minor changes. started writting own 3d math library and started implementation for linux/mac
This commit is contained in:
40
main.cpp
40
main.cpp
@@ -1,3 +1,4 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <handleapi.h>
|
||||
#include <thread>
|
||||
@@ -26,7 +27,7 @@
|
||||
std::mutex g_mutex;
|
||||
Quaternion g_currQuat = {1.0f, 0.0f, 0.0f, 0.0f};
|
||||
std::vector<Quaternion> g_quadHistory;
|
||||
bool g_running = true;
|
||||
bool g_running = false;
|
||||
HANDLE g_serialHandle = INVALID_HANDLE_VALUE;
|
||||
|
||||
|
||||
@@ -113,7 +114,7 @@ void serialParserThread() {
|
||||
|
||||
// close and exit the thread
|
||||
CloseHandle(g_serialHandle);
|
||||
std::cout << "Serial communicatin thread exiting" << std::endl;
|
||||
std::cout << "Serial communication thread exiting" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -293,7 +294,8 @@ int main() {
|
||||
|
||||
// Start serial parsing thread
|
||||
// pass the address of the code in memory so that thread can start its instance of the function
|
||||
std::thread parserThread(serialParserThread);
|
||||
//std::thread parserThread(serialParserThread);
|
||||
std::thread* parserThread = nullptr;
|
||||
|
||||
// set rendering state of window
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
@@ -302,7 +304,7 @@ int main() {
|
||||
|
||||
|
||||
// main rendering loop for the ui
|
||||
while (g_running && !glfwWindowShouldClose(window)) {
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
// process new events from window evevnt queue
|
||||
glfwPollEvents();
|
||||
// clear the color buffer == clear the screen / / GL_DEPTH_BUFFER_BIT would be for 3D rendering
|
||||
@@ -329,7 +331,7 @@ int main() {
|
||||
// apply MVP
|
||||
//model = glm::rotate(model, (float)glfwGetTime() * glm::radians(50.0f), glm::vec3(0.5f, 1.0f, 0.0f));
|
||||
|
||||
// this need to be deleted and redone
|
||||
// this needs to be deleted and redone
|
||||
glm::quat kekus_q(g_currQuat.w, g_currQuat.x, g_currQuat.y, g_currQuat.z);
|
||||
|
||||
|
||||
@@ -379,6 +381,26 @@ int main() {
|
||||
|
||||
ImGui::Text("Hello Daddy, I'm here to serve");
|
||||
ImGui::Text("w: %.4f x: %.4f y: %.4f z: %.4f", lQuad.w, lQuad.x, lQuad.y, lQuad.z);
|
||||
ImGui::Text("Connection to MCU: ");
|
||||
|
||||
ImGui::BeginDisabled(parserThread != nullptr);
|
||||
if (ImGui::Button("Connect")) {
|
||||
g_running = true;
|
||||
parserThread = new std::thread(serialParserThread);
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::BeginDisabled(parserThread == nullptr);
|
||||
if (ImGui::Button("Disconnect")) {
|
||||
g_running = false;
|
||||
parserThread -> join();
|
||||
delete parserThread;
|
||||
parserThread = nullptr;
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
|
||||
// create scrolling section for last 200 measurements
|
||||
ImGui::BeginChild("History", ImVec2(0, 300), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
@@ -405,10 +427,10 @@ int main() {
|
||||
}
|
||||
|
||||
// set the parsing thread to exit and wait for it
|
||||
g_running = false;
|
||||
if (parserThread.joinable()) {
|
||||
parserThread.join();
|
||||
}
|
||||
// g_running = false;
|
||||
//if (parserThread.joinable()) {
|
||||
// parserThread.join();
|
||||
//}
|
||||
|
||||
// clean up ImGui
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
|
||||
Reference in New Issue
Block a user