Here's a bit of a "Yay" moment;
Ages ago my first attempt at OpenGL rendering in RM started with drawing a triangle to the title screen, well now I can draw anything.
This is a test of the mesh rendering API I've been working on.
Here's a rundown of how it works;
Supports texturing as well, so you can slap a bitmap onto whatever mesh you want to draw.
Next step is to write a simple matrix API so that mesh can be transformed about the screen, then version 1.0 is ready.
Ages ago my first attempt at OpenGL rendering in RM started with drawing a triangle to the title screen, well now I can draw anything.
This is a test of the mesh rendering API I've been working on.
Here's a rundown of how it works;
Ruby:
#--------------------------------------------------------------------------
# * Initialise
#--------------------------------------------------------------------------
# Set how vertex data is read by shader
shader_material.SetAttributeIndex( "vertex_position", 0 )
shader_material.SetAttributeIndex( "vertex_colour", 1 )
# Make mesh in memory [ x, y, r, g, b ]
cpu_mesh = [ -0.5, -0.5, 1.0, 0.0, 0.0,
0.5, -0.5, 1.0, 1.0, 0.0,
0.5, 0.5, 0.0, 1.0, 0.0,
-0.5, 0.5, 0.0, 0.0, 1.0 ]
# Upload mesh to GPU memory as Vertex Buffer Object
gpu_mesh = VertexBuffer.Alloc
gpu_mesh.UploadVertexArray( cpu_mesh )
gpu_mesh.DescribeBuffer( 4, [2, 3] ) # 4 vertices with 2 positions and 3 colours
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
# Activate shader
shader_material.UseProgram
# Render VBO as a triangle fan
gpu_mesh.DrawArrays( VertexBuffer::DRAW_TRIANGLE_FAN )
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
# Destroy vertex memory on GPU
gpu_mesh.Dealloc
Supports texturing as well, so you can slap a bitmap onto whatever mesh you want to draw.
Next step is to write a simple matrix API so that mesh can be transformed about the screen, then version 1.0 is ready.