#not able to load texture when in thread
1 messages · Page 1 of 1 (latest)
oh, so how would i go about making a loading screen then?
because if i load everything, the game wont go to its next iteration untill everything is loaded
only the gl part has to be in the main thread
but other than that, you would have to split the loading work
aha, meaning i need to call every texture load before the game even started? (which sounds obvious, but enums make that really anoying)
you need to load the textures before it started
but for textures for example you can load an image in any thread
then LoadTextureFromImage in the main thread
yea that XD
but then enums are really anoying, they only initialize when you call them, meaning that i need to call every enum before even starting the update loop (or in the first iteration, but same thing)
what enums?
its like a class you define once (like any other)
but at the top of that class you make all the instances that exist of that class
This is really handy for textures, its kinda like a lot of singletons grouped together
in this screenshot for example, there is the class Textures.
that has a string as parameter (a path to the file)
this then inits the class with that texture
then you can write Textures.ITEM_APPLE and you have that instance
but the problem is that it wont load that instance untill it is accesed once
you don't have to load them all at startup, but you do have to upload the texture data to the GPU in the main thread.
you can trickle them in as needed
you don't have to block and load them all in the same frame
also I don't know when that code is run. at startup?
I literally just made test on this 😁. I just made simple system where delta time is the amount of time it has to load stuff at a time. Here is my Lua code if it helps. # in front of var means the amount on items the array has if you are not familiar with Lua.
if #textures < #files then
local loadTime = os.clock() + delta
while #textures < #files and os.clock() < loadTime do
table.insert( textures, RL.LoadTexture( files[ #textures + 1 ] ) )
end
maybe delta should be replased with fixed value.
everytime when i change scene group
(and a scene group is also something i made lol.
the gamemanager always continues its loop by calling the loop inside a 1 scene (the one that is currently active).
to switch from scene i just swap them if they are in the same group
if they are not a new scene group gets loaded. and this is that loadfunction at the top
(this system is a bit like ship of fools. Once in spawn you are at spawn, the sapwn scene group is currently there.
if you then go at sea, the first sea group gets loaded. But switching scenes in that same sea wont need any loading, just enabeling is enough. Loading was done at the start of the group) and then when switching from sea A to sea B. you change the group again