Jump to content
  • Advertisement


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


wglMakeCurrent problems...

This topic is 5481 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

How is wglMakeCurrent working? My rendering loop always looked like: if (wglGetCurrentContext()==NULL) wglMakeCurrent(hDC,hRC); render(); SwapBuffers(hDC); And that works fine. However if I do like: wglMakeCurrent(hDC,hRC); render(); SwapBuffers(hDC); It does just display a grey background (which is refreshed). Why? Recently I implemented offscreen rendering using p buffers. My loop looks like this: wglMakeCurrent(pBuffer_hDC,pBuffer_hRC); renderToBuffer(); wglMakeCurrent(normal_hDC,normal_hRC); render(); SwapBuffers(hDC); and this does not work either!! It displays one frame and then keeps displaying the same frame (no change). Please tell me what I am doing wrong. Thanks

Share this post

Link to post
Share on other sites
Probably when you call MakeCurrent in the first code you use the right hDC,hRC...in the other codes you use different (and wrong) hDCs. hdc must be the same also in SwapBuffer()...
My suggestion is to create an hdc and consequently an hrc in your init routine for every context (window, bitmap or pbuffer) and then use something like this

// Render

However it is said to say that in Windows and OpenGL hdcs are strange things....

Share this post

Link to post
Share on other sites
Thanks blizzard999,

I found the problem and apologize for my stupidity:
When I created the context with


hRC was a local variable masking the global one! Later I used the global version of hRC which explains why it didn''t work!

I have another quick question:

glGetError is supposed to return the last error code and clear the last error. In my code, I activate my pbuffer with:

int e0=glGetError();
bool successful=wglMakeCurrent(pBuffer_hDC,pBuffer_hRC);
int e1=glGetError();
int e2=glGetError();

The strange thing is:


1.) How can my call be successful and generate an error code at the same time?
2.) Why is e2 not GL_NO_ERROR? (the error code should be cleared after the call int e1=glGetError(); )

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!