View Full Version : glTexImage2D depends on wglMakeCurrent?

06-18-2003, 05:37 PM
Greetings all,

I'm working on a rudimentary modelling tool in MFC just for a learning experience. It's still in very infantile stages.

I have a splitter view where one side is a tabbed dialog and the other is the OpenGL view, and each tab is either a light, the rectangles, prism, spheres, and textures. On the texture tab you browse to your .bmp files and it displays a preview.

I was too lazy to look up how to take general data and map it to a child window, so I just made the child window an OpenGL context and just drew it in ortho mode.

Something really strange then happened. The first texture in the preview window was always blank, but subsequent textures always appeared. Then went I went to apply the textures to my prisms, and only one of the textures would appear in the main window!

This seems totally insane, but it seems like whichever of the contexts was most recently set with wglMakeCurrent was the only one "receiving" the texture - I was so fascinated by this that I gave my texture class two IDs - one for the preview and one for the main window, and just loaded it into GL twice. I most certainly won't code it that way going forward but it's sure an interesting phenomenon!

If anyone would like to see this effect in action I've uploaded the infantile code to my page (daltxcoltsfan.tripod.com/OpenGL/OpenGL.htm).

Has anyone else ever encountered this??? Is it by design or am I doing something wrong?


06-18-2003, 10:59 PM
It's by design.

Unless you use wglShareLists(), each rendering context will have its own texture objects.