I started programming the Wii by just writing pixels directly to the framebuffer. I've sinced learned how to use GX to draw textured polygons, which makes blending run much faster than it does on the CPU. Now I want to combine the two methods.
I want to draw a scene using GX and then draw some "overlays," by which I mean some text or a cursor that will overwrite parts of the image produced by GX. Is this sensible? I tried simply writing to the framebuffer after I called GX_DrawDone, but this produces a weird effect where my "overlay" pixels flickered erratically, as if my direct framebuffer write was occurring simultaneously with the GX framebuffer copy. I tried to use VIDEO_ClearFrameBuffer as I had done before with direct writing, and while this fixed the overlay flickering, it made half of the screen black.
It seems like GX is running as I'm doing my framebuffer writes, even though I tried to do them afterward. If this is the case, how do I synchronize the two processes?
Mixing GX and direct framebuffer writing
Re: Mixing GX and direct framebuffer writing
GX_DrawDone doesn't mean it has finished drawing 3D, it means you have finished sending commands to GPU, but GPU keeps working.
You can either wait for syncro and write your overlays just before copying the frameBuffer or you can draw your overlays as a texture to a polygon in front of the camera (using an orthogonal projection matrix).
You can either wait for syncro and write your overlays just before copying the frameBuffer or you can draw your overlays as a texture to a polygon in front of the camera (using an orthogonal projection matrix).
Re: Mixing GX and direct framebuffer writing
How do you wait for synchro? Synchro with what? Do I actually want to draw my overlays before calling GX_CopyDisp?techhnik wrote:You can either wait for syncro and write your overlays just before copying the frameBuffer...
My code is as follows:
Code: Select all
GX_Begin(GX_QUADS, GX_VTXFMT0, 56);
// some textured quadrilaterals
GX_End();
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetAlphaUpdate(GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(frameBuffer[fb],GX_TRUE);
GX_SetDrawSync(0);
GX_DrawDone();
/*** this draws the overlay pixels directly on the framebuffer ***/
drawBorderTest(frameBuffer[fb]);
VIDEO_SetNextFramebuffer(frameBuffer[fb]);
VIDEO_Flush();
VIDEO_WaitVSync();
fb ^= 1;
Who is online
Users browsing this forum: No registered users and 0 guests