Posted 24 February 2016 - 01:54 AM
This is a very simple 3D graphics library, nothing too impressive, but still worth sharing.
You render in it by just clearing the screen, providing a vertexarray to your vertexgl object and specifying UV coordinates (!) if you want.
There are also vertex and fragment shaders which are functions executed on each vertex received and each pixel drawed (respectively), used to alter the vertex position (For cameras and such) and pixel color (For anything really).
The (!)s are because textures aren't working as I don't have any UV coordinate calculation algorithm. I've searched a lot and couldn't find a working one, and I came up with one some time ago but i didn't save it so it's gone.
The file also includes vec3, vec4, quaternion, mat4x4 and vertexarray.
Current functions:
Sets the size of the screen to render to.
ortho(left, right, bottom, top, near, far)
Sets up an orthographic projection matrix (applied automatically).
perspective(fov, ratio, near, far)
Sets up a perspective projection matrix (applied automatically). Ratio should be 1 for stretched rendering and width / height for perfect pixels.
clear(color (optional))
Clear the rendering buffer. If the color is not specified, it will default to black.
draw(vertexarray)
Draws the specified vertexarray object to screen.
genTexture(width, height, pixels)
Returns a texture object with the specified properties.
bindTexture(texture)
Makes all subsequent texture operations be on the specified texture.
unbindTexture()
Same as bindTexture(nil). Binds a nil texture.
The GitHub repository for it includes VertexGL itself and a test program which loads that classic Blender monkey from an .obj file and draws it:
https://github.com/jv110/VertexGL
You render in it by just clearing the screen, providing a vertexarray to your vertexgl object and specifying UV coordinates (!) if you want.
There are also vertex and fragment shaders which are functions executed on each vertex received and each pixel drawed (respectively), used to alter the vertex position (For cameras and such) and pixel color (For anything really).
The (!)s are because textures aren't working as I don't have any UV coordinate calculation algorithm. I've searched a lot and couldn't find a working one, and I came up with one some time ago but i didn't save it so it's gone.
The file also includes vec3, vec4, quaternion, mat4x4 and vertexarray.
Current functions:
Spoiler
viewport(width, height)Sets the size of the screen to render to.
ortho(left, right, bottom, top, near, far)
Sets up an orthographic projection matrix (applied automatically).
perspective(fov, ratio, near, far)
Sets up a perspective projection matrix (applied automatically). Ratio should be 1 for stretched rendering and width / height for perfect pixels.
clear(color (optional))
Clear the rendering buffer. If the color is not specified, it will default to black.
draw(vertexarray)
Draws the specified vertexarray object to screen.
genTexture(width, height, pixels)
Returns a texture object with the specified properties.
bindTexture(texture)
Makes all subsequent texture operations be on the specified texture.
unbindTexture()
Same as bindTexture(nil). Binds a nil texture.
The GitHub repository for it includes VertexGL itself and a test program which loads that classic Blender monkey from an .obj file and draws it:
https://github.com/jv110/VertexGL
Edited on 24 February 2016 - 01:05 AM