Got the octree data to the GPU and it's traversing it, but it having some corruption issues. Endianness???

This commit is contained in:
MitchellHansen
2017-09-24 00:50:09 -07:00
parent ba11f9c081
commit ebce781eb3
12 changed files with 403 additions and 152 deletions

View File

@@ -3,7 +3,7 @@
#include "imgui/imgui-SFML.h"
Application::Application() {
srand(time(nullptr));
//srand(time(nullptr));
window = std::make_shared<sf::RenderWindow>(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
window->setMouseCursorVisible(false);
@@ -23,7 +23,7 @@ Application::~Application() {
bool Application::init_clcaster() {
Map _map(32);
//Map _map(32);
//return 0;
// Start up the raycaster
@@ -38,6 +38,10 @@ bool Application::init_clcaster() {
// Send the data to the GPU
raycaster->assign_map(map);
octree = std::make_shared<Map>(32);
raycaster->assign_octree(octree);
// Create a new camera with (starting position, direction)
camera = std::make_shared<Camera>(
sf::Vector3f(50, 50, 50),
@@ -90,6 +94,8 @@ bool Application::init_events() {
window_handler->subscribe_to_publisher(&input_handler, vr::Event::EventType::Closed);
window_handler->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyPressed);
//camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::JoystickMoved);
return true;
}
@@ -234,6 +240,47 @@ bool Application::game_loop() {
ImGui::End();
ImGui::Begin("Controller debugger");
ImDrawList* draw_list = ImGui::GetWindowDrawList();
static ImVec4 col = ImVec4(1.0f, 0.0f, 1.0f, 1.0f);
const ImVec2 p = ImGui::GetCursorScreenPos();
const ImU32 col32 = ImColor(col);
std::vector<float> axis_values = {
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::X) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::Y) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::U) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::R) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::Z) / 2,
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::V) / 2
};
ImGui::Columns(3, "Axis's"); // 4-ways, with border
ImGui::Separator();
ImGui::Text("X Y"); ImGui::NextColumn();
ImGui::Text("U R"); ImGui::NextColumn();
ImGui::Text("Z V"); ImGui::NextColumn();
ImGui::Separator();
for (int i = 0; i < 3; i++) {
float offset = ImGui::GetColumnWidth(i);
draw_list->AddLine(ImVec2(p.x + 0 + offset * i, p.y + 50), ImVec2(p.x + 100 + offset * i, p.y + 50), col32, 1.0);
draw_list->AddLine(ImVec2(p.x + 50 + offset * i, p.y + 0), ImVec2(p.x + 50 + offset * i, p.y + 100), col32, 1.0);
draw_list->AddCircleFilled(ImVec2(p.x + axis_values[2 * i] + 50 + offset * i, p.y + axis_values[2 * i + 1] + 50), 6, col32, 32);
ImGui::Dummy(ImVec2(100, 100));
ImGui::NextColumn();
}
ImGui::End();
//ImGui::ShowTestWindow();
ImGui::Render();
// ImGUI messes up somthing in the SFML GL state, so we need a single draw call to right things