I was wondering if anyone perhaps has some experience with using the OpenGL.glReadPixels method to take RGBA screenshots of an OpenGLSurface control.
Here is my problem… I can read the pixel data from the current OpenGLSurface without a problem as follow:
OpenGL.glReadPixels(x, y, width, height, OpenGL.GL_RGBA, OpenGL.GL_UNSIGNED_BYTE, pixelData)
but the alpha values in the returned pixelData memoryblock are always fixed to 255. I’ve tracked down the issue to being that the cAlphaBits value of the PIXELFORMATDESCRIPTOR structure should not be 0.
However, I’m not sure how one would update the PIXELFORMATDESCRIPTOR structure of a given OpenGLSurface device context.
According to the LR, the following method might be helpful:
OpenGLSurface.Configure ( MemoryBlock )
But this method is nowhere to be found in the current version I’m using (Xojo 2014r1.1)?
Any help or suggestions would be greatly appreciated.
[quote=104977:@Alwyn Bester]According to the LR, the following method might be helpful:
OpenGLSurface.Configure ( MemoryBlock )[/quote]
That’s actually an event. It fires before Open and you return a MemoryBlock with your format values which are used in making the actual OpenGL Context. I made a class for Mac to make these MemoryBlocks but Windows has a different format, I guess it’s this http://msdn.microsoft.com/en-us/library/windows/desktop/dd368826(v=vs.85).aspx
A gazillion “thank yous” Will, I’ve been spending hours on trying to figure this one out.
I’m comfortable with the Windows format and should be able to get things working from here. Any chance that you would be willing to share the Mac class… (keeping in mind that I will probably add it to the open source 3D engine (X3) I’m working on)?
Sure, you can pull glConfigurizer (ezgl set > surfaces > configure >) from this project http://ezgl.tumblr.com Looking at it now it was designed kinda funky so that the Constructor and getMem method are hidden from autocomplete. But you can pull it out and make those methods public then it would be used something like…
[code]Function Configure() As MemoryBlock
dim pix As new glConfigurizer
In the Constructor a MemoryBlock is made that’s ass-u-med to be big enough to hold a complete set of attributes. Calling a named method just adds the corresponding attribute and possible value to the MemoryBlock and then getMem gets it. The Constants section here lists the attribute values
Great stuff, thanks… I’ve downloaded the project and will pull the relevant code from it.