weird clang bug where it doesn't generate append func for call in main.cpp. I copied the dll to get past the build error
This commit is contained in:
@@ -116,7 +116,7 @@
|
|||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>pthreadVC3d.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ext\pthreads4w-code\build\Debug\pthreadVC3d.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
@@ -145,4 +145,10 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PthreadDLL Include="ext\pthreads4w-code\build\Debug\pthreadVC3d.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Target Name="CopyFiles">
|
||||||
|
<Copy SourceFiles="@(PthreadDLL)" DestinationFolder="$(TargetDir)" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
90
src/main.cpp
90
src/main.cpp
@@ -5,7 +5,6 @@
|
|||||||
#include <glm/ext/matrix_transform.hpp>
|
#include <glm/ext/matrix_transform.hpp>
|
||||||
#include <glm/ext/vector_float3.hpp>
|
#include <glm/ext/vector_float3.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@@ -42,46 +41,45 @@ body create_new_sphere() {
|
|||||||
static bool stop = false;
|
static bool stop = false;
|
||||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
const float max_hp = 10; // Number of scans (without a particular barcode) for which the sphere will still be visible
|
const float max_hp = 10; // Number of scans (without a particular barcode) for which the sphere will still be visible
|
||||||
array<std::tuple<char*, body, float>> camera_bodies;
|
std::vector<std::tuple<char*, body, float>> camera_bodies; // I would use my array here, but was getting a linking error
|
||||||
|
|
||||||
//void process_cin(void* args) {
|
void *process_cin(void* args) {
|
||||||
// size_t len = 256;
|
std::string line;
|
||||||
// std::string line;
|
while (true) {
|
||||||
// while (true) {
|
std::getline(std::cin, line);
|
||||||
// std::getline(std::cin, line);
|
array<char*> words = split_str(line.c_str());
|
||||||
// array<char*> words = split_str(line.c_str());
|
assert(words.len == 4);
|
||||||
// assert(words.len == 4);
|
printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging
|
||||||
// printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging
|
pthread_mutex_lock(&lock);
|
||||||
// pthread_mutex_lock(&lock);
|
float x = atof(words[1]);
|
||||||
// float x = atof(words[1]);
|
float y = atof(words[2]);
|
||||||
// float y = atof(words[2]);
|
float z = atof(words[3]);
|
||||||
// float z = atof(words[3]);
|
glm::vec3 new_loc = glm::vec3(x, y, z);
|
||||||
// glm::vec3 new_loc = glm::vec3(x, y, z);
|
bool found_match = false;
|
||||||
// bool found_match = false;
|
for (int i = 0; i < camera_bodies.size(); i++) {
|
||||||
// for (int i = 0; i < camera_bodies.len; i++) {
|
if (strcmp(words[0], std::get<0>(camera_bodies[i])) == 0) {
|
||||||
// if (strcmp(words[0], std::get<0>(camera_bodies[i])) == 0) {
|
glm::vec4 &transl = std::get<1>(camera_bodies[i]).pose[4];
|
||||||
// glm::vec4 &transl = std::get<1>(camera_bodies[i]).pose[4];
|
transl = 0.9f*transl + 0.1f*glm::vec4(new_loc, 1); // filter
|
||||||
// transl = 0.9f*transl + 0.1f*glm::vec4(new_loc, 1); // filter
|
|
||||||
//
|
std::get<1>(camera_bodies[i]).color = glm::vec4(i&0x4, i&0x2, i&0x1, 1);
|
||||||
// std::get<1>(camera_bodies[i]).color = glm::vec4(i&0x4, i&0x2, i&0x1, 1);
|
std::get<2>(camera_bodies[i]) = max_hp;
|
||||||
// std::get<2>(camera_bodies[i]) = max_hp;
|
found_match = true;
|
||||||
// found_match = true;
|
} else {
|
||||||
// } else {
|
float &cur_hp = std::get<2>(camera_bodies[i]);
|
||||||
// float &cur_hp = std::get<2>(camera_bodies[i]);
|
if (cur_hp > 0) cur_hp -= 1;
|
||||||
// if (cur_hp > 0) cur_hp -= 1;
|
std::get<1>(camera_bodies[i]).color = glm::vec4(i&0x4, i&0x2, i&0x1, cur_hp/max_hp);
|
||||||
// std::get<1>(camera_bodies[i]).color = glm::vec4(i&0x4, i&0x2, i&0x1, cur_hp/max_hp);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
if (!found_match) {
|
||||||
// if (!found_match) {
|
body b = create_new_sphere();
|
||||||
// body b = create_new_sphere();
|
int i = camera_bodies.size();
|
||||||
// int i = camera_bodies.len;
|
b.color = glm::vec4(i&0x4, i&0x2, i&0x1, max_hp);
|
||||||
// b.color = glm::vec4(i&0x4, i&0x2, i&0x1, max_hp);
|
auto t = std::make_tuple(words[0], b, max_hp);
|
||||||
// auto t = std::make_tuple(words[0], b, max_hp);
|
camera_bodies.push_back(t);
|
||||||
// append(camera_bodies, t);
|
}
|
||||||
// }
|
pthread_mutex_unlock(&lock);
|
||||||
// pthread_mutex_unlock(&lock);
|
}
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
static bool mouse_pressed = false;
|
static bool mouse_pressed = false;
|
||||||
static bool scroll_pressed = false;
|
static bool scroll_pressed = false;
|
||||||
@@ -199,10 +197,12 @@ int main() {
|
|||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
float time;
|
|
||||||
glm::mat4 projection_t
|
glm::mat4 projection_t
|
||||||
= glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 1300.0f);
|
= glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 1300.0f);
|
||||||
|
|
||||||
|
pthread_t thread_id;
|
||||||
|
pthread_create(&thread_id, NULL, process_cin, NULL);
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
process_input();
|
process_input();
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -211,6 +211,14 @@ int main() {
|
|||||||
|
|
||||||
draw_body(b2);
|
draw_body(b2);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&lock);
|
||||||
|
|
||||||
|
for (int i = 0; i < camera_bodies.size(); i++) {
|
||||||
|
draw_body(std::get<1>(camera_bodies[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&lock);
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user