|
|
| (5 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| [[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}} | | [[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}} |
|
| |
|
| = Spring = | | <span class="warning">These functions are ONLY available if the graphic board supports GLSL.<br><br> Please test in your scripts if one of them exists before you use them!</span> |
|
| |
|
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = GetSun
| |
| |arg1 =
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|number}} sunPosX, {{type|number}} sunPosY, {{type|number}} sunPosZ
| |
| |info =
| |
| }}
| |
|
| |
|
| or
| | '''gl.CreateShader''' |
| | ({[ vertex = "glsl code" ,] |
| | [ tcs = "glsl code" ,] |
| | [ tes = "glsl code" ,] |
| | [ geometry = "glsl code" ,] |
| | [ fragment = "glsl code" ,] |
| | [ uniform = { uniformName = number value, ...} ,] <span class=note>(specify a Lua array as an argument to uniformName to initialize GLSL arrays)</span> |
| | [ uniformInt = { uniformName = number value, ...} ,] <span class=note>(specify a Lua array as an argument to uniformName to initialize GLSL arrays)</span> |
| | [ uniformFloat = { uniformName = number value, ...} ,] <span class=note>(specify a Lua array as an argument to uniformName to initialize GLSL arrays)</span> |
| | [ uniformMatrix = { uniformName = number value, ...} ,] |
| | [ geoInputType = number inType,] |
| | [ geoOutputType = number outType,] |
| | [ geoOutputVerts = number maxVerts,] |
| | [ definitions = "string of shader #defines", ] |
| | }) -> number shaderID |
|
| |
|
| {{LuaCallout
| | * The "Vertex" or vertex-shader is your GLSL-Code as string, its written in a C-Dialect. This shader is busy deforming the geometry of a unit but it can not create new polygons. Use it for waves, wobbling surfaces etc. |
| |prefix = gl.
| | |
| |name = GetSun
| | * The "Geometry" or Geometry-shader can create new vertices and vertice-stripes from points. |
| |arg1 = {{type|string}} "pos"
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|number}} sunPosX, {{type|number}} sunPosY, {{type|number}} sunPosZ
| |
| |info =
| |
| }}
| |
|
| |
|
| or | | * The "TCS" or Tesselation Control Shader controls how much tessellation a particular patch gets; it also defines the size of a patch, thus allowing it to augment data. It can also filter vertex data taken from the vertex shader. The main purpose of the TCS is to feed the tessellation levels to the Tessellation primitive generator stage, as well as to feed patch data (as its output values) to the Tessellation Evaluation Shader stage. TCS shader can be used with spring version >= 104.0.1-596 (maintenance), it's also available in develop branch of spring. |
|
| |
|
| {{LuaCallout
| | * The "TES" or Tesselation Evaluation Shader takes the abstract patch generated by the tessellation primitive generation stage, as well as the actual vertex data for the entire patch, and generates a particular vertex from it. Each TES invocation generates a single vertex. It can also take per-patch data provided by the Tessellation Control Shader. TES shader can be used with spring version >= 104.0.1-596 (maintenance), it's also available in develop branch of spring. |
| |prefix = gl.
| |
| |name = GetSun
| |
| |arg1 = {{type|string}} "shadowDensity" {{bracket}}
| |
| |arg2 = {{type|string}} "unit" {{rbracket}}
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|number}} shadowDensity
| |
| |info =
| |
| }}
| |
|
| |
|
| or | | * The "Fragment" or Fragment-shader (sometimes called pixel-Shader) is post processing the allready rendered picture (for example drawing stars on the sky)- remember textures are not always 2 dimensional pictures. They can contain information about the depth, or the third value marks areas and the strength at which these are processed. |
|
| |
|
| {{LuaCallout
| | * The Uniforms are the values, you send along with the shader-program. To use them in the shader-program declare them like this: |
| |prefix = gl.
| | <syntaxhighlight lang="c">uniform float frame;</syntaxhighlight> |
| |name = GetSun
| |
| |arg1 = {{type|string}} "diffuse" {{bracket}}
| |
| |arg2 = {{type|string}} "unit" {{rbracket}}
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}} {{pipe}} {{type|number}} r, {{type|number}} g, {{type|number}} b
| |
| |info =
| |
| }}
| |
|
| |
|
| or
| | * From 101.0 onwards, the engine will automatically fill in an appropriately named uniform for team colour if it is declared; |
| | <syntaxhighlight lang="c">uniform vec4 teamColor;</syntaxhighlight> |
|
| |
|
| {{LuaCallout
| | '''gl.DeleteShader''' |
| |prefix = gl.
| | ( number shaderID ) -> nil |
| |name = GetSun
| |
| |arg1 = {{type|string}} "ambient" {{bracket}}
| |
| |arg2 = {{type|string}} "unit" {{rbracket}}
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}} {{pipe}} {{type|number}} r, {{type|number}} g, {{type|number}} b
| |
| |info =
| |
| }}
| |
|
| |
|
| or
| | '''gl.ActiveShader''' <font color="#55ee99">can be used in NON-drawing events (to update uniforms etc.)!</font> |
| | ( number shaderID, function [, arg1 [, arg2, ..]] ) -> nil |
|
| |
|
| {{LuaCallout
| | '''gl.UseShader''' |
| |prefix = gl.
| | ( number shaderID ) -> boolean linked |
| |name = GetSun
| |
| |arg1 = {{type|string}} "specular" {{bracket}}
| |
| |arg2 = {{type|string}} "unit" {{rbracket}}
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}} {{pipe}} {{type|number}} r, {{type|number}} g, {{type|number}} b
| |
| |info =
| |
| }}
| |
|
| |
|
| | '''gl.GetShaderLog''' |
| | ( ) -> string "infoLog" |
|
| |
|
| | '''gl.SetShaderParameter''' |
| | <font color="#ff0000">Renamed to SetGeometryShaderParameter in spring version >= 104.0.1-596 (maintenance).</font> |
| | <font color="#55ee99">needed by geometry shader programs (check the opengl GL_ARB_geometry_shader4 extension for glProgramParameteri)</font> |
| | ( number shaderID, number param, number value ) -> nil |
|
| |
|
| {{LuaCallout
| | '''gl.SetTesselationShaderParameter''' |
| |prefix = gl.
| | <font color="#0000ee">Available for spring versions >= 104.0.1-596 (maintenance).</font> |
| |name = GetAtmosphere
| | <font color="#55ee99">needed by tesselation shader programs (check the opengl GL_ARB_tessellation_shader extension for glProgramParameteri)</font> |
| |arg1 = {{type|string}} name
| | ( number param, number value ) -> nil |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|number}} r, {{type|number}} g, {{type|number}} b
| |
| |info = {{new|101.0}}<br>See [[Lua_UnsyncedCtrl#Sun|Spring.SetAtmosphere]] for details.
| |
| }}
| |
|
| |
|
| | | '''gl.GetActiveUniforms''' |
| {{LuaCallout
| | ( number shaderID ) -> { |
| |prefix = gl.
| | [1] = { name = "name", type = "type", length = number length, size = number size }, |
| |name = GetWaterRendering
| | ... |
| |arg1 = {{type|string}} name
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}} {{pipe}} {{type|number}} r, {{type|number}} g, {{type|number}} b {{pipe}} {{type|string}} texName {{pipe}} {{type|bool}} active
| |
| |info = {{new|104.0}}<br>See [[Lua_UnsyncedCtrl#Developers|Spring.SetWaterParams]] for details.
| |
| }}
| |
| | |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = GetMapRendering
| |
| |arg1 = {{type|string}} name
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}} {{pipe}} {{type|number}} r, {{type|number}} g, {{type|number}} b {{pipe}} {{type|bool}} active
| |
| |info = {{new|104.0}}<br>See [[Lua_UnsyncedCtrl#Developers|Spring.SetMapRenderingParams]] for details.
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = ConfigScreen
| |
| |arg1 = {{type|number}} screenWidth
| |
| |arg2 = {{type|number}} screenDistance
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info = Used for Unit LODs.
| |
| }}
| |
| | |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = DrawMiniMap
| |
| |arg1 = {{type|bool}} transform = true
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = SlaveMiniMap
| |
| |arg1 = {{type|bool}} mode
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = ConfigMiniMap
| |
| |arg1 = {{type|number}} intPX
| |
| |arg2 = {{type|number}} intPY
| |
| |arg3 = {{type|number}} intSX
| |
| |arg4 = {{type|number}} intSY
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = GetViewSizes
| |
| |arg1 =
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|number}} x, {{type|number}} y
| |
| |info =
| |
| }}
| |
| | |
| = Matrices & Viewport =
| |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = Viewport
| |
| |arg1 = {{type|number}} x
| |
| |arg2 = {{type|number}} y
| |
| |arg3 = {{type|number}} w
| |
| |arg4 = {{type|number}} h
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = PushMatrix
| |
| |arg1 =
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = PopMatrix
| |
| |arg1 =
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = Translate
| |
| |arg1 = {{type|number}} x
| |
| |arg2 = {{type|number}} y
| |
| |arg3 = {{type|number}} z
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = Scale
| |
| |arg1 = {{type|number}} x
| |
| |arg2 = {{type|number}} y
| |
| |arg3 = {{type|number}} z
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = Scale
| |
| |arg1 = {{type|number}} angle
| |
| |arg2 = {{type|number}} x
| |
| |arg3 = {{type|number}} y
| |
| |arg4 = {{type|number}} z
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
|
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = Billboard
| |
| |arg1 =
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info = Use this to draw 2d primitives in DrawWorld().
| |
| }}
| |
| <pre>To render a 2D billboarded quad in the gameworld at world position x,y,z, you do the following (at a minimum; I am skipping blending / depthtesting) here:
| |
| gl.PushMatrix()
| |
| gl.Texture(read what you need here)
| |
| gl.Translate(x,y,z)
| |
| gl.Billboard()
| |
| gl.TexRect(x1,y1,x2,y2)
| |
| gl.PopMatrix()</pre>
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = MatrixMode
| |
| |arg1 = {{type|number}} [[Lua_ConstGL#MatrixMode|mode]]
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = LoadIdentity
| |
| |arg1 =
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = LoadMatrix
| |
| |arg1 = 16 {{type|numbers}} or a [https://github.com/spring/spring/blob/develop/rts/Lua/LuaOpenGLUtils.cpp#L60 matrix name]
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = MultMatrix
| |
| |arg1 = ???
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = ???
| |
| |info =
| |
| }}
| |
| | |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = Ortho
| |
| |arg1 = {{type|number}} left
| |
| |arg2 = {{type|number}} right
| |
| |arg3 = {{type|number}} bottom
| |
| |arg4 = {{type|number}} top
| |
| |arg5 = {{type|number}} near
| |
| |arg6 = {{type|number}} far
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = Frustum
| |
| |arg1 = {{type|number}} left
| |
| |arg2 = {{type|number}} right
| |
| |arg3 = {{type|number}} bottom
| |
| |arg4 = {{type|number}} top
| |
| |arg5 = {{type|number}} near
| |
| |arg6 = {{type|number}} far
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = PushPopMatrix
| |
| |arg1 = ???
| |
| |arg2 =
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = ???
| |
| |info =
| |
| }}
| |
| | |
| | |
| {{LuaCallout
| |
| |prefix = gl.
| |
| |name = ClipPlane
| |
| |arg1 = {{type|number}} intPlane
| |
| |arg2 = {{type|bool}} enable {{pipe}} {{type|number}} A, {{type|number}} B, {{type|number}} C, {{type|number}} D
| |
| |arg3 =
| |
| |arg4 =
| |
| |arg5 =
| |
| |arg6 =
| |
| |arg7 =
| |
| |arg8 =
| |
| |arg9 =
| |
| |return = {{type|nil}}
| |
| |info = Note: intPlane can only be 1 or 2.
| |
| }}
| |
| | |
| = Clear =
| |
| '''gl.Clear'''
| |
| ( GL.DEPTH_BUFFER_BIT [, number cleardepth] ) -> nil
| |
| ( GL.STENCIL_BUFFER_BIT [, int clearstencil] ) -> nil
| |
| ( GL.COLOR_BUFFER_BIT | GL.ACCUM_BUFFER_BIT [, number r, number g, number b, number a] ) -> nil
| |
| | |
| '''gl.SwapBuffers''' {{new|104.0}}
| |
| () -> nil
| |
| | |
| Available only in LuaMenu, meant for frame-limited LuaMenu's that want identical content in both buffers.
| |
| | |
| = ResetState/Matrices =
| |
| '''gl.ResetState''' <span class="warning">DON'T USE IT UNLESS YOU KNOW WHAT YOU ARE DOING! Each call-in has different default states, but this function resets all states to the states below no matter what!</span> | |
| () -> nil
| |
| <font color="#55ee99">
| |
| ShadeModel = GL.SMOOTH
| |
| Scissor = false
| |
| Texture = false
| |
| Lighting = false,
| |
| ColorMask = true, true, true, true
| |
| DepthMask = false
| |
| DepthTest = false (GL.LEQUAL)
| |
| Culling = false (GL.BACK)
| |
| LogicOp = false (GL.INVERT)
| |
| AlphaTest = false (GL.GREATER, 0.5f)
| |
| Blending = true (GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA)
| |
| </font>
| |
| | |
| '''gl.ResetMatrices'''
| |
| () -> nil
| |
| <font color="#55ee99">
| |
| Resets GL.TEXTURE matrix stack
| |
| Resets GL.MODELVIEW matrix stack
| |
| Resets GL.PROJECTION matrix stack
| |
| </font>
| |
| | |
| | |
| = Draw Basics =
| |
| '''gl.BeginEnd'''
| |
| ( number [[Lua_ConstGL#Drawing_Primitives|GLType]], function [, arg1,... ] ) -> nil | |
| | |
| '''gl.Color'''
| |
| ( { number r, number g, number b[, number a] } |
| |
| number r, number g, number b[, number a] ) -> nil | |
| | |
| '''gl.Vertex'''
| |
| ( { number x, number y [, number z [, number w ]] } |
| |
| number x, number y |
| |
| number x, number y, number z |
| |
| number x, number y, number z, number w ) -> nil
| |
| | |
| '''gl.Normal'''
| |
| ( number x, number y, number z |
| |
| { number x, number y, number z } ) -> nil
| |
| | |
| '''gl.EdgeFlag'''
| |
| ( boolean enable ) -> nil
| |
| | |
| '''gl.Rect'''
| |
| ( number x1, number y1, number x2, number y2 ) -> nil
| |
| | |
| '''gl.TexRect''' <font color="#55ee99">texture rect</font>
| |
| ( number x1, number y1, number x2, number y2,
| |
| [ boolean flip_s, boolean flip_t | number s1, number t1, number s2, number t2 ] ) -> nil
| |
| | |
| '''gl.Shape'''
| |
| ( number [[Lua_ConstGL#Drawing_Primitives|GLtype]],
| |
| elements = {
| |
| [1] = { v | vertex = { number x, number y, number z }, <font color="#55ee99">required</font>
| |
| n | normal = { number x, number y, number z }, <font color="#55ee99">optional</font>
| |
| t | texcoord = { number x, number y }, <font color="#55ee99">optional</font>
| |
| c | color = { number r, number g, number b, number a } <font color="#55ee99">optional</font>
| |
| },
| |
| etc ...
| |
| }
| |
| ) -> nil
| |
| | |
| '''gl.SecondaryColor'''
| |
| ( { number r, number g, number b } |
| |
| number r, number g, number b ) -> nil
| |
| | |
| '''gl.FogCoord'''
| |
| ( number value ) -> nil
| |
| | |
| | |
| = Display Lists =
| |
| <span class=note>Display Lists save given vertex attributes in a static buffer, so the GPU can directly read them (without the CPU). Display Lists are a lot faster (10-60x) than standard drawing with glShape/glBeginEnd, so try to use them when ever you can. If you want to learn more about them, g00gle is your friend ;)</span>
| |
| | |
| '''gl.CreateList'''
| |
| ( function [,arg1 [,arg2...]] ) -> number listID
| |
| | |
| '''gl.CallList'''
| |
| ( number listID ) -> nil
| |
| | |
| '''gl.DeleteList'''
| |
| ( number listID ) -> nil
| |
| | |
| = Vertex Array Objects =
| |
| <span class=note> <font color=darkblue> Only available in "develop" branch of spring (the future 105.0+). This is conceptually similar and serve as modern OpenGL replacement to deprecated Display Lists. </font> </span>
| |
| | |
| '''gl.CreateVertexArray'''
| |
| ( number numElements, number numIndices, [boolean persistentBuffer = false] ) -> number bufferID
| |
| | |
| See what elements and indices are here: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/<br>
| |
| numElements and numIndices define the size of for elements and indices respectively. if indices are not going to be used, then set numIndices to 0<br>
| |
| Persistent buffers (persistentBuffer = true) are more efficient for dynamically/often updated geometry.<br>
| |
| | |
| | |
| '''gl.UpdateVertexArray'''
| |
| ( number bufferID, number elementPos, number indexPos, table tbl | function func ) -> boolean success
| |
| | |
| {elementPos, indexPos} define starting element in {element, index} VBO corresponding to 1st element of the supplied vertex data<br>
| |
| 4 elements table example:<br>
| |
| local verts = {
| |
| p = {0,0,0,1, 4,0,0,1, 4,4,0,1, 0,4,0,1},
| |
| n = {0,1,0 , 0,1,0 , 0,1,0 , 0,1,0 },
| |
| uv = {0,0,0,0, 1,0,0,0, 1,1,0,0, 0,1,0,0},
| |
| c0 = {1,0,0,1, 0,1,0,1, 0,0,1,1, 1,1,1,0},
| |
| i = {0, 1, 2, 2, 1, 3}, <font color="#55ee99">optional, use in case of indexed VBO</font>
| |
| c1 = {...} }
| |
| <br>Alternatively Lua func can use gl.Vertex/gl.Color/gl.Normal/gl.TexCoord to define vertices, similarly how it used to be done in gl.BeginEnd.Note there is no function yet to define indices.<br>
| |
| | |
| | |
| '''gl.RenderVertexArray'''
| |
| ( number bufferID, number primType, [number firstIndex = 0, count = numElements] ) -> boolean success
| |
| primType can be GL.POINTS, GL.LINE_STRIP, GL.LINE_LOOP, GL.LINES, GL.LINE_STRIP_ADJACENCY, GL.LINES_ADJACENCY, GL.TRIANGLE_STRIP, GL.TRIANGLE_FAN, GL.TRIANGLES, GL.TRIANGLE_STRIP_ADJACENCY, GL.TRIANGLES_ADJACENCY and GL.PATCHES<br>
| |
| firstIndex specifies the starting index in the enabled arrays.<br>
| |
| count specifies the number of indices to be rendered.<br>
| |
| | |
| | |
| '''gl.DeleteVertexArray'''
| |
| ( number bufferID ) -> boolean success
| |
| Releases previously allocated VAO<br>
| |
| | |
| = Text =
| |
| '''gl.Text'''
| |
| (string "text", number x, number y, number size [, string <span class=note>"options"</span>] )
| |
| <span class=note>
| |
| options are:
| |
| horizontal alignment:
| |
| 'c' = center
| |
| 'r' = right
| |
| vertical alignment:
| |
| 'a' = ascender
| |
| 't' = top
| |
| 'v' = vertical center
| |
| 'x' = baseline
| |
| 'b' = bottom
| |
| 'd' = descender
| |
| decorations:
| |
| 'o' = black outline
| |
| 'O' = white outline
| |
| 's' = shadow
| |
| other:
| |
| 'n' = don't round vertex coords to nearest integer (font may get blurry)
| |
| </span>
| |
| http://home.arcor.de/jkei/fontlines.png
| |
| | |
| | |
| '''gl.GetTextWidth'''
| |
| (string "text") -> number width <span class=note>(in pixels, with a font size of 1.0)</span>
| |
| | |
| '''gl.GetTextHeight'''
| |
| ( string "text" ) -> nil | number height, number descender, number numlines <span class=note>(in pixels, with a font size of 1.0)</span>
| |
| <span class=note>further descriptions here: [[GetTextHeight]]</span>
| |
| | |
| | |
| <span class=note><b>If you have multiple gl.Text calls, then you can bunch them between a gl.BeginText and gl.EndText to speedup the rendering.</b></span><br>
| |
| '''gl.BeginText'''
| |
| ( ) -> nil
| |
| '''gl.EndText'''
| |
| ( ) -> nil
| |
| | |
| = Unit/Feature Draw Functions =
| |
| '''gl.Unit''' <font color="#55ee99">(draws an unit; on default it uses LOD, with lod<0 it is turned off, else it defines a specific level)</font>
| |
| ( number unitID, [ boolean rawdraw, int lod ] ) -> nil
| |
| | |
| '''gl.UnitRaw''' <font color="#55ee99">(doesn't apply worldspace->unit transformation! only works if <i>rawdraw</i> is true )</font>
| |
| ( number unitID, [ boolean rawdraw, int lod ] ) -> nil
| |
| | |
| '''gl.UnitShape'''
| |
| ( number unitDefID, number teamID, bool rawState, bool toScreen, bool opaque ) -> nil
| |
| | |
| {{new|101.0}} The three extra boolean arguments make it so that calling only these functions is enough to get correctly rendered models; pass in 'false' for the THIRD argument to get the fixed behavior, omit it or pass in 'true' [default] to render with your own custom state instead. The FOURTH argument should be 'true' if in DrawScreen and 'false' (default) if in DrawWorld; any transforms for these two functions *MUST* include a gl.LoadIdentity call when argument #3 is false (whether they are used in DrawWorld or in DrawScreen) the FIFTH argument determines whether the model is drawn opaque ('true' [default]) or with translucency ('false'); only has an effect when argument #3 is false.
| |
| | |
| '''gl.UnitMultMatrix''' <font color="#55ee99">(world space -> unit space)</font>
| |
| ( number unitID ) -> nil
| |
| | |
| '''gl.UnitPieceMultMatrix''' <font color="#55ee99">(unit space -> piece space)</font>
| |
| ( number unitID, int piece ) -> nil
| |
| | |
| '''gl.UnitPiece''' <font color="#55ee99">(draws the unit piece)</font>
| |
| ( number unitID, int piece ) -> nil
| |
| | |
| '''gl.UnitPieceMatrix''' <font color="red">(use gl.UnitPieceMultMatrix instead!)</font>
| |
| ( number unitID, int piece ) -> nil
| |
| | |
| '''gl.Feature'''
| |
| ( number featureID ) -> nil
| |
| | |
| '''gl.FeatureRaw''' {{new|101.0}}
| |
| ( number featureID, [ boolean rawdraw, int lod ] ) -> nil
| |
| | |
| '''gl.FeatureShape'''
| |
| ( number featureDefID, number teamID, bool custom, bool drawScreen, bool opaque ) -> nil
| |
| | |
| '''gl.FeatureMultMatrix''' {{new|101.0}} <font color="#55ee99">(world space -> feature space)</font>
| |
| ( number featureID ) -> nil
| |
| | |
| '''gl.FeaturePieceMultMatrix''' {{new|101.0}} <font color="#55ee99">(feature space -> piece space)</font>
| |
| ( number featureID, int piece ) -> nil
| |
| | |
| '''gl.FeaturePiece''' {{new|101.0}} <font color="#55ee99">(draws the Feature piece)</font>
| |
| ( number featureID, int piece ) -> nil
| |
| | |
| '''gl.FeaturePieceMatrix''' {{new|101.0}} <font color="red">(use gl.FeaturePieceMultMatrix instead!)</font>
| |
| ( number featureID, int piece ) -> nil
| |
| | |
| '''gl.DrawListAtUnit'''
| |
| ( number unitID, number listID, [ boolean midPos,
| |
| number scaleX, number scaleY, number scaleZ,
| |
| number degrees, number rotX, number rotX, number rotZ ] ) -> nil
| |
| | |
| '''gl.DrawFuncAtUnit'''
| |
| ( number unitID, boolean midPos, function [, arg1,... ]) -> nil
| |
| | |
| = States (Blending,AlphaTest...) =
| |
| '''gl.Blending'''
| |
| ( boolean enable | number [[Lua_ConstGL#BlendingFactorSrc|srcmode]], number [[Lua_ConstGL#BlendingFactorDest|dstmode]] ) -> nil
| |
| ( string <span class=note>mode</span> ) -> nil
| |
| {| cellpadding="0" cellspacing="0" style="margin-top: -5px; margin-left:5px"
| |
| ! style="color:#55ee99" | mode maybe:
| |
| |-
| |
| | style="color:#55ee99" | "add"
| |
| | style="color:#55ee99" | = GL.ONE, GL.ONE
| |
| |-
| |
| | style="color:#55ee99" | "alpha_add"
| |
| | style="color:#55ee99" | = GL.SRC_ALPHA, GL.ONE
| |
| |-
| |
| | style="color:#55ee99" | "alpha"
| |
| | style="color:#55ee99" | = GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA
| |
| |-
| |
| | style="color:#55ee99" | "reset"
| |
| | style="color:#55ee99" | = GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA
| |
| |-
| |
| | style="color:#55ee99" | "color"
| |
| | style="color:#55ee99" | = GL.SRC_COLOR, GL.ONE_MINUS_SRC_ALPHA
| |
| |-
| |
| | style="color:#55ee99" | "modulate"
| |
| | style="color:#55ee99" | = GL.DST_COLOR, GL.ZERO
| |
| |-
| |
| | style="color:#55ee99" | "disable"
| |
| | style="color:#55ee99" | = GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA
| |
| |}
| |
| | |
| | |
| '''gl.BlendEquation'''
| |
| ( number mode ) -> nil
| |
| | |
| '''gl.BlendFunc'''
| |
| ( number [[Lua_ConstGL#BlendingFactorSrc|srcmode]], number [[Lua_ConstGL#BlendingFactorDest|dstmode]] ) -> nil
| |
| | |
| '''gl.BlendEquationSeparate''' <span class=warning>(needs openGL2.0!)</span>
| |
| ( number modeRGB, number modeAlpha ) -> nil
| |
| | |
| '''gl.BlendFuncSeparate''' <span class=warning>(needs openGL2.0!)</span>
| |
| ( number [[Lua_ConstGL#BlendingFactorSrc|srcRGB]], number [[Lua_ConstGL#BlendingFactorDest|dstRGB]], number [[Lua_ConstGL#BlendingFactorSrc|srcAlpha]], number [[Lua_ConstGL#BlendingFactorDest|dstAlpha]] ) -> nil
| |
| | |
| '''gl.AlphaTest'''
| |
| ( boolean enable | number [[Lua_ConstGL#AlphaFunction and DepthFunction|func]], number threshold ) -> nil
| |
| | |
| '''gl.DepthTest'''
| |
| ( boolean enable | number [[Lua_ConstGL#AlphaFunction and DepthFunction|func]] ) -> nil
| |
| | |
| '''gl.Culling'''
| |
| ( boolean enable | number [[Lua_ConstGL#Culling|face]] ) -> nil
| |
| | |
| '''gl.DepthClamp''' <span class=warning>not always available, needs GL.NV_depth_clamp!</span>
| |
| ( boolean enable ) -> nil
| |
| | |
| '''gl.DepthMask'''
| |
| ( boolean enable ) -> nil
| |
| | |
| '''gl.ColorMask'''
| |
| ( boolean ) -> nil
| |
| ( boolean r, boolean g, boolean b, boolean a ) -> nil
| |
| | |
| '''gl.LogicOp'''
| |
| ( boolean enable | number [[Lua_ConstGL#LogicOp|func]] ) -> nil
| |
| | |
| '''gl.Fog'''
| |
| ( boolean enable ) -> nil
| |
| | |
| '''gl.Smoothing''' {{removed|104.0}}
| |
| ( (boolean enable | number POINT),
| |
| (boolean enable | number LINE),
| |
| (boolean enable | number POLYGON) ) -> nil
| |
| | |
| '''gl.EdgeFlag'''
| |
| ( boolean enable ) -> nil
| |
| | |
| '''gl.Scissor'''
| |
| ( boolean ) -> nil
| |
| ( int x, int y, int w, int h ) -> nil
| |
| | |
| '''gl.LineStipple'''
| |
| ( string any ) -> nil <font color="#55ee99">(use springs default line stipple)</font>
| |
| ( boolean enable ) -> nil
| |
| ( int factor, number pattern ) -> nil
| |
| | |
| '''gl.PolygonMode'''
| |
| ( number [[Lua_ConstGL#Culling|face]], number [[Lua_ConstGL#PolygonMode|mode]] ) -> nil
| |
| | |
| '''gl.PolygonOffset'''
| |
| ( boolean enable | number factor, number units ) -> nil
| |
| | |
| '''gl.PushAttrib'''
| |
| ( [ number [[Lua_ConstGL#glPushAttrib.28.29_bits|attrib]] ] ) -> nil
| |
| | |
| '''gl.PopAttrib'''
| |
| () -> nil
| |
| | |
| = Stencil =
| |
| '''gl.StencilTest'''
| |
| ( boolean enable ) -> nil
| |
| '''gl.StencilMask'''
| |
| ( number mask ) -> nil
| |
| '''gl.StencilFunc'''
| |
| ( number func, number ref, number mask ) -> nil
| |
| '''gl.StencilOp'''
| |
| ( number fail, number zfail, number zpass ) -> nil
| |
| | |
| | |
| '''gl.StencilMaskSeparate''' <span class=warning>(needs openGL2.0!)</span>
| |
| ( number [[Lua_ConstGL#Culling|face]], number mask ) -> nil
| |
| '''gl.StencilFuncSeparate''' <span class=warning>(needs openGL2.0!)</span>
| |
| ( number [[Lua_ConstGL#Culling|face]], number func, number ref, number mask ) -> nil
| |
| '''gl.StencilOpSeparate''' <span class=warning>(needs openGL2.0!)</span>
| |
| ( number [[Lua_ConstGL#Culling|face]], number fail, number zfail, number zpass ) -> nil
| |
| | |
| | |
| = LineWidth & PointSize =
| |
| '''gl.LineWidth'''
| |
| ( number width ) -> nil
| |
| | |
| '''gl.PointSize''' <font color="red">(values != 1 can break severely on ATI cards, see http://springrts.com/mantis/view.php?id=2390)</font>
| |
| ( number size ) -> nil
| |
| | |
| '''gl.PointSprite''' <font color="red">(needs openGL2.0!)</font>
| |
| ( boolean enable, [boolean coord_replace, boolean coord_origin_upper] ) -> nil
| |
| | |
| '''gl.PointParameter''' <font color="red">(needs openGL2.0!)</font>
| |
| ( number v1, number v2, number v3,
| |
| [ number sizeMin, number sizeMax, number sizeFade ] ) -> nil
| |
| | |
| = Textures =
| |
| '''gl.Texture'''
| |
| ( [ number texNum, ] boolean enable | string <span class=note>name</span> ) -> nil | boolean loaded
| |
| <font color=#dd9944>This is the only call-out that is needed to load and draw any texture in a Lua script. All you have to do is pass it a valid path to a valid png and it will use that image for drawing any subsequent textured rectangles. This is shown in the last line of the following list of valid strings for the name parameter.</font>
| |
| | |
| | |
| <span class=note>
| |
| {| cellpadding="0" cellspacing="0" style="margin-top: -5px; margin-left:5px"
| |
| ! style="color:#55ee99; text-align:left" |`name` may be:
| |
| |-
| |
| | style="color:#55ee99" | #12
| |
| | style="color:#55ee99" | = unitDef 12 buildpic
| |
| |-
| |
| | style="color:#55ee99" | %34:1
| |
| | style="color:#55ee99" | = unitDef 34 s3o tex2 (:0->tex1,:1->tex2)
| |
| |-
| |
| | style="color:#55ee99" | %-102:0
| |
| | style="color:#55ee99" | = featureDef 102 s3o tex1
| |
| |-
| |
| | style="color:#55ee99" | !56
| |
| | style="color:#55ee99" | = lua generated texture 56 (= return value of gl.CreateTexture)
| |
| |-
| |
| | style="color:#55ee99" | $units
| |
| | style="color:#55ee99" | = 3do textureatlas tex1
| |
| |-
| |
| | style="color:#55ee99" | $units1
| |
| | style="color:#55ee99" | = 3do textureatlas tex1
| |
| |-
| |
| | style="color:#55ee99" | $units2
| |
| | style="color:#55ee99" | = 3do textureatlas tex2
| |
| |-
| |
| | style="color:#55ee99" | $shadow
| |
| | style="color:#55ee99" | = shadowmap
| |
| |-
| |
| | style="color:#55ee99" | $specular
| |
| | style="color:#55ee99" | = specular cube map <font color="red">(removed in the latest develop)</font>
| |
| |-
| |
| | style="color:#55ee99" | $reflection
| |
| | style="color:#55ee99" | = reflection cube map <font color="red">(can be mipmaped starting from 104.0.1-714-ga29177f. Set CubeTexGenerateMipMaps=1 in settings)</font>
| |
| |-
| |
| | style="color:#55ee99" | $shading
| |
| | style="color:#55ee99" | = ground shading texture
| |
| |-
| |
| | style="color:#55ee99" | $grass
| |
| | style="color:#55ee99" | = grass shading texture
| |
| |-
| |
| | style="color:#55ee99" | $heightmap
| |
| | style="color:#55ee99" | = heightmap (needs HeightMapTexture=1 set in spring config)
| |
| |-
| |
| | style="color:#55ee99" | $minimap
| |
| | style="color:#55ee99" | = minimap texture
| |
| |-
| |
| | style="color:#55ee99" | $map_reflection
| |
| | style="color:#55ee99" | = same as "$reflection" {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $sky_reflection
| |
| | style="color:#55ee99" | = defined for SSMF maps that have a skyReflectModTex {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $detail
| |
| | style="color:#55ee99" | = detail texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $normals
| |
| | style="color:#55ee99" | = auto generated normals texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $ssmf_normals
| |
| | style="color:#55ee99" | = SSMF normals texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $ssmf_specular
| |
| | style="color:#55ee99" | = SSMF specular texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $ssmf_splat_distr
| |
| | style="color:#55ee99" | = SSMF splat distribution texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $ssmf_splat_detail
| |
| | style="color:#55ee99" | = SSMF splat detail texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $ssmf_splat_normals
| |
| | style="color:#55ee99" | = SSMF splat normals texture {{new|101.0}}, used as "$ssmf_splat_normals" or "$ssmf_splat_normals:X", 'X' can be a value between 0 and 3, defaults to 0 if ":X" is omitted
| |
| |-
| |
| | style="color:#55ee99" | $ssmf_emission
| |
| | style="color:#55ee99" | = SSMF emission texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $ssmf_parallax
| |
| | style="color:#55ee99" | = SSMF parallax texture {{new|101.0}}
| |
| |-
| |
| | style="color:#55ee99" | $info
| |
| | style="color:#55ee99" | = currently active info texture (los, airlos, radar, jammer)<br/> Note that textures contain no data until user switches to their respective modes and non-active textures are not updated in the background, so will go stale
| |
| |-
| |
| | style="color:#55ee99" | $info_losmap
| |
| | style="color:#55ee99" | = los texture (L-view)
| |
| |-
| |
| | style="color:#55ee99" | $info_mtlmap
| |
| | style="color:#55ee99" | = metal map texture (F4-view)
| |
| |-
| |
| | style="color:#55ee99" | $info_hgtmap
| |
| | style="color:#55ee99" | = height map texture (F1-view)
| |
| |-
| |
| | style="color:#55ee99" | $info_blkmap
| |
| | style="color:#55ee99" | = blocking map texture (F2-view)
| |
| |-
| |
| | style="color:#55ee99" | $map_gbuffer_normtex
| |
| | style="color:#55ee99" | = contains the smoothed normals buffer of the map in view in world space coordinates (note that to get true normal vectors from it, you must multiply the vector by 2 and subtract 1) {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $map_gbuffer_difftex
| |
| | style="color:#55ee99" | = contains the diffuse texture buffer of the map in view {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $map_gbuffer_spectex
| |
| | style="color:#55ee99" | = contains the specular textures of the map in view {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $map_gbuffer_emittex
| |
| | style="color:#55ee99" | = for emissive materials (bloom would be the canonical use) {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $map_gbuffer_misctex
| |
| | style="color:#55ee99" | = for arbitrary shader data {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $map_gbuffer_zvaltex
| |
| | style="color:#55ee99" | = contains the depth values (z-buffer) of the map in view. {{new|95}} <br/>To translate this to world position coordinates, use:<br/>
| |
| | |
| '''No clip control / clipspace for depth is [-1,1]'''
| |
| vec4 worldpos= viewProjectionInv * vec4(vec3(gl_TexCoord[0].st,
| |
| texture2D( map_gbuffer_zvaltex,gl_TexCoord[0].st ).x) * 2.0 - 1.0, 1.0);
| |
| | |
| '''Default if clip control is supported / clipspace for depth is [0,1].'''
| |
| vec4 worldpos= viewProjectionInv * vec4(gl_TexCoord[0].st * 2.0 - 1.0,
| |
| texture2D( map_gbuffer_zvaltex,gl_TexCoord[0].st ).x, 1.0);
| |
| | |
| worldpos.xyz = worldpos.xyz / worldpos.w;
| |
| |-
| |
| | style="color:#55ee99" | $model_gbuffer_normtex
| |
| | style="color:#55ee99" | = contains the smoothed normals buffer of the models in view in world space coordinates (note that to get true normal vectors from it, you must multiply the vector by 2 and subtract 1) {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $model_gbuffer_difftex
| |
| | style="color:#55ee99" | = contains the diffuse texture buffer of the models in view {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $model_gbuffer_spectex
| |
| | style="color:#55ee99" | = contains the specular textures of the models in view {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $model_gbuffer_emittex
| |
| | style="color:#55ee99" | = for emissive materials (bloom would be the canonical use) {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $model_gbuffer_misctex
| |
| | style="color:#55ee99" | = for arbitrary shader data {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | $model_gbuffer_zvaltex
| |
| | style="color:#55ee99" | = contains the depth values (z-buffer) of the models in view. {{new|95}}
| |
| |-
| |
| | style="color:#55ee99" | ${opt}:/LuaUI/images/image.png
| |
| | style="color:#55ee99" | = load a texture from the VFS
| |
| |}
| |
| | |
| possible ${opt}'s are:
| |
| 'n' = nearest
| |
| 'l' = linear
| |
| 'a' = aniso
| |
| 'i' = invert
| |
| 'g' = greyed
| |
| 'c' = clamped
| |
| 'b' = border
| |
| 't%r,%g,%b' = tint
| |
| 'r%width,%height' = resize | |
| The above ${opt}'s are NOT available for .DDS textures! .dds will load faster than other image formats.
| |
| | |
| example: ":iac:/LuaUI/images/image.png"
| |
| example: ":cr16,16:/LuaUI/images/image.png"
| |
| example2: ":t1.0,0.5,0:/LuaUI/images/image.png" (orange tint)
| |
| </span>
| |
| | |
| '''gl.CreateTexture'''
| |
| ( int xsize, int ysize,
| |
| [ {
| |
| [target = number,] <font color="#55ee99">(like GL.TEXTURE_1D,GL.TEXTURE_2D,...)</font> <font color=darkblue> (Added support for GL_TEXTURE_2D_MULTISAMPLE in 104.0.1-1015-g8e36ef2 maintenance)</font>
| |
| [format = number,]
| |
| [min_filter = [[Lua_ConstGL#Texture_Filtering|number]],]
| |
| [mag_filter = [[Lua_ConstGL#Texture_Filtering|number]],]
| |
| [wrap_s = [[Lua_ConstGL#Texture_Clamping|number]],]
| |
| [wrap_t = [[Lua_ConstGL#Texture_Clamping|number]],]
| |
| [wrap_r = [[Lua_ConstGL#Texture_Clamping|number]],]
| |
| [aniso = number,]
| |
| [border = boolean,]
| |
| [fbo = boolean,] <font color="red">(needs GLEW_EXT_framebuffer_object!)</font>
| |
| [fboDepth = boolean,] <font color="red">(needs GLEW_EXT_framebuffer_object!)</font>
| |
| [samples = number,] <font color=darkblue> specify any number here and target = GL_TEXTURE_2D_MULTISAMPLE to create multisample texture (Added in 104.0.1-1015-g8e36ef2 maintenance)</font>
| |
| } ]
| |
| ) -> string
| |
| | |
| '''gl.DeleteTexture'''
| |
| ( string texture ) -> boolean
| |
| | |
| '''gl.DeleteTextureFBO''' <font color="red">(needs GLEW_EXT_framebuffer_object!)</font>
| |
| ( string texture ) -> boolean
| |
| | |
| '''gl.TextureInfo'''
| |
| ( string texture ) -> nil | {
| |
| xsize = number,
| |
| ysize = number,
| |
| alpha = boolean, //not used yet
| |
| type = number, //not used yet
| |
| } | | } |
| <font color="#55ee99">
| |
| the format of the texture string is the same as in gl.Texture()
| |
| </font>
| |
|
| |
| '''gl.TexCoord'''
| |
| ( number x |
| |
| number x, number y |
| |
| number x, number y, number z |
| |
| number x, number y, number z, number w |
| |
| { number x [, number y [, number z [, number w ]]] } ) -> nil
| |
|
| |
| '''gl.MultiTexCoord'''
| |
| ( int texNum,
| |
| number x |
| |
| number x, number y |
| |
| number x, number y, number z |
| |
| number x, number y, number z, number w |
| |
| { number x [, number y [, number z [, number w ]]] } ) -> nil
| |
|
| |
| '''gl.TexEnv'''
| |
| ( number [[Lua_ConstGL#Texture_Environment|target]], number [[Lua_ConstGL#Texture_Environment|pname]],
| |
| number [[Lua_ConstGL#Texture_Environment|value]] |
| |
| number var1, number var2, number var3 ) -> nil
| |
|
| |
| '''gl.MultiTexEnv'''
| |
| ( int texNum, number [[Lua_ConstGL#Texture_Environment|target]], number [[Lua_ConstGL#Texture_Environment|pname]],
| |
| number [[Lua_ConstGL#Texture_Environment|value]] |
| |
| number var1, number var2, number var3 ) -> nil
| |
|
| |
| '''gl.TexGen'''
| |
| ( number [[Lua_ConstGL#Texture_Generation|target]],
| |
| boolean state |
| |
| number [[Lua_ConstGL#Texture_Generation|pname]], number value |
| |
| number [[Lua_ConstGL#Texture_Generation|pname]], number var1, number var2, number var3 ) -> nil
| |
|
| |
| '''gl.MultiTexGen'''
| |
| ( int texNum, number [[Lua_ConstGL#Texture_Generation|target]],
| |
| boolean state |
| |
| number [[Lua_ConstGL#Texture_Generation|pname]], number value |
| |
| number [[Lua_ConstGL#Texture_Generation|pname]], number var1, number var2, number var3 ) -> nil
| |
|
| |
| '''gl.CopyToTexture'''
| |
| (string texture, int xoff, int yoff, int x, int y, int w, int h
| |
| [,number target,number level])->nil
| |
|
| |
| '''gl.RenderToTexture''' <font color="red">(needs GLEW_EXT_framebuffer_object!)</font>
| |
| ( string fbotexture, lua_func ) -> nil
| |
|
| |
| '''gl.GenerateMipmap''' <font color="red">(needs glGenerateMipmapEXT!)</font>
| |
| ( string texture ) -> boolean
| |
|
| |
| The following are primarily intended to be used in conjunction with
| |
| gl.{Unit,Feature}(objID, ..., raw=true)
| |
| gl.{Unit,Feature}Shape(defID, ..., raw=true)
| |
| and apply a model's default textures; easier than gl.Texture("$%...")
| |
|
| |
| '''gl.UnitTextures'''
| |
| ( number unitID, boolean enable ) -> boolean
| |
|
| |
| '''gl.UnitShapeTextures'''
| |
| ( number unitDefID, boolean enable ) -> boolean
| |
|
| |
| '''gl.FeatureTextures'''
| |
| ( number featureID, boolean enable ) -> boolean
| |
|
| |
| '''gl.FeatureShapeTextures'''
| |
| ( number featureDefID, boolean enable ) -> boolean
| |
|
| |
| = PixelReadback =
| |
| '''gl.SaveImage'''
| |
| ( number x, number y, number w, number h,
| |
| string filename [, table {alpha=boolean, yflip=boolean, grayscale16bit=boolean, readbuffer=number} ] ) -> nil | boolean success
| |
|
| |
| <span class="note">
| |
| grayscale16bit is {{new|99.0}} and allows to save single color 16bit PNG<br>
| |
| readbuffer is {{new|104+}} and allows to choose the attachment of MRT FBO, use GL_COLOR_ATTACHMENT0_EXT and further as index
| |
| </span>
| |
|
| |
| '''gl.ReadPixels'''
| |
| ( number x, number y, number w, number h [, number format = GL.RGBA ] )
| |
| -> nil
| |
| | number r,[g,[b,[a]]]
| |
| | table { { {1 = number r, 2 = number g, 3 = number b, 4 = number a}, ... }, ... }
| |
| <span class="note">
| |
| This reads back pixels from the final rendered screen. E.g. you can make a screenshot by grabbing the whole view.
| |
| </span>
| |
|
| |
| = Lights =
| |
| '''gl.Lighting'''
| |
| ( boolean enable ) -> nil
| |
|
| |
| '''gl.ShadeModel'''
| |
| ( number [[Lua_ConstGL#ShadeModel|mode]] ) -> nil
| |
|
| |
| '''gl.Light'''
| |
| ( int light,
| |
| boolean enable |
| |
| number [[Lua_ConstGL#Light_Specification|pname]], number param |
| |
| number [[Lua_ConstGL#Light_Specification|pname]], number param1, number param2, number param3 ) -> nil
| |
|
| |
| '''gl.Material'''
| |
| ({
| |
| ambient = {number r, number g, number b[, number a]},
| |
| diffuse = {number r, number g, number b[, number a]},
| |
| ambidiff = {number r, number g, number b[, number a]},
| |
| emission = {number r, number g, number b[, number a]},
| |
| specular = {number r, number g, number b[, number a]},
| |
| shininess = number specularExponent
| |
| }) -> nil
| |
|
| |
|
| |
| = Hardware relevant =
| |
| '''gl.HasExtension'''
| |
| ( string extname ) -> boolean
| |
|
| |
| '''gl.GetNumber'''
| |
| ( number ext, int count ) -> number [, number, number, ... #count ]
| |
|
| |
| '''gl.GetString'''
| |
| ( number ext ) -> string
| |
|
| |
|
| |
| = DrawGroundPrimitives =
| |
| '''gl.DrawGroundCircle'''
| |
| ( number x, number y, number z, number radius, number divs [, number slope ] ) -> nil
| |
| <font color="#55ee99">Note: number divs is the number of sides the circle will have. the higher the smoother the circle (and more GPU intensive) </font>
| |
|
| |
|
| |
| '''gl.DrawGroundQuad''' <font color="#55ee99">Note: x1,z1,x2 & z2 are rounded, so don't use it for very small or moving objects. x and z are correspond to the coordinates displayed by the tooltip </font>
| |
| ( number x1, number z1, number x2, number z2,
| |
| [ boolean useNorm, <span class=warning>(does nothing!)</span>
| |
| [ number tu1, number tv1, number tu2, number tv2 |
| |
| boolean useTextureCoord ] ] ) -> nil
| |
|
| |
| = Queries =
| |
| '''gl.CreateQuery''' <span class=warning>needs >=OpengGL2.0!</span>
| |
| ( ) -> nil | userdata query
| |
| '''gl.DeleteQuery''' <span class=warning>needs >=OpengGL2.0!</span>
| |
| ( userdata query ) -> nil
| |
| '''gl.RunQuery''' <span class=warning>needs >=OpengGL2.0!</span>
| |
| ( userdata query, function, arg1, arg2, ... ) -> nil
| |
| '''gl.GetQuery''' <span class=warning>needs >=OpengGL2.0!</span>
| |
| ( userdata query ) -> nil | number renderedFragments
| |
|
| |
|
| |
| = Extended =
| |
| '''gl.ActiveTexture'''
| |
| ( int texNum, function [, arg1,... ] ) -> nil
| |
|
| |
| '''gl.GetGlobalTexNames'''
| |
| () -> { [1] = string texture, etc ... }
| |
|
| |
| '''gl.GetGlobalTexCoords''' <span class=note>gets the texcoord of a 3do texture in the 3do texture atlas</span>
| |
| ( string 3doTextureName ) -> number xstart, number ystart, number xend, number yend
| |
|
| |
| '''gl.UnsafeState'''
| |
| ( number state [, boolean disable_state ], function, arg1, arg2, ... ) -> nil
| |
| <span class=note>Calls glEnable(state) or glDisable(state) (if disable_state==true) and<br>then calls the lua_function and afterwards reverts the state.</span>
| |
|
| |
|
| '''gl.GetShadowMapParams''' | | '''gl.GetUniformLocation''' |
| () -> number xmid, number ymid, number p17, number p18 | | ( number shaderID, name uniformName ) -> number locationID |
|
| |
|
| '''gl.GetMatrixData''' | | '''gl.Uniform''' |
| ( GL.PROJECTION [, int i] ) -> nil | number, etc.. | number Matrix[i] | | ( number locationID, number f1 [,number f2 [,number f3 [,number f4]]] ) -> nil |
| ( GL.MODELVIEW [, int i] ) -> nil | number, etc.. | number Matrix[i]
| |
| ( GL.TEXTURE [, int i] ) -> nil | number, etc.. | number Matrix[i]
| |
| ( "shadow" ) -> nil | number, etc..
| |
| ( "camera" ) -> nil | number, etc..
| |
| ( "caminv" ) -> nil | number, etc..
| |
| ( "camprj" ) -> nil | number, etc..
| |
| ( "billboard" ) -> nil | number, etc..
| |
|
| |
|
| '''gl.Flush''' | | '''gl.UniformInt''' |
| () -> nil | | ( number locationID, number int1 [,number int2 [,number int3 [,number int4]]] ) -> nil |
|
| |
|
| '''gl.Finish''' | | '''gl.UniformArray''' {{new|95.0}} |
| () -> nil | | ( number locationID, number type, table uniforms ) -> nil |
| | <span class="note">type can be one of {1 = int, 2 = float, 3 = float matrix}. In 104.0 the maximum length of the uniforms table increased from 32 entries to 1024.</span> |
|
| |
|
| = Shaders (GLSL) =
| | '''gl.UniformMatrix''' |
| [[Lua_GLSL_Api]] | | ( number locationID, |
| | "shadow" | |
| | "camera" | |
| | "caminv" | |
| | "camprj" | |
| | number m1, number m2, number m3, number m4 | |
| | number m1, ... , number m9 | |
| | number m1, ... , number m16 |
| | ) -> nil |
|
| |
|
| [[category: Lua]] | | [[category: Lua]] |