hey
im trying to write a decent resource loader for my engine. im pretty much done but i have one problem that i cant seem to find any way around
my resource loader loads resources at the same time my render thread is rendering... and as far as i know theres no way to make GL calls on 2 threads at the same time (althouh i hope im wrong)
how can i make my setup work?
any ideas?
Thnx in Advance!
My approach is:
OpenGL thread:
Allocate VBO, PBO
Map VBO, PBO to direct buffer (ByteBuffer)
Other thread:
Load data into the mapped buffers
OpenGL thread:
Release the mappings
Use the loaded stuff
Not just you can load in multiple threads this way, but you are loading into OpenGL managed memory directly, without the need for OpenGL to copy the data itself. The drawback is that once loaded into the mapped buffers, you cant access those data from Java any more without getting a performance hit.
that sounds feasible since i never touch the data in my VBO after its loaded anyway
il try it. thnx.
actualy ive just thought of another possible solution but this invloves switching contexts at most twice per frame.
my question is: how costly is Display.releaseContext(); and Display.makeCurrent(); can i safely use them to switch from and back to my rendering thread at most each frame?
you could of course always try it - but afaik, its very costly.
il figure something out
since the game im creating with my engine relies heavely on billboards instead of actual models i might get away with it performance wise
else il just do what veAr suggested
Thnx!