Change Graphics During RunTime (source code )

Blitz3D Forums/Blitz3D Programming/Change Graphics During RunTime (source code )

Stickman(Posted 2003) [#1]
I know I have seen this topic up on the forums before and heres one way of getting it done.

I had posted a code simaler to this in Genral descussion to see if doing things this way is Ok and so far it seems so.

Gona put it in Code archives for others to use but figured Id put it here first to see if anybody finds somthing wrong with it first.


Const Init=1
Const start=2
Const Run=3
Const Restart=4
Const Close=5

Global winX,winY,WinD,WinM

State=init

While Not State=Close

 Select State

 Case Init

  WinX=640
  WinY=480
  WinD=16
  WinM=2
 
  State=start

 Case start

  Graphics winX,winY,WinD,WinM
  Img=CreateImage(256,256)
   SetBuffer ImageBuffer( Img )
    Color 255,128,64
    Rect 0,0,256,256,1
    Color 255,255,0
    Oval 128,128,128,128,0
   SetBuffer BackBuffer()
  
   state=Run

  Case Run

   Cls 
    If KeyHit(1) state=Close
    If KeyHit(57) state=Restart
    DrawImage Img,0,0
    Text 280,200,"To Change Graphics Press SpaceBar"
    Text 280,240," Curent Setting : "+Winx+","+Winy+","+Wind+","+Winm
    Text 280,280," Press ESC to EXIT "
    If state=restart
     Color 255,0,0
     Text 280,100," 1=640,480,16,2 "
     Text 280,120," 2=800,600,32,1 "
    End If 
   Flip    

  Case Restart

    ClearWorld 
    Color 255,255,255
    Locate 280,160
    NewG=Input( "change graphics to 1 or 2 " )

    If NewG=1 
       WinX=640
       WinY=480
       WinD=16
       WinM=2
    Else If NewG=2
       WinX=800
       WinY=600
       WinD=32
       WinM=1
    End If 
    state=start

  Case Close
       ClearWorld()
  Default
       End
 End Select 

Wend
End 




Jim Teeuwen(Posted 2003) [#2]
soo yer basicly sdoing what a program restart will do as well. re-issue the Graphics() command after changing the res. It might work fine here, but I dont really see the improovement over shuttin down/restarting the app.. you stil have to reload all the graphics and such.