I'm having a problem getting my app to work in both fullscreen and windowed mode. The code fails on the CreateGraphics line. I tried setting the Hertz to 0 at first, but that failed, so I tried 60 which I know should work and that also failed.
Any ideas?
It fails on this line in Create():
App.GRAPHICS_Fullscreen = CreateGraphics(App.Width, App.Height, App.Depth, 60, GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER)
Any ideas?
'Global App:Application = Application.Create("Fruit Sliders", 800, 600) Type Application Field Name$ Field Width% Field Height% Field Depth% Field Window:TGadget Field Canvas:TGadget Field Panel:TGadget Field GRAPHICS_Window:TGraphics Field GRAPHICS_Fullscreen: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, App.Width, App.Height) ' Create a canvas in the window to draw graphics to. App.Canvas = CreateCanvas(0, 0, App.Width, App.Height, 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 fullscreen graphics object, and save canvas graphics object for later. App.GRAPHICS_Fullscreen = CreateGraphics(App.Width, App.Height, App.Depth, 60, GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER) App.GRAPHICS_Window = CanvasGraphics(App.Canvas) ' Set game to windowed or fullscreen as desired. Select Fullscreen Case False App.SetWindowed() Case True App.SetFullscreen() End Select End Function ' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This method puts the application in windowed mode. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Method SetWindowed() SetGraphics GRAPHICS_Window ShowGadget Window Windowed = True End Method ' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This method sets the application to fullscreen mode, unless no fullscreen mode in the desired resolution exists. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Method SetFullscreen() If GRAPHICS_Fullscreen = Null SetWindowed() Return Else HideGadget Window SetGraphics GRAPHICS_Fullscreen Windowed = False EndIf End Method End Type
It fails on this line in Create():
App.GRAPHICS_Fullscreen = CreateGraphics(App.Width, App.Height, App.Depth, 60, GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER)