PDA

View Full Version : bad behavior of wglReleaseTexImageARB



V-man
04-17-2004, 03:59 PM
I having some difficulties again while working with render to texture. It's hard to explain it cause I tried various things and some of them work, some don't.

I create a p-buffer, I release it so that I can make it current and make some GL calls but in some circumstances wglReleaseTexImageARB fails.

myfunction_CreatePbuffer(); //success
wglMakeCurrent(MainWindowDC, MainWindowGL);
glBindTexture(GL_TEXTURE_2D, 0);
wglMakeCurrent(NULL, NULL);
wglReleaseTexImageARB; //fails

GetLastError with FormatString says "The procedure could not be found"
What the hell does that mean???

Anyway, I made some changed and that part works and it still doesn't make any sense.

In another part, I want to render to this RTT, so again I call

wglMakeCurrent(NULL, NULL);
wglReleaseTexImageARB

and it fails with the same message.

so I decieded to remove wglMakeCurrent(NULL, NULL); and now it returns 0 but the error message is "The operation completed successfully"

and then wglMakeCurrent(TexDC, TexGL);
returns 1 but nothing seems to be rendered to the texture. It always remains black.

The only thing that might explain it is that this is a MDI app with a single GL window.

When I worked with simple window or dialog based window, I had no such problems.

I must say that wgl functions suck big time.

plasmonster
04-17-2004, 04:19 PM
Why are you fooling with MakeCurrent when you release. As far as I know, you only need to do that before drawing to the texture.

Basic proceedure:

ReleaseTexture();
MakeTextureContextCurrent();
DrawToTexture();
MakePreviousContextCurrent();
...
BindTexture();
DrawWithTexture();

repeat.

Your call may fail becuse there is no context for it.

V-man
04-18-2004, 09:23 AM
Looking at NVidia's render_to_texture from their SDK, I solved it.

It looks like the problem comes from not having the right texture bound. So I guess you need to make a context current and also call glBindTexture before releasing or binding.

So you are partly correct.

plasmonster
04-18-2004, 09:30 AM
I assumed that it goes without saying that you need a current context before you make context specific calls. :)

edit:
By the way, i agree with you. It would be nice if some day the whole wgl business went away.