Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OpenGL - GPU based rendering (GLList)
#1
Yo gang...

From MasterGy's question in another thread GPU based rendering is now a thing im really looking into/learning about but still no working (modern GL) versions to show yet! In the meantime...though very old and considered outdated GLLists does work! 

Using it for animated models is not suggested but for anything static in your game, i.e, terrain, sky sphere/boxes, trees, rocks, etc...it's really useful 

The main joy is you can make lists that call lists! This way rather than have separate lists for a skysphere and terrain, you can have ONE for the whole world! You can then easily extended this to adding trees, buildings, etc...

The second joy is you can also easily combine the loading of assets and list creation into one function...

Base Function : 
Code: (Select All)
FUNCTION Make_List~&


'// Load things here

  TmpList~& = _GLGENLISTS(1) '// Generate a temp handle for a single list
  _GLNEWLIST TmpList~&, _GL_COMPILE '// Start making the list

  '// YOU RENDER HERE
  '// Draw everything thats static once and make a GPU procompiled list!
  '// Then use glcalllist to draw it all...it renders much faster this way

  _GLENDLIST '// Finihsed everything so stop making the lists

  '// Return the GLList handle as _unsigned long (Remeber to chnage to match your actual function name)
  Make_List~& = TmpList~&

END FUNCTION

You will off course need to change the function name for each thing you want to make as a list in your program, remember to change the return value at the end of the function to match!

DEMO :  in my dev program this modded version of that function returns a handle (as _unsigned long) for a world (sky and terrain)

Code: (Select All)
FUNCTION GDK_GL_Make_World_List~&

  goodmap% = GDK_GL_Terrain_Load(Terrain, "Hill_HMap.png", "Hill_Texture.png", 90, 3900)
  Terrain.Position.X = (Terrain.Width / 2) * Terrain.Scale.X
  Terrain.Position.Z = (Terrain.Height / 2) * Terrain.Scale.Z
  Terrain.Position.Y = -4200 ' Adjust terrain base position
  TList~& = GDK_GL_Terrain_Make_List(Terrain)

  Sky& = GDK_GL_Load_Texture("Sky.png")
  SkyList~& = GDK_GL_CreateSphereList(15000, 200, 200, Sky&)

  TmpList~& = _GLGENLISTS(1)
  _GLNEWLIST TmpList~&, _GL_COMPILE

  ' === RENDER TERRAIN ===
  _GLPUSHMATRIX
  _GLLOADIDENTITY
  _GLTRANSLATEF 0, Terrain.Position.Y, 0
  _GLCALLLIST TList~&
  _GLPOPMATRIX

  '=== Render Sky sphere ===
  _GLPUSHMATRIX
  _GLLOADIDENTITY
  _GLROTATEF 180, 1, 0, 0
  _GLCALLLIST SkyList~&
  _GLPOPMATRIX

  _GLENDLIST '// Finihsed everything so stop making the lists

  GDK_GL_Make_World_List~& = TmpList~&
END FUNCTION

to create it :         World~& = GDK_GL_Make_World_List~& '// Sky and terrain are created once and stored as a single list

to render it :         _GLCALLLIST World~& '// Draw the terrain and the sky

As you'll see it calls two other variants of the MAke_List function for the terrain and sphere...(as i said, lists inside lists!)

Anyway, hope you guys find it useful or at least informative.

Unseen
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Triangle-Based Collision Detection Herve 3 453 11-01-2025, 01:37 AM
Last Post: Unseen Machine
  Pixelling OpenGl TempodiBasic 3 933 03-20-2025, 02:04 AM
Last Post: vince
  3D rendering of Game of Life by ubi44 bplus 3 1,274 02-16-2024, 02:50 AM
Last Post: bplus
  Simple Rummy-based game PhilOfPerth 3 1,124 11-24-2023, 11:23 PM
Last Post: PhilOfPerth
  A GradeBook demo based on NasaCow UDTs and ideas TempodiBasic 6 1,537 04-20-2023, 05:36 AM
Last Post: NasaCow

Forum Jump:


Users browsing this thread: 1 Guest(s)