what is linked to HDC and what to HGLRC?


I recently started using p-buffers. When switching between the rendering contexts, I noticed that I had to set some parameters twice. (like lighting and depth functions) I also noticed that I had to create textures and shaders twice.
Each of these things had to be done twice. (for both the screen and the p-buffer)

So what I’d like to know is:

  • Which types of properties are linked to rendering contexts(HGLRC) and which are linked to device interfaces(HDC)?

  • Is it possible to make the p-buffer and screen share parameters, shaders, textures etc. For instance by making them use the same rendering context?

Everything opengl-related belongs to the rendering context (e.g. textures, shaders, buffers).

You can use wglShareLists to share resources between compatible contexts. Contexts are generally compatible when they have the same pixel format and the same renderer.

And if you can use FBO, just forget about those ugly pbuffers.

but… Render targets always have different pixel formats don’t they?

I mean, the screen’s pixel format has “render to window” as a setting and the pbuffer’s pixel has settings like: “render to pbuffer” and “bind to texture”.

In all my tests, sharing between pbuffer RC and window RC worked.
GL_EXT_framebuffer_object is way better than pbuffers by the way.

OK thanks

but… Render targets always have different pixel formats don’t they?

True. Different color depths (16 vs 32 bits), z-buffers, etc are the things I had in mind.

That said, use FBOs if you have a choice :wink:

A little off-topic, sorry, but could you please explain in more detail what do you mean by “the same pixel format” and “the same renderer”?

I am trying to create an offscreen rendering context that shares the display lists with a regular RC. Then I’m trying to redraw the GL scene that contains some stuff drawn directly and some other stuff drawn with help of already GL_COMPILE’d display lists, I see the regular stuff in the output bitmap but the display lists are not executed! Obviously, it means wglShareLists() fails in my case, and I haven’t got a clue how to cope with this. I have experimented with pixel formats, no result so far.

In MSDN artcile for wglShareLists() I have found:

Rendering contexts can share display lists only if they use the same implementation of OpenGL functions.

Does it mean that sharing sharing display lists between a regular RC and the one mapped to a bitmap is impossible in principle?

“one mapped to a bitmap” : I am pretty sure that the one you talk about is not hardware accelerated, so no, so sharing.
Use FBO instead !!!

Thanks a lot!
Already found the same answer (concerning sharing possibility) here: http://www.opengl.org/discussion_boards/…true#Post177215