Graphics width,height[,depth][,mode]
Parameters
|
width - width of the display in pixels, e.g. 640, 1280, 1920 height - height of the display in pixels, e.g. 480, 720, 1080 depth (optional) - colour depth in bits; 0 lets the engine choose (default). The modern runtime always renders 32-bit mode (optional) - how the display is presented: 0: auto - windowed in debug mode, fullscreen otherwise (default) 1: fullscreen 2: windowed 3: windowed, scaled - the view stretches to fit the window 6: as 2, with classic Blitz3D's pause-when-inactive flag 7: as 3, with classic Blitz3D's pause-when-inactive flag |
Description
|
Opens a graphics display for 2D drawing. This is normally the first real line of a 2D program: it creates the game's display at the size you ask for, and must run before any drawing or image commands. For 3D games use Graphics3D instead - it opens the display and the 3D engine together. Mode 0 is a developer-friendly default: while you work in debug mode you get a window, and players get fullscreen. During development modes 2 or 3 are handy to force a window; for release, check fullscreen sizes with GfxModeExists first, since not every monitor accepts every resolution. Modes 6 and 7 exist for compatibility - the modern runtime treats them like 2 and 3. Any other value raises a runtime error. Calling Graphics again switches to the new settings, but it rebuilds the display: all loaded images are freed (their handles become invalid - reload them), the drawing colour resets to white, the cls colour to black, the font to the default, and the draw target becomes the front buffer. Most games follow Graphics with SetBuffer BackBuffer() to set up the usual draw-then-Flip loop. See also: Graphics3D, EndGraphics, GfxModeExists, SetBuffer, Flip. |
Example
; Graphics Example ; ---------------- ; Graphics opens the display: width,height,depth,mode. ; Depth 0 lets Blitz choose; mode 2 = windowed. Graphics 640,480,0,2 ; Draw to the back buffer and Flip each finished frame SetBuffer BackBuffer() x#=0 While Not KeyDown(1) Cls ; A drifting box shows the display is live x=x+3 If x>640 Then x=-40 Color 255,150,0 Rect x,220,40,40,1 Color 255,255,255 Text 0,0,"Esc: exit" Text 0,20,"Graphics 640,480,0,2 opened a "+GraphicsWidth()+" x "+GraphicsHeight()+" display at "+GraphicsDepth()+" bit" Flip Wend End
Index