PocketMatrix forums

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

Allocate and deallocate Surfaces

Twelvegames · 10 Sep 2003, 13:27 UTC
HI,
WIch is the best method to allocate an array of CGapiSurfaces, and after deallocate them?

Suppose to have an Array[n] of Surfaces.
First i fill this array with valid bitmap files.
What i should do when i want to clean up this Array?

(I mean deallocate them)
Twelvegames · 10 Sep 2003, 14:23 UTC
I found this tips on the documentation:
"If you manually want to free all data allocated by a surface you can call CGapiSurface::CreateSurface(0, 0, 0)."

so i made:
Code:
HRESULT Brazilian::DestroyButton(int ID)
{
BUTTONS[ID].ButtonSurface->CreateSurface(NULL,NULL,NULL);
BUTTONS[ID].x=0;
BUTTONS[ID].y=0;
BUTTONS[ID].right=0;
BUTTONS[ID].bottom=0;
BUTTONS[ID].pressed=false;
//BUTTONS[ID].FX.dwFXcolor1=RGB(255, 255, 255);
return S_OK;
}


But i have this error, why?

D:\PROGETTI\TWELVE\CAPOEIRA II\bRaZiLiAn\common\Brazilian.cpp(303) : error C2668: 'CreateSurface' : ambiguous call to overloaded function
Neither me nor your compiler can figure out which version of CreateSurface you are trying to call here so I would suggest to use something more explicit like:

CreateSurface(0,(int)0,(int)0);


PS.
I don't have GapiDraw docs in front of me so the above example is just that - an example.
The point is that you need to tell compiler what kind of arguments are you trying to pass - NULL is sort of like 'void' :-)
CreateSurface (0,0,0) should work...
Johan wrote: CreateSurface (0,0,0) should work...

It never does for me either. I use: CreateSurface(0,(DWORD)0,0);

--Eric
Odd, I thought NULL was basically

#define NULL 0

so you would not need a basic type.
Yeah, and that is why his compiler was confused ...
There is no way to figure out if the value was meant to be pointer style NULL or just int that happened to be 0.
Ok, thanks for the feedback. I'm back from Italy, and since 2.05 is delayed I guess I can add a Free() before it's up on the web...
Johan wrote:Ok, thanks for the feedback. I'm back from Italy, and since 2.05 is delayed I guess I can add a Free() before it's up on the web...

Joy! My code will be cleaner! ;) Thanks Johan!

--Eric