rem This is a simpler version of the rather verbose original spinning cube demo program.
rem In this version we'll depend on various default resources that the engine will now use
rem unless we provide our own.
rem I will also keep the commenting rather light in this version; a more insightful set of
rem comments can be found in the "Spinning Cube (Original)" project.

rem Ensure that DX11Constants.dba is included so that we won't end up with undefined constants
rem defaulting to zero values
INCLUDEGUARD DX11_CONSTANTS

rem Initialize the DX11 plugin; since we don't have any DX11-specific features here we might
rem as well set the feature level to DXVERSION_10_0 in order to support older hardware
dx11 init 1600, 900, false, "DX11 Example: Spinning Cube", DXVERSION_10_0

rem Create cube object
cube = dx11 create object cube(10.0)

rem Unless otherwise specified all objects are positioned at (0, 0, 0) during creation.
rem Place the main camera so that it will see the cube.
dx11 set camera position dx11 get main camera(), 0, 0, -20

rem Create a label for outputting text (we'll update the text in the main loop
rem so no reason to fill it out now)
label = dx11 create label("PLACEHOLDER", 0, 0)

rem Setup high resolution timing variables to maintain smooth and consistent movement over
rem varying frame rates ("timer based movement")
currentTick as double integer = dx11 get high resolution tick()
lastTick    as double integer

rem Main loop
while not dx11 quit()
    rem Update time factor
    lastTick    = currentTick
    currentTick = dx11 get high resolution tick()
    rem This function will return the delta time between the two high resolution tick values expressed in seconds.
    rem As such we can use it as a factor to multiply with all movement and get the result that whatever we multiply with this factor 
    rem will be the movement per second.
    timeFactor# = dx11 get high resolution delta time(lastTick, currentTick)
    
    rem Rotate the cube around its Y-axis by 180 degrees per second
    dx11 apply object angle cube, 0.0, 180.0 * timeFactor#, 0.0
    
    rem Print the current frame rate to our label
    dx11 set label text label, "FPS: " + str$(dx11 get screen fps())
    
    rem Render camera(s) and update engine internals
    dx11 sync
endwhile

rem You can perform any cleanup that you need to do from here.
rem The DX11 engine will be automatically shut down and cleaned up when the plugin is unloaded, which happens when you call
rem END / your program code ends just like usual.
end
