OpenGL glReadPixels equivalent and GX_CULL question September 12, 2010 04:45PM | Registered: 14 years ago Posts: 15 |
Re: OpenGL glReadPixels equivalent and GX_CULL question September 12, 2010 05:05PM | Registered: 14 years ago Posts: 15 |
Quote
dashxdr
Is there an equivalent to glReadPixels? I want to be able to capture the video buffer for a screenshot.
/** * Make a snapshot of the screen in a texture WITHOUT ALPHA LAYER. * @param posx top left corner of the grabbed part. * @param posy top left corner of the grabbed part. * @param tex A pointer to a texture representing the screen or NULL if an error occurs. * @param clear When this flag is set to true, the screen is cleared after copy. */ void GRRLIB_Screen2Texture (int posx, int posy, GRRLIB_texImg *tex, bool clear) { if(tex->data != NULL) { GX_SetTexCopySrc(posx, posy, tex->w, tex->h); GX_SetTexCopyDst(tex->w, tex->h, GX_TF_RGBA8, GX_FALSE); GX_CopyTex(tex->data, GX_FALSE); GX_PixModeSync(); GRRLIB_FlushTex(tex); if(clear) GX_CopyDisp(xfb[!fb], GX_TRUE); } }
Re: OpenGL glReadPixels equivalent and GX_CULL question September 13, 2010 01:58AM | Registered: 15 years ago Posts: 118 |
Yes, There is! I actually had to find it when porting the OGL code to GX for DesmumeWii. The code to do so is thus:Quote
dashxdr
Is there an equivalent to glReadPixels?
GX_SetTexCopySrc(x, y, w, h); GX_SetTexCopyDst(w, h, GX_TF_RGBA8, GX_FALSE); GX_CopyTex(copyToThis, GX_TRUE); GX_PixModeSync();Just replace it with your numbers. You can see the whole thing in the ReadFramebuffer() function here. I would also recommend turning off the copy filter before copying, and re-setting it when you're done.
Front-facing on the Wii is the opposite direction as it is in OGL. This is intentional and part of the hardware. This is why we had to reverse the order of vertices here.Quote
dashxdr
I wonder if the #defines for GX_CULL_FRONT and GX_CULL_BACK are reversed...
Re: OpenGL glReadPixels equivalent and GX_CULL question September 13, 2010 04:13AM | Registered: 14 years ago Posts: 15 |