The program doesn't crash any more when you change video modes, but there's a couple new problems.
I have updated this test program. It starts up in fullscreem and from there you can hit F to toggle back and forth from fullscreen to windowed mode.
In DirectX, you can switch back to canvas, and from there back to fullscreen. But when I switch back to canvas again, I have all these black horizontal lines on the canvas, and everything slows to a crawl.
In OpenGL, which used to work fine, you can switch from fullscreen to windowed mode, and back, but when you go into fullscreen mode the second time, it now shows a flashing start bar at the bottom of the screen, as if you forgot to clear both buffers.
I have a Geforce 6800.
'SetGraphicsDriver GLMax2DDriver() Global App:Application = Application.Create("Fruit Sliders", 800, 600, 0, True) Image:TImage = CreateImage(32, 32) DrawImage(Image, 0, 0) Repeat If KeyHit(KEY_F) App.ToggleFullscreen() DebugLog("State : " + App.Windowed) EndIf Flip True Until KeyHit(KEY_ESCAPE) Type Application Field Name$ Field Width% Field Height% Field Depth% Field Window:TGadget Field Canvas:TGadget Field Panel:TGadget Field TG:TGraphics Field Windowed% ' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This function creates the game window, and sets up the graphics objects for windowed and fullscreen modes. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Function Create:Application(AppName$, AppWidth%, AppHeight%, AppDepth%=0, Fullscreen%=False) Local X%, Y% Local App:Application ' Create new application. App = New Application ' Store application settings. App.Name$ = AppName$ App.Width = AppWidth App.Height = AppHeight App.Depth = AppDepth ' If Depth is 0, try to find a suitable fullscreen bit depth. If App.Depth = 0 App.Depth = 16 If GraphicsModeExists(App.Width, App.Height, 24) Then App.Depth = 24 If GraphicsModeExists(App.Width, App.Height, 32) Then App.Depth = 32 EndIf ' Create a window in the center of the screen. X = GadgetWidth(Desktop())/2 - App.Width/2 Y = GadgetHeight(Desktop())/2 - App.Height/2 App.Window = CreateWindow(App.Name$, X, Y, App.Width, App.Height, Null, WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_CLIENTCOORDS|WINDOW_HIDDEN) SetMinWindowSize(App.Window, GadgetWidth(App.Window), GadgetHeight(App.Window)) ' Create a panel in the window, drawn behind the canvas, which fills the empty space around the gameplay area when the window is maximized. App.Panel = CreatePanel(0, 0, App.Width, App.Height, App.Window) SetPanelColor(App.Panel, 0, 0, 0) SetGadgetLayout(App.Panel, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED) ' Create a canvas. App.Canvas = CreateCanvas(ClientWidth(App.Window)/2-App.Width/2, ClientHeight(App.Window)/2-App.Height/2, App.Width, App.Height, App.Panel) ' Set game to windowed or fullscreen as desired. Select Fullscreen Case False App.SetWindowed() Case True App.SetFullscreen() End Select ' Return new application instance. Return App End Function ' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This method toggles between fullscreen or windowed mode, choosing the opposite of whichever is currently enabled. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Method ToggleFullscreen() Select Windowed Case False SetWindowed() Case True SetFullscreen() End Select End Method ' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This method puts the application in windowed mode. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Method SetWindowed() ' Set drawing operations to go to canvas. EndGraphics SetGraphics CanvasGraphics(Canvas) Windowed = True ShowGadget Window ActivateGadget Canvas ' Canvas must be activated for input or else game will make user click on canvas before any polled keyboard input is returned. EnablePolledInput() End Method ' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This method sets the application to fullscreen mode, unless no fullscreen mode in the desired resolution exists. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Method SetFullscreen() Local G:TGraphics ' Set drawing operations to fullscreen. HideGadget Window G = Graphics(Width, Height, Depth) Windowed = False ' If the operation fails, put us back in windowed mode. Otherwise, hide the window, and record that fullscreen is enabled. If G = Null Then SetWindowed() End Method End Type ' ----------------------------------------------------------------------------------------------------------------------------------------------------------- ' This function overrides the standard RuntimeError function which does not work properly. Assert also does not work. ' ----------------------------------------------------------------------------------------------------------------------------------------------------------- Function RuntimeError(Error$) EndGraphics Notify(Error$, True) End End Function
I have updated this test program. It starts up in fullscreem and from there you can hit F to toggle back and forth from fullscreen to windowed mode.
In DirectX, you can switch back to canvas, and from there back to fullscreen. But when I switch back to canvas again, I have all these black horizontal lines on the canvas, and everything slows to a crawl.
In OpenGL, which used to work fine, you can switch from fullscreen to windowed mode, and back, but when you go into fullscreen mode the second time, it now shows a flashing start bar at the bottom of the screen, as if you forgot to clear both buffers.
I have a Geforce 6800.