|
width (optional) - width of the screen resolution; defaults to the current desktop width height (optional) - height of the screen resolution; defaults to the current desktop height depth (optional) - colour depth in bits, kept for compatibility; 0 lets the engine choose (default). The modern runtime always renders 32-bit mode (optional) - mode of display 0: windowed (if possible) in debug mode, fullscreen in non-debug mode (default) 1: fullscreen always 2: windowed always 3: windowed always, as 2 (classic Blitz3D scaled this window) 6: as 2 (classic Blitz3D also paused while the window was inactive) 7: as 3 (classic Blitz3D also paused while the window was inactive) |
|
Sets 3D graphics mode. This command must be executed before any other 3D command, otherwise programs will return an error. If width and height are omitted, Graphics3D uses the current desktop dimensions. Use DesktopWidth and DesktopHeight to query those values directly. Width and height set the resolution of the screen or window. In fullscreen modes the resolution must be one the graphics card and monitor support - check with GfxModeExists rather than hard-coding an exotic size. Classic values are 640,480 and 800,600; modern desktop sizes such as 1920,1080 work too. Depth is kept for compatibility: the modern runtime always renders in 32-bit colour, whatever you pass, and GraphicsDepth reports the value you asked for, or 32 if you passed 0. Modes 3, 6 and 7 exist for compatibility too. Classic Blitz3D stretched mode 3's drawing to fit a resizable window, and paused modes 6 and 7 while their window was inactive. On Windows and macOS, Blitz3D+ opens the same window for all of them as for mode 2. In the online IDE a mode 3 or 7 program's window can be resized, and the picture is scaled to fit it. Use plain Graphics instead for 2D-only programs, and EndGraphics to close the display down. See also: Graphics, EndGraphics, GfxModeExists, Windowed3D. |
; Graphics3D Example
; ------------------
; Graphics3D width,height,depth,mode sets up 3D graphics.
; Depth 0 picks the best colour depth; mode 2 always opens a window.
Graphics3D 640,480,0,2
; Draw to the back buffer; Flip then shows each finished frame
SetBuffer BackBuffer()
; Every 3D scene needs a camera...
camera=CreateCamera()
PositionEntity camera,0,1,-5
; ...and a light, or everything appears flat
light=CreateLight()
RotateEntity light,45,45,0
; A spinning cone so there is something to see
cone=CreateCone(16)
PositionEntity cone,0,1,0
EntityColor cone,255,100,0
; The classic Blitz3D main loop
While Not KeyDown(1)
TurnEntity cone,0,1,0
; Arrow keys move the camera
If KeyDown(200) Then MoveEntity camera,0,0,0.1
If KeyDown(208) Then MoveEntity camera,0,0,-0.1
If KeyDown(203) Then TurnEntity camera,0,1,0
If KeyDown(205) Then TurnEntity camera,0,-1,0
RenderWorld
Text 0,0,"Arrow keys: move camera Esc: exit"
Text 0,20,"Graphics3D 640,480,0,2 - windowed 640x480 3D display"
Flip
Wend
End