PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Drawing doesn't work from other functions

I'm trying to get gapidraw to work to use it in my next project, but I've some basic problems that I hope someone can help me with.

I initiate the screen with OpenDisplay and get a backbuffer which I fill with a colored rectangle, then I do a flip and it works great.

But when I try to draw a new rectangle from another function and do a flip nothing happends. What can I be doing wrong?

I declare global classes as follows:
//
class CGapiDisplay* disp = NULL; (define.cpp)
extern class CGapiDisplay* disp; (define.hpp)

Then in my init function InitInstance( ...
//
disp = new CGapiDisplay;
back = new CGapiDisplay;

if( disp->OpenDisplay( GDDISPLAY_FULLSCREEN, main_hWnd, 240, 320, NULL, NULL, NULL, NULL) != GD_OK)
PostQuitMessage(0);

disp->SetDisplayMode(GDDISPMODE_NORMAL);
disp->GetBackBuffer(back);
back->FillRect( NULL, RGB(255, 0, 255), 0, NULL);
disp->Flip();

Which works fine, but then in another function directly after I do the following:

back->FillRect( NULL, RGB(255,255,0), 0, NULL);
disp->Flip();

And nothing happends, what do I do wrong? I probably misseds something basic cause I'm kind of new to working with classes, anyone have an idea?

/nB
The backbuffer should be of type CGapiSurface.. Changing that might work...
I actually had that before but changed back now again but it still doesn't work :(

Funny though is that if I put a PostQuitMessage before my program quits, but the row after nothing happends. Seems like the FillRect does something that make the function just quit, can't even get to save the result it returns to a file :(

I'm lost :?

I didnt mention it but I'm running it in emulator for 2002, but all source examples do just fine there so it shouldn't be that.

/nB
Just wondering... where did u define back?
Same place as disp, I did get it to work now, rewrote everything from start, tends to get a bit messy after a lot of tries. Now it work, not sure why but cause it works I doesn't ask :) I probably must have done some basic error somewhere.

Thanks for the feedback.

/nB