Changeset 772d8c7 in opengl-game


Ignore:
Timestamp:
Aug 3, 2017, 3:03:21 AM (7 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
c40990d
Parents:
be246ad
Message:

Add fullscreen and anti-aliasing support and some more logging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • new-game.cpp

    rbe246ad r772d8c7  
    99using namespace std;
    1010
     11const bool FULLSCREEN = true;
     12
     13void glfw_error_callback(int error, const char* description) {
     14   gl_log_err("GLFW ERROR: code %i msg: %s\n", error, description);
     15}
     16
    1117int main(int argc, char* argv[]) {
    1218   cout << "New OpenGL Game" << endl;
    1319
    14    restart_gl_log();
     20   if (!restart_gl_log()) {}
     21   gl_log("starting GLFW\n%s\n", glfwGetVersionString());
    1522
     23   glfwSetErrorCallback(glfw_error_callback);
    1624   if (!glfwInit()) {
    1725      fprintf(stderr, "ERROR: could not start GLFW3\n");
     
    2634#endif
    2735
    28    GLFWwindow* window = glfwCreateWindow(640, 480, "Hello Triangle", NULL, NULL);
     36   glfwWindowHint(GLFW_SAMPLES, 4);
     37
     38   GLFWwindow* window = NULL;
     39
     40   if (FULLSCREEN) {
     41      GLFWmonitor* mon = glfwGetPrimaryMonitor();
     42      const GLFWvidmode* vmode = glfwGetVideoMode(mon);
     43      window = glfwCreateWindow(vmode->width, vmode->height, "Extended GL Init", mon, NULL);
     44   } else {
     45      window = glfwCreateWindow(640, 480, "Hello Triangle", NULL, NULL);
     46   }
     47
    2948   if (!window) {
    3049      fprintf(stderr, "ERROR: could not open window with GLFW3\n");
     
    93112      glBindVertexArray(vao);
    94113      glDrawArrays(GL_TRIANGLES, 0, 3);
     114
    95115      glfwPollEvents();
    96116      glfwSwapBuffers(window);
     117
     118      if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_ESCAPE)) {
     119         glfwSetWindowShouldClose(window, 1);
     120      }
    97121   }
    98122
Note: See TracChangeset for help on using the changeset viewer.