I have a very simple program:
glfwInit();
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
long w = glfwCreateWindow(400, 400, "test", 0, 0);
glfwMakeContextCurrent(w);
GL.createCapabilities();
// Frame start
GL11.glBegin(GL11.GL_LINE_LOOP);
GL11.glVertex2d(0.3, 0.3);
GL11.glVertex2d(0.7, 0.3);
GL11.glVertex2d(0.5, 0.7);
GL11.glEnd();
// Frame end
glfwSwapBuffers(w); // -- move this after showwindow to make it work, but causes white window to flash white when appearing because it has nothing rendered yet
glfwShowWindow(w);
while (!glfwWindowShouldClose(w)) {
glfwWaitEvents();
glfwPollEvents();
}
glfwDestroyWindow(w);
glfwTerminate();
but after executing I get a white window. I thought you could pre-render a frame so when you show the window you immediately have something drawn onto it instead of having to draw the frame after showing the window which creates a white flash. Basically how can I set the window to have drawn something without showing it because I think it just ignores draw calls when it is invisible
A window that is actually hidden (i.e. not mapped or minimized) doesn't own any active pixels, and hence you can't render to it. However if you see a "white flash", then a non-nil background color/brush has been set for the window, which would also interfere with regular rendering. So the first thing to do is making sure that background color/brush is being unset, so that it doesn't flash on expose events.
If you really want to prepare a rendering to be available right on window map, then you could do this by rendering off-screen to a framebuffer object, and then upon mapping could quickly fill the window framebuffer using glBlitFramebuffer