开发者

Why we must load textures AFTER creating windows in OpenGL?

In my situation,

glutInitWindowSize(w_walker*8, h_walker);
glutCreateWindow("walker");
loadTexture("./fighter512.png");

worked, but

loadTextur开发者_如何学Pythone("./fighter512.png");
glutInitWindowSize(w_walker*8, h_walker);
glutCreateWindow("walker");

did not. Why?


OpenGL commands operate on a OpenGL context. GLUT creates a OpenGL context only after a window has been created. With PBuffers one can have a OpenGL context without a window. In X11/GLX creating PBuffers is straightforward; on Windows one has to create a dummy window first to access the OpenGL extensions used for creating a PBuffer, which requires an active OpenGL context beforehand. But once the PBuffer and a OpenGL context on it are created the dummy window is no longer needed.


Often, with some drivers/OpenGL implementations, the act of creating the window has the side effect of determining where the memory for textures, off-screen buffers and the window itself will actually live and consequently how big it will be too.

Without creating the window (or more precisely the rendering context) it's hard (i.e. impossible) to determine where to put the texture once loaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜