Archived

This topic is now archived and is closed to further replies.

OGL textures and MFC

This topic is 5087 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all; My Question: On App Init I gather textures using - glGenTextures() - glBindTexture() - gluBuild2DMipmaps() ...then I call glIsTexture() on each texture to ensure that each GLuint ''texture name'' is an actual texture. I always get ''true''. On subesquent draw operations I again call glIsTexture() before binding and I always get ''false''...? Reloading textures once per frame is not viable ''soft real-time'' solution. Perhaps OpenGL with MFC threading issues could be the culprit so I will also post on an MFC forum but I don''t feel that is the problem. By the way, texture memory is not the problem (only two textures and both are less than 256 X 256). Also, I have been using OpenGL quite successfully for over a year now including a well received Full Sail final project. - I have never had any problem before with OpenGL(not including bad code on my part). - I have never used OpenGL and MFC together before. Any help would be great! -c3019

Share this post


Link to post
Share on other sites
do you have a a valid opengl context when you''re creating the textures? maybe you create your textures with a different (or non valid) context and your draw code occures after you initialized your context so that those texture objects dont exist in your valid context.

Share this post


Link to post
Share on other sites
_w- ''textures created while the HGLRC is bound to a speparate HDC will fail to render on the same HGLRC when bound to a different HDC...?''
Perhaps, I misunderstood.
I create a valid HGLRC that matches the PIXELFORMAT that I am using and then I acquire textures. The textures create OK. Infact, the last texture that is bound still draws even though its name triggers a failure in ''glIsTexture''(this originally made me think that I was deleting the memory prematurely, but that is not the case).

I will look into what you are saying but I get the feeling I am misunderstanding you...

Thnx for ANY AND ALL help.

-c3019

Share this post


Link to post
Share on other sites
quote:
Original post by citizen3019
Hello all;

My Question:

On App Init I gather textures using
- glGenTextures()
- glBindTexture()
- gluBuild2DMipmaps()

...then I call glIsTexture() on each texture to ensure that each GLuint ''texture name'' is an actual texture. I always get ''true''.

On subesquent draw operations I again call glIsTexture() before binding and I always get ''false''...?



Probably _walrus is right...have you called ''wglMakeCurrent()'' with your HGLRC before texture loading?
glAreTextureResidents() never works but glIsTexture() should...

quote:

Reloading textures once per frame is not viable ''soft real-time'' solution.



I use a class Texture (in my GL namespace) that handles the reloading; in practice I keep a static pointer to the texture in use. When I want to use a specific texture I call the method MakeCurrent() and if the texture is in use (it''s ptr is equal to the static pointer) I do nothing else I reload it.
The texture contains also an OpenGL texture ID so if it is valid (I want binding on it) I reload it via binding else I call TexImage again.

quote:

Perhaps OpenGL with MFC threading issues could be the culprit so I will also post on an MFC forum but I don''t feel that is the problem.

By the way, texture memory is not the problem (only two textures and both are less than 256 X 256).



glIsTexture() should be independent from it...you have simply requested a texture name (that is an idenifier).

quote:

Also, I have been using OpenGL quite successfully for over a year now including a well received Full Sail final project.
- I have never had any problem before with OpenGL(not including bad code on my part).
- I have never used OpenGL and MFC together before.



MFC is not the problem...I used OpenGL in Win32/MFC without difference (MFC is only a ugly OO version of Win32 programming



Share this post


Link to post
Share on other sites
quote:
Original post by blizzard999
Probably _walrus is right...


Probably... =)
But I resorted to Attaching CView::GetDC()->GetSafeDC() every on draw command and...
-same problem.
I checked for early release of dynamic mem or gl-tex-ids and no problem there either.

The kicker is when I run the same code in an MFCSDI app instead of the MFCMDI app...
-Success...!?

WTF.

By default I assmue my code is poor since, well...

quote:
Original post by blizzard999
I use a class Texture (in my GL namespace) that handles the reloading; in practice I keep a static pointer to the texture in use. When I want to use a specific texture I call the method MakeCurrent() and if the texture is in use (it''s ptr is equal to the static pointer) I do nothing else I reload it.
The texture contains also an OpenGL texture ID so if it is valid (I want binding on it) I reload it via binding else I call TexImage again.


That is an awesome idea that I''ve never thought of before, I might steal the idea. Thanks in advance.

quote:
Original post by blizzard999
ME: Perhaps OpenGL with MFC threading issues could be the culprit

YOU: glIsTexture() should be independent from it...you have simply requested a texture name (that is an idenifier).

OGL is thread independant but the context binding is.
quote:
Original post by blizzard999
(MFC is only a ugly OO version of Win32 programming

So true=)


#define Thanks everyone


Share this post


Link to post
Share on other sites