Could someone plz give me an example (main loop) for mixing Iw2D and IwUI ?
Right now i use the following:
//... initializations
while(1)
{
s3eDeviceYield(0);
s3eKeyboardUpdate();
s3ePointerUpdate();
IwGetUIController()->Update();
IwGetUIView()->Update(1000/20);
// ... do my logic
// Rendering
IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
// do my Iw2D drawings ...
Iw2DSurfaceShow();
}












Hi,
A simplified version of my main loop looks something like this:
NOTE: I used callbacks, set via s3eDeviceRegister() to get keyboard/mouse/touch input.
while( !s3eDeviceCheckQuitRequest() )
{
IwGetUIController()->Update(); // process/handle UI related input
// handle any non-UI related input (using input obtained via callbacks)
// update game logic
Iw2DSurfaceClear( … ); // NOTE: When using Iw2D, should clear the screen like this
// Render Iw2D & IwGx graphics
IwGetUIView()->Update( … ); // update UI view & animation
IwGetUIView()->Render(); // render the UI
Iw2DSurfaceShow(); // NOTE: When using Iw2D, should present the screen like this
s3eDeviceYield(); // Callbacks called during yield if/when needed
}
Hope this helps,
-David
don't forget Iw2DFinishDrawing() to guarantee the drawing order (z-buffer)! (usually, you render the UI after drawing with iw2d)
Thx for the answers. It looks like that *any* combination will work, so i am looking for the *right* *optimal* way. This is now how i do it:
while(!s3eDeviceCheckQuitRequest())
{
s3eDeviceYield(0);
s3eKeyboardUpdate();
s3ePointerUpdate();
IwGetUIController()->Update();
IwGetUIView()->Update(1000/20); // 1000/20 = 20fps
IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
IwGxSetScissorScreenSpace(VIEW::SCR_X, VIEW::SCR_Y, VIEW::SCR_W, VIEW::SCR_H);
g_game->Draw(); // my 2D drawings ...
Iw2DFinishDrawing();
IwGxClearScissorScreenSpace();
IwGetUIView()->Render();
IwGxFlush();
IwGxSwapBuffers();
}
Hi,
When using Iw2D, you should use Iw2DSurfaceShow(), not IwGxSwapBuffers()
From the docs:
"void Iw2DSurfaceShow()
Finish any pending drawing and present the surface. The default surface must be the current drawing surface. This function must be called instead of other Show() functions like s3eSurfaceShow() and IwGxSwapBuffers()."
-David