Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

The Screenshot Thread

Status
Not open for further replies.
Here's a bit of a "Yay" moment;
4ShcIp9.png


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.
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top