-
Notifications
You must be signed in to change notification settings - Fork 0
OpenGL Differences
There are a few key difference that make XFDraw from OpenGL. Obviously the first one is that its a software renderer.
XFDraw uses a GLMatrix
to store transform data. You do not need to multiply your vertex by a projection matrix. Interestingly, GLMatrix
in not even a matrix.
XFDraw uses a vector3/vec3 as its gl_Position
variable in the vertex shader.
XFDraw does not use NWC. After the vertex shader is executed, the triangles are clipped either in a perspective camera view frustrum, a orthograpic (rectangular prism) frustrum or a blended one. At this stage they are still in 3D camera space. Finally they are transformed from 3D to 2D coordinates.
To save memory bandwidth and improve bliting performance, XFDraw stores colors in BGRA format. While you can always store things in vec4
format and convert the values to BGRA afterwards before a blit operation, by default every demo utilizes byte4's.
You do not need to render a quad for a screenspace effect. To improve performance, you can just use the dedicated screenspace shaders, which have extra features for performance. It is combined with multiple in
support.
When you use the texture()
function, it will return your data based of the exact coordinates of the texture.
This is done like this so it would be faster to clear the depth buffer.
When working between your C# code and the shader code, many types are not exactly the same name. This was done so that the shader language was very similar to GLSL, but the C# side also was very similar to C#/Unity.
C++/GLSL Type | Size (Bytes) | C# Equivalent |
---|---|---|
byte4 |
4 | Color4 |
int |
4 | int |
float |
4 | float |
int2 |
8 | Not implemented |
vec2 |
8 | Vector2 |
vec3 |
12 | Vector3 |
vec4 |
16 | Vector4 |
mat3 |
36 | Matrix3x3 |
mat4 |
64 | Matrix4x4 |
GLMatrix |
56/Auto Cast | GLMatrix |
sampler1D |
Managed | GLBuffer |
sampler2D |
Managed | GLTexture |
samplerCube |
Managed | GLCubemap |
The last three items are managed, meaning that they the references to the GL classes are kept and those buffers are only locked when the Draw/Pass command is issued. This prevents writing to a buffer while it is being resized. GLMatrix
is auto cast to an internal type GLMat
which is 56 bytes in size.