Changeset e6bc0f4 in opengl-game for new-game.cpp
- Timestamp:
- May 10, 2019, 6:18:31 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 155a7cf
- Parents:
- c55614a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
rc55614a re6bc0f4 167 167 void mouse_button_callback(GLFWwindow* window, int button, int action, int mods); 168 168 void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); 169 void window_size_callback(GLFWwindow* window, int width, int height); 169 170 170 171 void APIENTRY debugGlCallback( … … 261 262 bool key_down[NUM_KEYS]; 262 263 263 int wi dth = 640;264 int height = 480;264 int windowWidth = 640; 265 int windowHeight = 480; 265 266 266 267 vec3 cam_pos; … … 329 330 const GLFWvidmode* vmode = glfwGetVideoMode(mon); 330 331 331 wi dth = vmode->width;332 height = vmode->height;332 windowWidth = vmode->width; 333 windowHeight = vmode->height; 333 334 cout << "Fullscreen resolution " << vmode->width << "x" << vmode->height << endl; 334 335 } 335 window = glfwCreateWindow(wi dth, height, "New OpenGL Game", mon, NULL);336 window = glfwCreateWindow(windowWidth, windowHeight, "New OpenGL Game", mon, NULL); 336 337 337 338 if (!window) { … … 342 343 343 344 glfwMakeContextCurrent(window); 345 glViewport(0, 0, windowWidth, windowHeight); 346 344 347 glewExperimental = GL_TRUE; 345 348 glewInit(); … … 351 354 cout << "Bound debug callback" << endl; 352 355 } else { 353 cout << "OpenGL debugg message callback is not supported" << endl;356 cout << "OpenGL debug message callback is not supported" << endl; 354 357 } 355 358 … … 394 397 glfwSetMouseButtonCallback(window, mouse_button_callback); 395 398 glfwSetKeyCallback(window, key_callback); 399 400 glfwSetWindowSizeCallback(window, window_size_callback); 396 401 397 402 const GLubyte* renderer = glGetString(GL_RENDERER); … … 590 595 // (Maybe I should just use glm::perspective, after making sure it matches what I have now) 591 596 float fov = 67.0f * ONE_DEG_IN_RAD; 592 float aspect = (float)wi dth / (float)height;597 float aspect = (float)windowWidth / (float)windowHeight; 593 598 594 599 float range = tan(fov * 0.5f) * NEAR_CLIP; … … 961 966 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 962 967 968 // Anton's book suggests placing this here, after glClear(). Check it's impact on framerate 969 //glViewport(0, 0, windowWidth, windowHeight); 970 963 971 switch (curState) { 964 972 case STATE_MAIN_MENU: … … 1002 1010 selectedObject = NULL; 1003 1011 1004 float x = (2.0f*mouse_x) / wi dth - 1.0f;1005 float y = 1.0f - (2.0f*mouse_y) / height;1012 float x = (2.0f*mouse_x) / windowWidth - 1.0f; 1013 float y = 1.0f - (2.0f*mouse_y) / windowHeight; 1006 1014 1007 1015 cout << "x: " << x << ", y: " << y << endl; … … 1051 1059 // should be true for GLFW_PRESS and GLFW_REPEAT 1052 1060 key_down[key] = (action != GLFW_RELEASE); 1061 } 1062 1063 void window_size_callback(GLFWwindow* window, int width, int height) { 1064 cout << "Window resized to (" << width << ", " << height << ")" << endl; 1065 1066 windowWidth = width; 1067 windowHeight = height; 1068 1069 // TODO: Ideally, remove the window title bar when the window is maximized 1070 // Check https://github.com/glfw/glfw/issues/778 1071 1072 // This requires glfw3.3. I think I have to upgrade 1073 // Doesn't seem to be needed in OSX and also causes a segfault there 1074 //glfwSetWindowAttrib(window, GLFW_DECORATED, GLFW_FALSE); 1053 1075 } 1054 1076 … … 2444 2466 int padding = 4; 2445 2467 ImGui::SetNextWindowPos(ImVec2(-padding, -padding), ImGuiCond_Once); 2446 ImGui::SetNextWindowSize(ImVec2(wi dth + 2 * padding, height + 2 * padding), ImGuiCond_Once);2468 ImGui::SetNextWindowSize(ImVec2(windowWidth + 2 * padding, windowHeight + 2 * padding), ImGuiCond_Always); 2447 2469 ImGui::Begin("WndMain", NULL, 2448 2470 ImGuiWindowFlags_NoTitleBar |
Note:
See TracChangeset
for help on using the changeset viewer.