2016-11-30 7 views
0

В настоящее время я после учебника, который имеет код инициализации для создания окнаЦели ложной GLFW_VISIBILE Подсказки Хотя привязки OpenGL контекст

private void init() { 
    // Setup an error callback. The default implementation 
    // will print the error message in System.err. 
    errorCallback = GLFWErrorCallback.createPrint(System.err); 
    glfwSetErrorCallback(errorCallback); 

    // Initialize GLFW. Most GLFW functions will not work before doing this. 
    if (!glfwInit()) { 
     throw new IllegalStateException("Unable to initialize GLFW"); 
    } 

    // Configure our window 
    glfwDefaultWindowHints(); // optional, the current window hints are already the default 
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation 
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable 

    int WIDTH = 300; 
    int HEIGHT = 300; 

    // Create the window 
    window = glfwCreateWindow(WIDTH, HEIGHT, "Hello World!", NULL, NULL); 
    if (window == NULL) { 
     throw new RuntimeException("Failed to create the GLFW window"); 
    } 

    // Setup a key callback. It will be called every time a key is pressed, repeated or released. 
    glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() { 
     @Override 
     public void invoke(long window, int key, int scancode, int action, int mods) { 
      if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) { 
       glfwSetWindowShouldClose(window, true); // We will detect this in our rendering loop 
      } 
     } 
    }); 

    // Get the resolution of the primary monitor 
    GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); 
    // Center our window 
    glfwSetWindowPos(
      window, 
      (vidmode.width() - WIDTH)/2, 
      (vidmode.height() - HEIGHT)/2 
    ); 

    // Make the OpenGL context current 
    glfwMakeContextCurrent(window); 
    // Enable v-sync 
    glfwSwapInterval(1); 

    // Make the window visible 
    glfwShowWindow(window); 
} 

Обратите внимание на glfwWindowHint(GLFW_VISIBLE, GL_FALSE); намеке отключен, то после создания окна, установив ключевые обратные вызовы, привязка контекста opengl, он снова включен glfwShowWindow(window);

Документация не предлагает ничего подобного, и удаление обеих строк ничего не изменит. Зачем отключить подсказку в первую очередь?

Учебник: https://lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl/content/chapter1/chapter1.html

ответ

3

Он отключает visablity так что он может настроить размер, изменение позиции, и инициализировать контекст без клиента, имеющего свидетелем этого. В разделе Окна Visablity в GLFW docs:

оконный режим окно может быть создано изначально скрыто с GLFW_VISIBLE окна подсказки. Созданные в Windows скрытые полностью невидимы для пользователя, пока не будут показаны. Это может быть полезно, если вам нужно установить , прежде чем показывать его, например, перемещая его до в определенном месте.

программа Youre следует, что точный пример, вызвав

glfwSetWindowPos(
      window, 
      (vidmode.width() - WIDTH)/2, 
      (vidmode.height() - HEIGHT)/2 
    ); 
+0

Не видел, что в документации, спасибо! – jthort

+0

Lemme смотреть это галочка !! ;) –

+0

Придется дождаться определенного количества времени до принятия – jthort