Graphics.glDraw

From PGE Wiki
Jump to: navigation, search

Graphics.glDraw is a function with access named arguments for drawing OpenGL primitives. The only required parameter is vertexCoords.

The list with accepted arguments:

Type Name Default Description
table vertexCoords <required> A flat table of x/y coordinates of verticies. Can be either 0-based or 1-based.
table textureCoords nil A flat table of x/y coordinates of for texture coordinates for each vertex. Can be either 0-based or 1-based.
table vertexColors nil A flat table of rgba values for the verticies.
table color {1.0, 1.0, 1.0, 1.0} (White) A table of RGB or RGBA values ranging from 0.0 to 1.0.
LuaImageResource or CaptureBuffer texture nil The texture to draw. Can be either a LuaImageResource or a CaptureBuffer.
number primitive Graphics.GL_TRIANGLES The OpenGL Graphics primative to draw verticies of. Valid options are: Graphics.GL_POINTS, Graphics.GL_LINES, Graphics.GL_LINE_LOOP, Graphics.GL_LINE_STRIP, Graphics.GL_TRIANGLES, Graphics.GL_TRIANGLE_STRIP, Graphics.GL_TRIANGLE_FAN
number priority 1.0 The priority to draw with. See LunaLua Render Priority.

Note: When using a CaptureBuffer as texture, be sure that the priority is higher than the one used in the buffer. Otherwise it might result into a crash.

boolean sceneCoords false If set to "true", the image will be drawn relative to the scene. Default is relative to the screen.

Values for LunaLua with Shader Support

Type Name Default Description
Shader shader nil The compiled Shader-Program to use.
table attributes nil A table where the key is the name of the attribute and the value is a an array containing all required values. Keep in mind that this is per-vertex, so you the number of values you pass in that array depends on the number for verticies you use.
table uniforms nil A table where the key is the name of the uniform and the value is a an array containing all required values.