public:
std::mutex data_mutex;
unsigned int mvp_uniform, v_attrib, t_attrib, program, vbuf, cbuf, ebuf, tex, models_buffer;
+ bool visible = true;
bool collision_check = false; // Consider separating out player from projectile collision here
std::vector<glm::vec3> locations;
glm::vec3 size; // What about non-square objects?
/* Global section */
int time_resolution = 10;
int framecount = 0;
+int loopcount = 0;
std::vector<gameobject*> objects;
projectile ice_balls;
}
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods){
+ if(GLFW_KEY_F3 == key && 1 == action)
+ main_hud.visible = !main_hud.visible;
if(GLFW_KEY_W == key && 1 == action){
player_key_status.forward = 1;
}
int cpu_time = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time).count();
last_call = start_time;
int sleep_time = 1000 - cpu_time;
- // printf("Loop time: %d Sleep time: %d CPU time: %d\n", loop_time, sleep_time, cpu_time);
+ loopcount++;
if(sleep_time > 100 )
std::this_thread::sleep_for(std::chrono::microseconds(sleep_time));
}
std::thread object_movement_thread(object_movement);
std::thread animation_thread(animation);
std::thread collision_detection_thread(collision_detection);
+ std::thread display_fps([](){
+ while(!shutdown_engine){
+ double loop_time = 1000.0 / loopcount;
+ main_hud.lprintf(1, "FPS: %4d Move: %lf", framecount, loop_time);
+ framecount = 0;
+ loopcount = 0;
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
+ });
+
glEnable(GL_DEPTH_TEST);
while (!glfwWindowShouldClose(window)) {
glm::mat4 vp = projection * view;
for(gameobject* o : objects)
- o->draw(vp);
+ if(o->visible)
+ o->draw(vp);
// grand_mutex.unlock();
glfwSwapBuffers(window);