Skip to content

Initializing the renderer

Adam Gorski edited this page Aug 23, 2021 · 6 revisions

Initialization

Unlike renderXF, there is no need to initialize anything, as XFDraw uses a static class called GL.

It is recommended to call GL.Initialize(); to perform compatibility checks and DLL importing during startup, instead of a less convenient time where the first GL method is called.

Lets look at some of the useful methods offered by the GL class:

GL.Blit(GLTexture Data, BlitData Destination)

This method essentially blits a texture (which can be a framebuffer) onto a form provided in BlitData class.

GL.Clear(GLTexture TargetBuffer, byte R, byte G, byte B)

This method clears a selected texture (or framebuffer) with a specific color. It is very fast.

GL.Clear(GLTexture TargetBuffer)

This method clears a selected texture (or framebuffer) with zeroes.

Lets look at some drawing modes

XFDraw support Wireframe and triangle modes.

GLMode Implemented Description
GLMode.Triangle Yes Triangle
GLMode.Wireframe Yes Wireframe
GLMode.TriangleWireLate Yes Triangle and Wireframe
GLMode.TriangleSingle No Triangle but the shader is called only once
GLMode.Line No Line rendering mode

Example code:

GL.Draw(vertexBuffer, yourShader, depthBuffer, projectionMatrix, GLMode.Triangle);

//Or
GL.Draw(vertexBuffer, yourShader, depthBuffer, projectionMatrix, GLMode.Triangle, startIndex, stopIndex);

Notes

Wireframe and TriangleWireframe support depth offsets. TriangleWireframe is a special effect which makes it more convenient to draw a wireframe at the end of a draw command. This saves an entire vertex stage and XYZ to XY transform stage during a draw command making it faster than calling the two one after the other.

GLMode.TriangleSingle does not support using gl_FragCoord, gl_FragDepth or gl_FragPos as its not sampled per pixel basis, but rather a per triangle. This is very useful for vertex attributes that stay constant for the entire triangle face, as this method saves performance.

Clone this wiki locally