[futurebasic] Memory and gWorlds

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 1998 : Group Archive : Group : All Groups

From: "Yates, Phil" <YATESP@...>
Date: Tue, 28 Apr 98 09:04:00 PDT
Bill Michael wrote :

> Right out of your program's partition. This is why it's so critical 
to > either have _lots_ of room, or limit the color depth of your gWorlds. A 
> program that runs fine on a 256-color monitor will quickly run out of 
> memory if it's run in "millions" of colors, if the gWorlds are 
> "defaulting" to the system color depth.

I had a problem whereby I wanted to create the largest possible gWorld to 
hold an offscreen map of something like 4000 x 4000 pixels. I eventually 
ended up by allocating the program something like 30Megs to run in. Once I 
had done this, I was able to check the free memory available within my 
partition at runtime, and then set the gWorld to match after I'd checked the 
colour depth in use.

If it's of any use to anyone this is the function I use :
'
'                                                                            
'                Get GWorld Co-ords                                          
'                                                                            
'
CLEAR LOCAL
DIM Twelfth!,Sqrt!
LOCAL FN GetGWorldSize
  gAvailMem& = MEM(-1)
  gContingency! = gAvailMem& / 20
  gAvailMem& =  gAvailMem& - gContingency!)
  Twelfth! = gAvailMem& / 12
  Sqrt! = SQR(Twelfth!)
  gGWorldX! = INT(Sqrt! * 4):'Sets 4 x 3 aspect ratio to match the screen
  gGWorldY! = INT(Sqrt! * 3)
  LONG IF SYSTEM(_crntDepth) > 8:'allow for 32K colours
    gGWorldX! = gGWorldX! / 2
    gGWorldY! = gGWorldY! / 2
  END IF
  IF gGWorldX! > 4000 THEN gGWorldX! = 4000
  IF gGWorldY! > 4000 THEN gGWorldY! = 4000
END FN
'                                                                            
PMY