If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
int GetPixelFormat (HDC hdc);
int DescribePixelFormat (
HDC hdc,
int iPixelFormat,
UINT nBytes,
LPPIXELFORMATDESCRIPTOR ppfd
);
PIXELFORMATDESCRIPTOR is a large struct which includes the size and offsets of each colour channel. This struct is actually used in the msw implementation of wxGLCanvas e.g. in wxGLCanvas::Create(...) but I don't see any function to query it.
The background to this is that I have an app which uses glReadPixels. It works with render buffers (because the app knows the format) but I want to extend it so that it works with windows as well. (And yes, I know about the issues with swap buffers and obscured windows.)
I've not checked how this is done on other platforms so maybe the answer is that it's impossible and I just have to use windows-specific code. Or is it there and I just missed it?
No, wxWidgets doesn't provide a function for retrieving the pixel format (PF). Normally, this PF is the same the app asked for (the wxGLCanvas attributes). But you can can use MSW specific function GetPixelFormat, and use it with the HDC returned by wxGLCanvas::GetHDC()
so that it works with windows as well
Sorry, I don't understand this sentence. OpenGL works with its own buffers, not with "window buffer".
Manolo wrote: ↑Sun Mar 28, 2021 8:01 pm
No, wxWidgets doesn't provide a function for retrieving the pixel format (PF). Normally, this PF is the same the app asked for (the wxGLCanvas attributes). But you can can use MSW specific function GetPixelFormat, and use it with the HDC returned by wxGLCanvas::GetHDC()
In my case, the app uses the platform defaults so it doesn't know the format being requested. I guess I could possibly use wxGLAttributes::GetGLAttrs() but documentation doesn't specify the details of what is returned:
"Returns a pointer to the internal list of attributes. It's very unlikely you need this function. If the list is empty the returned value is NULL."
so that it works with windows as well
Sorry, I don't understand this sentence. OpenGL works with its own buffers, not with "window buffer".
I meant the back buffer where the corresponding front buffer is displayed in the window. ('display buffer' maybe?)
Is there a reason GetPixelFormat isn't in wxWidgets? It seems an obvious function to include and I've seen various requests for it in the past.
I guess I could possibly use wxGLAttributes::GetGLAttrs() but documentation doesn't specify the details of what is returned:
Oh, yes, I forgot this function. It returns a pointer-to-integer with the list of "ints" that compose the list of parameters needed for OGL. The parameters values are OS-dependant, but this is not an issue as you will use them also in OS-dependant way.
I meant the back buffer
Then tell OGL to select it before using glReadPixels.
I found that OpenGL actually provides this functionality. There's a bit of complexity if you need it to work with both windows and FBOs but all the queries are there e.g.