yage.system.graphics.api.opengl
Authors:
Eric Poggel
License:
LGPL v3
- class
OpenGL
: yage.system.graphics.api.api.GraphicsAPI;
- The
OpenGL
class provides a higher level of abstraction over
OpenGL
,
without limiting what can be done with low-level
OpenGL
calls.
By inherting GraphicsAPI, it can be used interchangeably with other graphics apis,
should they ever be implemented.
- enum
MatrixType
;
-
PROJECTION
-
TEXTURE
-
TRANSFORM
- this();
- void
bindCamera
(CameraNode camera, int width, int height);
- void
bindLight
(LightNode light, int num);
- Enable this light as the given light number and apply its properties.
TODO:
Perhaps this should be bindLights(LightNode[]) instead.
This function is used internally by the engine and should not be called manually or exported.
- void
bindMatrix
(Matrix* matrix, MatrixType type = cast(MatrixType)2);
- Push or Pop Matrices on an OpenGL matrix stack.
Params:
Matrix* matrix |
Multiply the current Matrix at the top of the stack by this Matrix and push the result onto the stack,
or if matrix is null
, pop it off the stack.
This is a pointer to allow null
's, a copy is made for internal use. |
MatrixType type |
Determines which OpenGL matrix stack to modify. |
- bool
bindPass
(MaterialPass pass);
- Profiling has shown that changing shaders, textures, and blending operations are the slowest parts of this funciton.
TODO:
This can be made faster by only changing the shader and blending when different from a previous pass.
Params:
MaterialPass pass |
|
lights |
Array of LightNodes that affect this material. Required if the pass's autoShader is not AutoShader.NONE. |
Returns:
false
if Not all of the textures or the shader couldn't be bound. Even if this happens, as much of the
pass will be bound as possible, including as many textures as possible.
- void
bindRenderTarget
(IRenderTarget target);
- Call this function twice, the first time with a render target, and then again with null
to complete.
TODO, allow specifying which buffers to draw to (color, depth, stencil, etc).
Params:
IRenderTarget target |
Render to this target |
- void
bindScene
(Scene scene);
- Bind global scene properties, like ambient light and fog.
Params:
Scene scene |
If non null
, bind the properties of this scene, otherwise set them back to the defalts. |
- void
bindShader
(Shader shader, ShaderUniform[] variables = null);
- Make this shader program the currently active shader.
It will be compiled if necessary.
Params:
Shader shader |
|
ShaderUniform[] variables |
Unless specified otherwise, the currently bound textures specified by bindTextures will be bound
to uniform variables texture0, texture1, etc. |
- bool
bindTextures
(TextureInstance[] textures);
- Bind Textures for rendering.
Params:
TextureInstance[] textures |
Textures to be bound. Texture units beyond the array length will be disabled. |
Returns:
True if all of the textures were bound. Otherwise as many as possible will be bound.
- bool
bindVertexBuffer
(VertexBuffer vb, char[] type);
- Bind (and if necessary upload to video memory) a vertex buffer
Params:
char[] type |
A vertex buffer type constant defined in Geometry or Mesh. |
- void
cleanup
(uint age = cast(uint)3600);
- Reset OpenGL state and free any resources from graphics memory are either:
- haven't been used for longer than age,
- are no longer referenced.
If removed from graphics memory, they will be re-uploaded when needed again.
Params:
uint age |
maximum age (in seconds) of objects to keep. Set to 0 to remove all items. Defaults to 3600. |
- void
drawPolygons
(VertexBuffer polygons, char[] type, bool indexed = true);
- Draw the contents of a vertex buffer, such as a buffer of triangle indices.
@param triangles If not null
, this array of triangle indices will be used for drawing the mesh
- void
reset
();
- TODO
|