QB64 Phoenix Edition
OpenGL - GPU based rendering (GLList) - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7)
+---- Thread: OpenGL - GPU based rendering (GLList) (/showthread.php?tid=4009)



OpenGL - GPU based rendering (GLList) - Unseen Machine - 10-19-2025

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