This might help
#Constant Enable 1
#Constant Disable 0
#Constant True -1
#Constant False 0
#Constant KEY_ESCAPE 27
#Constant KEY_SPACE 32
SetWindowSize( 1920, 1080, Disable, Enable )
SetVirtualResolution( 480, 270 )
SetScissor( Disable, Disable, Disable, Disable )
UseNewDefaultFonts( Enable )
SetSyncRate( 30, Enable )
SetWindowAllowResize( Enable )
SetWindowTitle( "Benchmark" )
Global Box As Integer : Box = CreateObjectBox( 10.0, 10.0, 10.0 )
Type Vector
X As Float
Y As Float
Z As Float
W As Float
EndType
Function Vector( X As Float, Y As Float, Z As Float, W As Float )
Local Output As Vector
Output.X = X
Output.Y = Y
Output.Z = Z
Output.W = W
EndFunction Output
Global BoxAngle As Vector : BoxAngle = Vector( 0.0, 0.0, 0.0, 0.0 )
Type Resolution
Width As Float
Height As Float
EndType
Function Resolution( Width As Float, Height As Float )
Local Output As Resolution
Output.Width = Width
Output.Height = Height
EndFunction Output
Global Window As Resolution : Window = Resolution( GetWindowWidth(), GetWindowHeight() )
Global Virtual As Resolution : Virtual = Resolution( GetVirtualWidth(), GetVirtualHeight() )
Global Scale As Resolution : Scale = Resolution( Virtual.Width / Window.Width, Virtual.Height / Window.Height )
Global UseOffscreen As Integer : UseOffscreen = False
Global RenderQuad As Integer : RenderQuad = CreateObjectQuad() : SetObjectVisible( RenderQuad, Disable )
#Constant FRONTBUFFER 0
#Constant BACKBUFFER 1
#Constant ZBUFFER 2
#Constant RENDERIMAGE_COLOR 0
#Constant RENDERIMAGE_DEPTH 1
Global RenderCache As Integer[] : UpdateRenderBuffers( RenderCache )
RunApplication()
End
Function RunApplication( )
Local Running As Integer
Repeat
Running = Main( )
Until Running = False
EndFunction
Function Main( )
// Quit App if the EscapeKey Pressed
If GetRawKeyPressed( KEY_ESCAPE ) Then ExitFunction False
If GetRawKeyPressed( KEY_SPACE ) Then UseOffscreen = Not( UseOffScreen )
// Handle Resolution Changing
If Window.Width <> GetWindowWidth() Or Window.Height <> GetWindowHeight()
Window = Resolution( GetWindowWidth(), GetWindowHeight() )
Virtual = Resolution( Window.Width * Scale.Width, Window.Height * Scale.Height )
SetVirtualResolution( Virtual.Width, Virtual.Height )
UpdateDeviceSize( Window.Width, Window.Height )
If UseOffscreen Then UpdateRenderBuffers( RenderCache ) // Let's only update this IF we're Rendering Offscreen
EndIf
BoxAngle = Vector( BoxAngle.X + 0.6, BoxAngle.Y + 0.4, BoxAngle.Z + 0.1, 0.0 )
SetObjectRotation( Box, WrapValue( BoxAngle.X, 360.0 ), WrapValue( BoxAngle.Y, 360.0 ), WrapValue( BoxAngle.Z, 360.0 ) )
If UseOffscreen
SetRenderToImage( RenderCache[BACKBUFFER], RenderCache[ZBUFFER] )
ClearScreen()
Update(0) // If we have any physics, tweens, etc. we'd need this
// Perform Draw and Print Operations Here
Print( Str( Window.Width ) + "x" + Str( Window.Height ) )
Print( Str( Virtual.Width ) + "x" + Str( Virtual.Height ) )
Print( "Using Offscreen Render Method" )
//
Render() // Renders Object, Sprites and Text
SetRenderToScreen( )
SetObjectVisible( RenderQuad, Enable )
SetObjectImage( RenderQuad, RenderCache[BACKBUFFER], 0 )
DrawObject( RenderQuad )
Swap()
SetObjectVisible( RenderQuad, Disable )
Else
Print( Str( Window.Width ) + "x" + Str( Window.Height ) )
Print( Str( Virtual.Width ) + "x" + Str( Virtual.Height ) )
Print( "Using Normal Rendering Method" )
Sync()
EndIf
EndFunction True
Function WrapValue( Value As Float, MaxValue As Float )
Value = Value / MaxValue
Value = MaxValue * ( Value - Trunc( Value ) )
EndFunction Value
Function UpdateRenderBuffers( BufferCache Ref As Integer[] )
// If our Buffer is full, Dispose of everything
If BufferCache.Length <> -1
For I = 0 To BufferCache.Length
// Delete any existing RenderImages
If BufferCache[I] Then DeleteImage( BufferCache[i] )
Next
// Empty Cache
BufferCache.Length = -1
EndIf
For I = 0 To 1
BufferCache.Insert( CreateRenderImage( GetVirtualWidth(), GetVirtualHeight(), RENDERIMAGE_COLOR, Disable ) )
Next
BufferCache.Insert( CreateRenderImage( GetVirtualWidth(), GetVirtualHeight(), RENDERIMAGE_DEPTH, Disable ) )
For I = 0 To 2
SetImageMinFilter( BufferCache[I], Disable )
SetImageMagFilter( BufferCache[I], Disable )
Next
EndFunction
