Why should we load textures AFTER creating windows in OpenGL?

In my situation

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

worked but

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

no. Why?

+3
source share
2 answers

Often, with some implementations of the / OpenGL drivers, the window-creating action has the side effect of determining where the memory for textures, off-screen buffers and the window itself will actually be stored, and therefore how large it will be.

Without creating a window (or, more precisely, a display context), it is difficult (i.e. impossible) to determine where to place the texture after loading.

+1
source

OpenGL OpenGL. GLUT OpenGL . PBuffers OpenGL . X11/GLX PBuffers ; Windows OpenGL, PBuffer, OpenGL. PBuffer OpenGL, .

+2

Source: https://habr.com/ru/post/1793230/


All Articles