So while working on my game I noticed that I can achieve AA without actually enabling it via the GPU, I am fully aware that this is not true AA, however the method used is similar to what GPUs do(though far slower from my tests).
Basically I am rendering a 2nd camera to a render target plane which the default camera renders. By default this uses the display resolution, which gives the same results(but lower FPS) than without the 2nd camera and rendering it normally. All I then do is multiply the resolution of the camera's image by 2,4 and the GPU down-samples the image resulting in AA. Because the GPU isn't exactly designed for this task, using 2x AA in my example looks better than 4x and 8x didn't even work on my GPU.
This doesn't really have much practical use as enabling it properly(when the d3d device is created) is much faster, and allows you to use 4x,8x,16x etc, however it is a code snippet nonetheless.
#Constant CAM_MAIN 0
#Constant CAM_SCENE 1
// Variables
DisplayX As Dword
DisplayY As Dword
Index As Integer
LimbID As Integer
DLL_User32 As Dword = 1
Elapsed As Float
OldTimer As Dword
RTObjectID As Dword = 2
RTImageID As Dword = 2
RTWidth As Float
RTHeight As Float
RTDepth As Float
PixelWidth As Float
ExampleObjectID As Dword = 1
AAMode As Integer
OldAAMode As Integer
// Set display
Load DLl "user32.dll" , DLL_User32
DisplayX = Call DLL( DLL_User32 , "GetSystemMetrics" , 0 )
DisplayY = Call DLL( DLL_User32 , "GetSystemMetrics" , 1 )
Set Display Mode DisplayX , DisplayY , 32 , 0
// Init DBP
Sync On
Sync Rate 0
Autocam Off
// Make render target object
Make Object Plain RTObjectID , 200.0 , 200.0
Set Object Light RTObjectID , 0
// Cheap hack to find the dimensions >_>
Set Camera Range 0.1 , 20000.0
Pick Screen Screen Width() , 0 , 100.0
RTWidth = Get Pick Vector X()
RTHeight = Get Pick Vector Y()
RTDepth = Get Pick Vector Z()
PixelWidth = Get Pick Vector Y() / ( Screen Height() * 0.5 )
// NOTE: For some reason the RT plane needs to be offset by .5 pixels for each texel to be rendered 100% correctly
Scale Limb RTObjectID , 0 , RTWidth , RTHeight , 100.0
Offset Limb RTObjectID , 0 , -PixelWidth*0.5 , PixelWidth*0.5 , RTDepth
// Make the scene camera
Camera_Setup(CAM_SCENE)
// Assign scene cam to RT object
Set Camera To Image CAM_SCENE , RTImageID , DisplayX , DisplayY
Texture Object RTObjectID , RTImageID
// Make example object
Make Object Box ExampleObjectID , 100.0 , 1.0 , 0.0
Make Mesh From Object ExampleObjectID , ExampleObjectID
For Index = -10 To 10
If Index
Inc LimbID
Add Limb ExampleObjectID , LimbID , ExampleObjectID
Offset Limb ExampleObjectID , LimbID , 0.0 , Index * 5.0 , 0.0
Endif
Next
Delete Mesh ExampleObjectID
Position Object ExampleObjectID , 0.0 , 0.0 , 100.0
// Setup text
Set Text Font "Arial"
Set Text Size 30
Do
// Very basic Timer Based Movement
Elapsed = Timer() - OldTimer
OldTimer = Timer()
// User input
If Spacekey()
Roll Object Right 1 , Elapsed * 0.01
Endif
// Switch AA modes
OldAAMode = AAMode
If Keystate(2) Then AAMode = 0
If Keystate(3) Then AAMode = 1
If Keystate(4) Then AAMode = 2
If AAMode <> OldAAMode
Camera_Setup(CAM_SCENE)
If AAMode
Set Camera To Image CAM_SCENE , RTImageID , DisplayX * ( 2 ^ AAMode ) , DisplayY * ( 2 ^ AAMode )
Else
Set Camera To Image CAM_SCENE , RTImageID , DisplayX , DisplayY
Endif
// Re apply the RT image to the RT object
Texture Object RTObjectID , RTImageID
Endif
// Output
Text 5 , 5 , "FPS: " + Str$( Screen FPS() )
Center Text DisplayX * 0.5 , 5 , "Press 1-3 for AA modes - Spacebar to rotate"
Select AAMode
Case 0
Center Text DisplayX * 0.5 , 30 , "No AA"
EndCase
Case 1
Center Text DisplayX * 0.5 , 30 , "2x AA"
EndCase
Case 2
Center Text DisplayX * 0.5 , 30 , "4x AA"
EndCase
EndSelect
// Show the scene
Exclude Object Off ExampleObjectID
// Hide the RT
Exclude Object On RTObjectID
// Render the scene cam first
Sync Mask 2^CAM_SCENE
FastSync
// Hide the scene
Exclude Object On ExampleObjectID
// Show the RT
Exclude Object Off RTObjectID
// Reposition the RT infront of the camera
Position Object RTObjectID , Camera Position X(CAM_MAIN) , Camera Position Y(CAM_MAIN) , Camera Position Z(CAM_MAIN)
Rotate Object RTObjectID , Camera Angle X(CAM_MAIN) , Camera Angle Y(CAM_MAIN) , Camera Angle Z(CAM_MAIN)
// Render only the main cam
Sync Mask 2^CAM_MAIN
Sync
Loop
Function Camera_Setup( CameraID As Dword )
// Cleanup old camera
If Camera Exist( CameraID )
Delete Camera CameraID
Endif
Make Camera CameraID
Color Backdrop CameraID , 0
Set Camera Range CameraID , 0.1 , 2000.0
EndFunction