PDA

View Full Version : what is linked to HDC and what to HGLRC?



Neonic
02-24-2009, 02:39 PM
Hello,

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?

Stephen A
02-24-2009, 02:56 PM
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.

ZbuffeR
02-24-2009, 03:25 PM
And if you can use FBO, just forget about those ugly pbuffers.

Neonic
02-25-2009, 07:56 AM
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".

ZbuffeR
02-25-2009, 09:45 AM
In all my tests, sharing between pbuffer RC and window RC worked.
GL_EXT_framebuffer_object is way better than pbuffers by the way.

Neonic
02-25-2009, 10:52 AM
OK thanks

Stephen A
02-26-2009, 03:22 AM
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 ;)

sansan
03-02-2009, 01:23 AM
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.

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?

ZbuffeR
03-02-2009, 02:40 AM
"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 !!!

sansan
03-02-2009, 02:59 AM
Thanks a lot!
Already found the same answer (concerning sharing possibility) here: http://www.opengl.org/discussion_boards/...true#Post177215 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Board=3&Number=177215&Searchpage=1&Main=36379&Words=%2Bshare%2A+%2Bdisplay+%2Blist%2A+%2Bbitmap&topic=0&Search=true#Post177215)