PocketMatrix forums

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

CreateSurface only during CreateSurfaces ?!

The documentation states that the CreateSurface call can only be done in the CreateSurfaces call.
I'm wondering if there isn't a workaround because this would mean that I could never create a surface after the CreateSurfaces call. If I would use for example 10 different surfaces I would have to load them all and maybe some of them I only need for a few minutes in the whole game. How do I tackle this problem. Because when I don't do it this way I get a GDERR_INCOMPATIBLEPRIMARY error.
I was able to create a new surface on the fly without calling it in the "CreateSurfaces" function. It didn't give me any error although I don't know yet if its safe.
It is safe. The recommendation is there mostly since CreateSurfaces() will be called again if either:

(1) The display rotation is changed (SetDisplayMode())
(2) One or more surfaces were lost. This only happens in GapiDraw 1.10beta3 (not released yet), in full screen mode, on stationary PCs.

More documentation related to hardware acceleration & the full screen mode will follow...
If that is the case then I do not understand why I get that error.
I create the surface in the constructor of an object. When I create this object in a processnextframe call or in a createsurfaces call there is no problem but if I do it somewhere else I get the GDERR_INCOMPATIBLEPRIMARY error.
I would guess that the surface gets created before the display is open. You need to open the display to get the GAPI properties first... That's basically the way it works on Pocket PCs...
summer_goth · 21 Mar 2003, 22:26 UTC
What I normally do is create all the surfaces in the "CreateSurfaces" function, even if I would not use them for quite some while after that. I create them as empty, and then later during the run of the program I load in the surface that I wish to use. The memory will be reallocated. This seems to work for me, dont know if it'll help or whether its merely redundant coding.
sbl wrote:
I would guess that the surface gets created before the display is open. You need to open the display to get the GAPI properties first... That's basically the way it works on Pocket PCs...

This was indeed the case. Thank you for the help.