PocketMatrix forums

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

How to use CGapiSurface pointer out side ProcessNextFrame ?

Hello every one. I have to draw balls on surface, but there is no function for circle or ellipse. Do I have to draw the balls via SetPixel or there is any other alternative?. Also when once application starts, and ProcessNextFrame is Called, can I call some other function within ProcessNextFrame who has its own CGapiSurface pointer for e.g if I try to call my own function then ...

virtual HRESULT ProcessNextFrame(CGapiSurface* pBackbuffer, DWORD dwFlags)
{
...
circle(int x,int y, int radious);
...
}


circle(int x,int y,int radious)
{
CGapiSurface* MYBACKBUFFER; //here Run time error
MYBACKBUFFER->SetPixel(10,10,RBG(255,255,255);
...
}

Athough there is no compile time error, but Run time error occurs and application terminates. And also let me know of the overhead if i try to create circle via SetPixel() . And what about importing a *.png file. can some one plz give me a complete example about importing an image ???
Pejo Software - Per · 17 Oct 2004, 17:04 UTC
Suggestion/question:
Why don't you have your balls..... as images(png, bmp) instead?

And your run time error: Have you initialized the surface?
Instead of circle(x,y,rad) why not do:

Code:

circle(int x, int y, int radius, CGapiSurface* pBackBuffer)
{
...
}


and call it like this:

Code:

virtual HRESULT ProcessNextFrame(CGapiSurface* pBackbuffer, DWORD dwFlags)
{
...
circle(x, y, radius, pBackBuffer);
...
}
What mitch said would be a good solution,

Remember that ProcessNextFrame just acts as you main loop for the game, so you can call anything you like out of it.

Where you wrote

CGapiSurface* MYBACKBUFFER; //here Run time error

Think about what you did, all that is created here is a pointer that dosnt point to anything.