|
@@ -27,6 +27,7 @@ Strict
|
|
|
Import brl.map
|
|
|
Import brl.Graphics
|
|
|
Import b3d.OpenB3dLib
|
|
|
+Import brl.standardio
|
|
|
|
|
|
'Import "source.bmx"
|
|
|
|
|
@@ -160,6 +161,7 @@ Extern
|
|
|
Function GetSurfaceBrush_:Byte Ptr( surf:Byte Ptr ) ="GetSurfaceBrush"
|
|
|
Function Graphics3D_( width:Int, height:Int, depth:Int, Mode:Int, rate:Int )="Graphics3D"
|
|
|
Function GraphicsResize_( width:Int, height:Int )="GraphicsResize"
|
|
|
+ Function SetRenderState_( capability:Int, flag:Int ) = "SetRenderState"
|
|
|
Function HandleSprite_( sprite:Byte Ptr, h_x:Float, h_y:Float )="HandleSprite"
|
|
|
Function HideEntity_( ent:Byte Ptr )="HideEntity"
|
|
|
Function LightColor_( light:Byte Ptr, red:Float, green:Float, blue:Float )="LightColor"
|
|
@@ -312,6 +314,11 @@ Global globals:TGlobal=New TGlobal
|
|
|
Public
|
|
|
|
|
|
|
|
|
+' Constants
|
|
|
+' ---------
|
|
|
+
|
|
|
+Const USE_MAX2D:Int=True ' true to enable max2d/minib3d integration
|
|
|
+
|
|
|
|
|
|
' Blitz2D functions
|
|
|
' -----------------
|
|
@@ -353,28 +360,16 @@ Function EndMax2D()
|
|
|
glMatrixMode(GL_COLOR)
|
|
|
glPushMatrix()
|
|
|
|
|
|
- ' Enable States
|
|
|
- glEnable(GL_LIGHTING)
|
|
|
- glEnable(GL_DEPTH_TEST)
|
|
|
- glEnable(GL_FOG)
|
|
|
- glEnable(GL_CULL_FACE)
|
|
|
- glEnable(GL_SCISSOR_TEST)
|
|
|
-
|
|
|
- glEnable(GL_NORMALIZE)
|
|
|
-
|
|
|
- glEnableClientState(GL_VERTEX_ARRAY)
|
|
|
- glEnableClientState(GL_COLOR_ARRAY)
|
|
|
- glEnableClientState(GL_NORMAL_ARRAY)
|
|
|
-
|
|
|
+ TGlobal.EnableStates()
|
|
|
glDisable(GL_TEXTURE_2D)
|
|
|
|
|
|
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
|
|
|
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE)
|
|
|
|
|
|
- glClearDepth(1.0)
|
|
|
+ glClearDepth(1.0)
|
|
|
glDepthFunc(GL_LEQUAL)
|
|
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
|
|
|
-
|
|
|
+
|
|
|
glAlphaFunc(GL_GEQUAL,0.5)
|
|
|
|
|
|
End Function
|
|
@@ -405,6 +400,63 @@ Type TGlobal
|
|
|
Global tex:TTexture=New TTexture
|
|
|
Global voxelspr:TVoxelSprite=New TVoxelSprite
|
|
|
|
|
|
+ Function GraphicsInit()
|
|
|
+
|
|
|
+ TextureFilter("",9)
|
|
|
+?Not linuxarm
|
|
|
+ glewInit() ' required for ARB funcs
|
|
|
+?
|
|
|
+ ' get hardware info and set vbo_enabled accordingly (use THardwareInfo.VBOSupport)
|
|
|
+ THardwareInfo.GetInfo()
|
|
|
+
|
|
|
+ If USE_MAX2D=True
|
|
|
+
|
|
|
+ ' save the Max2D settings for later - by Oddball
|
|
|
+ glPushAttrib(GL_ALL_ATTRIB_BITS)
|
|
|
+ glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS)
|
|
|
+ glMatrixMode(GL_MODELVIEW)
|
|
|
+ glPushMatrix()
|
|
|
+ glMatrixMode(GL_PROJECTION)
|
|
|
+ glPushMatrix()
|
|
|
+ glMatrixMode(GL_TEXTURE)
|
|
|
+ glPushMatrix()
|
|
|
+ glMatrixMode(GL_COLOR)
|
|
|
+ glPushMatrix()
|
|
|
+
|
|
|
+ EndIf
|
|
|
+
|
|
|
+ EnableStates()
|
|
|
+
|
|
|
+ glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
|
|
|
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE)
|
|
|
+
|
|
|
+ glClearDepth(1.0)
|
|
|
+ glDepthFunc(GL_LEQUAL)
|
|
|
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
|
|
|
+
|
|
|
+ glAlphaFunc(GL_GEQUAL,0.5)
|
|
|
+
|
|
|
+ End Function
|
|
|
+
|
|
|
+ Function EnableStates()
|
|
|
+
|
|
|
+ glEnable(GL_LIGHTING)
|
|
|
+ glEnable(GL_DEPTH_TEST)
|
|
|
+ glEnable(GL_FOG)
|
|
|
+ glEnable(GL_CULL_FACE)
|
|
|
+ glEnable(GL_SCISSOR_TEST)
|
|
|
+
|
|
|
+ glEnable(GL_NORMALIZE)
|
|
|
+
|
|
|
+ glEnableClientState(GL_VERTEX_ARRAY)
|
|
|
+ 'glEnableClientState(GL_COLOR_ARRAY)
|
|
|
+ 'glEnableClientState(GL_NORMAL_ARRAY)
|
|
|
+
|
|
|
+ SetRenderState(GL_COLOR_ARRAY,1) ' when drawing with Max2d
|
|
|
+ SetRenderState(GL_NORMAL_ARRAY,1) ' when using flat shading
|
|
|
+
|
|
|
+ End Function
|
|
|
+
|
|
|
End Type
|
|
|
|
|
|
Rem
|
|
@@ -578,6 +630,169 @@ Type TGeosphere Extends TTerrain
|
|
|
|
|
|
End Type
|
|
|
|
|
|
+Rem
|
|
|
+bbdoc: Hardware-info
|
|
|
+about: Contains @{Function GetInfo()} and @{DisplayInfo(LogFile:Int=False)}.
|
|
|
+End Rem
|
|
|
+Type THardwareInfo
|
|
|
+
|
|
|
+ ' by klepto2
|
|
|
+ Global ScreenWidth:Int = DesktopWidth() ' added
|
|
|
+ Global ScreenHeight:Int = DesktopHeight()
|
|
|
+ Global ScreenDepth:Int = DesktopDepth()
|
|
|
+ Global ScreenHertz:Int = DesktopHertz()
|
|
|
+
|
|
|
+ Global Vendor:String
|
|
|
+ Global Renderer:String
|
|
|
+ Global OGLVersion:String
|
|
|
+
|
|
|
+ Global Extensions:String
|
|
|
+ Global VBOSupport:Int ' Vertex Buffer Object
|
|
|
+ Global GLTCSupport:Int ' OpenGL's TextureCompression
|
|
|
+ Global S3TCSupport:Int ' S3's TextureCompression
|
|
|
+ Global AnIsoSupport:Int ' An-Istropic Filtering
|
|
|
+ Global MultiTexSupport:Int ' MultiTexturing
|
|
|
+ Global TexBlendSupport:Int ' TextureBlend
|
|
|
+ Global CubemapSupport:Int ' CubeMapping
|
|
|
+ Global DepthmapSupport:Int ' DepthTexturing
|
|
|
+ Global VPSupport:Int ' VertexProgram (ARBvp1.0)
|
|
|
+ Global FPSupport:Int ' FragmentProgram (ARBfp1.0)
|
|
|
+ Global ShaderSupport:Int ' glSlang Shader Program
|
|
|
+ Global VSSupport:Int ' glSlang VertexShader
|
|
|
+ Global FSSupport:Int ' glSlang FragmentShader
|
|
|
+ Global SLSupport:Int ' OpenGL Shading Language 1.00
|
|
|
+
|
|
|
+ Global MaxTextures:Int
|
|
|
+ Global MaxTexSize:Int
|
|
|
+ Global MaxLights:Int
|
|
|
+
|
|
|
+ Function GetInfo()
|
|
|
+
|
|
|
+ Local Extensions:String
|
|
|
+
|
|
|
+ ' Get HardwareInfo
|
|
|
+ Vendor = String.FromCString(Byte Ptr(glGetString(GL_VENDOR)))
|
|
|
+ Renderer = String.FromCString(Byte Ptr(glGetString(GL_RENDERER)))
|
|
|
+ OGLVersion = String.FromCString(Byte Ptr(glGetString(GL_VERSION)))
|
|
|
+
|
|
|
+ ' Get Extensions
|
|
|
+ Extensions = String.FromCString(Byte Ptr(glGetString(GL_EXTENSIONS)))
|
|
|
+ THardwareInfo.Extensions = Extensions
|
|
|
+
|
|
|
+ ' Check for Extensions
|
|
|
+ THardwareInfo.VBOSupport = Extensions.Find("GL_ARB_vertex_buffer_object") > -1
|
|
|
+ THardwareInfo.GLTCSupport = Extensions.Find("GL_ARB_texture_compression")
|
|
|
+ THardwareInfo.S3TCSupport = Extensions.Find("GL_EXT_texture_compression_s3tc") > -1
|
|
|
+ THardwareInfo.AnIsoSupport = Extensions.Find("GL_EXT_texture_filter_anisotropic")
|
|
|
+ THardwareInfo.MultiTexSupport = Extensions.Find("GL_ARB_multitexture") > -1
|
|
|
+ THardwareInfo.TexBlendSupport = Extensions.Find("GL_EXT_texture_env_combine") > -1
|
|
|
+ If Not THardwareInfo.TexBlendSupport 'SMALLFIXES use the ARB version that works the same
|
|
|
+ THardwareInfo.TexBlendSupport = Extensions.Find("GL_ARB_texture_env_combine") > -1
|
|
|
+ EndIf
|
|
|
+ THardwareInfo.CubemapSupport = Extensions.Find("GL_ARB_texture_cube_map") > -1
|
|
|
+ THardwareInfo.DepthmapSupport = Extensions.Find("GL_ARB_depth_texture") > -1
|
|
|
+ THardwareInfo.VPSupport = Extensions.Find("GL_ARB_vertex_program") > -1
|
|
|
+ THardwareInfo.FPSupport = Extensions.Find("GL_ARB_fragment_program") > -1
|
|
|
+ THardwareInfo.ShaderSupport = Extensions.Find("GL_ARB_shader_objects") > -1
|
|
|
+ THardwareInfo.VSSupport = Extensions.Find("GL_ARB_vertex_shader") > -1
|
|
|
+ THardwareInfo.FSSupport = Extensions.Find("GL_ARB_fragment_shader") > -1
|
|
|
+ THardwareInfo.SLSupport = Extensions.Find("GL_ARB_shading_language_100") > - 1
|
|
|
+
|
|
|
+ If THardwareInfo.VSSupport = False Or THardwareInfo.FSSupport = False
|
|
|
+ THardwareInfo.ShaderSupport = False
|
|
|
+ EndIf
|
|
|
+
|
|
|
+ ' Get some numerics
|
|
|
+ glGetIntegerv(GL_MAX_TEXTURE_UNITS, Varptr(THardwareInfo.MaxTextures))
|
|
|
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, Varptr(THardwareInfo.MaxTexSize))
|
|
|
+ glGetIntegerv(GL_MAX_LIGHTS, Varptr(THardwareInfo.MaxLights))
|
|
|
+
|
|
|
+ End Function
|
|
|
+
|
|
|
+ Function DisplayInfo(LogFile:Int=False)
|
|
|
+
|
|
|
+ Local position:Int, Space:Int, stream:TStream
|
|
|
+
|
|
|
+ If LogFile
|
|
|
+
|
|
|
+ stream = WriteStream("HardwareInfo.txt")
|
|
|
+ stream.WriteLine("Hardwareinfo:")
|
|
|
+ stream.WriteLine("")
|
|
|
+
|
|
|
+ ' Display Desktopinfo
|
|
|
+ stream.WriteLine("Width: "+ScreenWidth)
|
|
|
+ stream.WriteLine("Height: "+ScreenHeight)
|
|
|
+ stream.WriteLine("Depth: "+ScreenDepth)
|
|
|
+ stream.WriteLine("Hertz: "+ScreenHertz)
|
|
|
+ stream.WriteLine("")
|
|
|
+
|
|
|
+ ' Display Driverinfo
|
|
|
+ stream.WriteLine("Vendor: "+Vendor)
|
|
|
+ stream.WriteLine("Renderer: "+Renderer)
|
|
|
+ stream.WriteLine("OpenGL-Version: "+OGLVersion)
|
|
|
+ stream.WriteLine("")
|
|
|
+
|
|
|
+ ' Display Hardwareranges
|
|
|
+ stream.WriteLine("Max Texture Units: "+MaxTextures)
|
|
|
+ stream.WriteLine("Max Texture Size: "+MaxTexSize)
|
|
|
+ stream.WriteLine("Max Lights: "+MaxLights)
|
|
|
+ stream.WriteLine("")
|
|
|
+
|
|
|
+ ' Display OpenGL-Extensions
|
|
|
+ stream.WriteLine("OpenGL Extensions:")
|
|
|
+ While position < Extensions.length
|
|
|
+ Space = Extensions.Find(" ", position)
|
|
|
+ If Space = -1 Then Exit
|
|
|
+ stream.WriteLine(Extensions[position..Space])
|
|
|
+ position = Space+1
|
|
|
+ Wend
|
|
|
+
|
|
|
+ stream.WriteLine("")
|
|
|
+ stream.WriteLine("- Ready -")
|
|
|
+ stream.Close()
|
|
|
+
|
|
|
+ Else
|
|
|
+
|
|
|
+ Print("Hardwareinfo:")
|
|
|
+ Print("")
|
|
|
+
|
|
|
+ ' Display Desktopinfo
|
|
|
+ Print("Width: "+ScreenWidth)
|
|
|
+ Print("Height: "+ScreenHeight)
|
|
|
+ Print("Depth: "+ScreenDepth)
|
|
|
+ Print("Hertz: "+ScreenHertz)
|
|
|
+ Print("")
|
|
|
+
|
|
|
+ ' Display Driverinfo
|
|
|
+ Print("Vendor: "+Vendor)
|
|
|
+ Print("Renderer: "+Renderer)
|
|
|
+ Print("OpenGL-Version: "+OGLVersion)
|
|
|
+ Print("")
|
|
|
+
|
|
|
+ ' Display Hardwareranges
|
|
|
+ Print("Max Texture Units: "+MaxTextures)
|
|
|
+ Print("Max Texture Size: "+MaxTexSize)
|
|
|
+ Print("Max Lights: "+MaxLights)
|
|
|
+ Print("")
|
|
|
+
|
|
|
+ ' Display OpenGL-Extensions
|
|
|
+ Print("OpenGL Extensions:")
|
|
|
+ While position < Extensions.length
|
|
|
+ Space = Extensions.Find(" ", position)
|
|
|
+ If Space = -1 Then Exit
|
|
|
+ Print(Extensions[position..Space])
|
|
|
+ position = Space+1
|
|
|
+ Wend
|
|
|
+
|
|
|
+ Print("")
|
|
|
+ Print("- Ready -")
|
|
|
+
|
|
|
+ EndIf
|
|
|
+
|
|
|
+ End Function
|
|
|
+
|
|
|
+End Type
|
|
|
+
|
|
|
Type TLight Extends TEntity
|
|
|
|
|
|
Method NewLight:TLight( inst:Byte Ptr )
|