Streaming command for texture?¿

Previous topic - Next topic

mentalthink

HI it´s possible make a stream for weight textures of images, for load in real time playing the game:

In example in some space of time load , a little portions of image, and in some place the image appears...

So I try sometimes to load an image, when I test the game, but in some cases the game stop a little time...

Of Course after appears the image, delete from the memory, and this mode, don´t overload the memory of the Devices

Crivens

If I understand you correctly do you mean like Id uses for either their current or next tech? Basically it doesn't matter on the hardware and the texture and model can be as big or as complicated as you like but the software will stream the textures (and auto-downgrade models I believe) based on the machine spec, a bit like Google Earth.

If so then phew would be great if it could be built into GLB. Wouldn't like to do it myself though!

Closest really would be to auto resize images to several sizes and then automatically decide which one to load based on an average FPS. Or if we have a memory command (dunno if we do) then also base on how much memory is left.

Complicated though and to be really clever would also need to unload already loaded textures and reload a smaller size if things got a bit heavier later on. ie. dynamically load the same textures at different sizes based on current circumstances. eg. you start off in a desert with a very detailed hi-res textured tank, but when you get to the big boss it automatically re-textures the tank with a low-res model to aid memory and speed. But only if it thinks your hardware cannot handle it at this current point. Beat the boss and he is unloaded so the hardware realises you are now capable of better graphics so re-textures the tank in hi-res. Hmmm pretty complicated to get the balance just right with loads of objects. Would be awesome though...

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

mentalthink

HI Crivens thanks for reply, well how you told, I´m not programmer, perhaps it´s too much complicated, make somthing like a stream... but I think it´s good mode, for have always very great amount of memory, and can load in real time defined textures or images, or perhaps 3d models, and music... well I only say becuase I think on it, but I don´t want in any time tell to GlBasic to do it, if it´s too much complex, or it´s something not intesting, well I forgot the idea.

Thanks Crivens.

Crivens

It's very interesting, and I for one would love it. If you read about how Id use a similar idea they say you can have textures as big as you like (100000x100000) and it will just stream them like Google Earth. So no matter what the device it will pretty much work at the same sort of speeds, and increase the quality of the graphics depending on how much the system is being hit. Very nice, but a bit next gen for me if at the level of Google Earth type streaming.

We did talk about something a lot simpler a while back. It was all based around the idea that you may want Retina graphics for the 4S but not for the 4 as maybe it wasn't powerful enough for your game (or even retina for 4 but non-retina for ipod4 because it has half the memory). Essentially you could then in project options state which device gets what resolution. From there you could then decide on the quality of graphics up front, and if we could access the memory we could also make a decision on the graphics to use.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

fuzzy70

#4
It is basically the way world of warcraft works. All audio, gfx (3d & 2d) are streamed so it gives you a seamless experience & if you have never seen the size of WoW maps then lets just HUGE. Only when you enter a completely diff continent or into a dungeon/raid etc then you see a loading screen, you can easily play for hours doing quests without seeing 1 loading screen other than the initial one.

Implementation of such a system is not that straight forward, am pretty sure one of the game engines I downloaded had some form of dynamic loading built in. Will have a look to see if I can find out which one it was.

Lee

check out http://mapwow.com/ for an example of the sheer size of WoW maps
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

erico

 :offtopic: reminds me of SWIV on the amiga...nice simultaneously loading data/playing code...no loading screens from beguinning to end...although the amiga disk drive would add its own share os sound effects :P


fuzzy70

Quote from: erico on 2011-Dec-06
:offtopic: reminds me of SWIV on the amiga...nice simultaneously loading data/playing code...no loading screens from beguinning to end...although the amiga disk drive would add its own share os sound effects :P

If you was scrolling in just 1 direction like SWIV then should not be to difficult to implement, rephrase that as "a bit easier to implement as you know whats coming"  :D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Slydog

It would be fairly easy to divide your world into tiles, and dynamically load the tile data when you are in a certain proximity, always seeing say 5 tiles around you.

The problem would be when loading the graphics for those tiles, your game would freeze for a bit while they load.

To eliminate the freezes you would need to implement 'threads', to load the image in the background.

Or, Gernot could add an option (or a new command?) to the LOADSPRITE command:
Code (glbasic) Select
LOADSPRITE bmp$, num%, is_asynchronous%=FALSE

If 'is_asynchronous' is true, then the command would return immediate control back to your program while GLBasic loads the image in the background.  A callback to let you know when finished would be nice, or an 'ISSPRITELOADED()' command to check if the loading is finished.

This would be good for music also, or any file.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

erico

Quote from: Slydog on 2011-Dec-06
It would be fairly easy to divide your world into tiles, and dynamically load the tile data when you are in a certain proximity, always seeing say 5 tiles around you.

The problem would be when loading the graphics for those tiles, your game would freeze for a bit while they load.

To eliminate the freezes you would need to implement 'threads', to load the image in the background.

Or, Gernot could add an option (or a new command?) to the LOADSPRITE command:
Code (glbasic) Select
LOADSPRITE bmp$, num%, is_asynchronous%=FALSE

If 'is_asynchronous' is true, then the command would return immediate control back to your program while GLBasic loads the image in the background.  A callback to let you know when finished would be nice, or an 'ISSPRITELOADED()' command to check if the loading is finished.

This would be good for music also, or any file.

+1  :good:

mentalthink

Thanks Slydog, very good solution.

A little thing, I don´t know If I expressed bad, or sorry, my English somtimes not it´s too good for undertood to yours.

Well I want to say, loas streaming but only in memory, not the image appears, like a youtube video (in this case image), only imagine, I have loaded 3 backgorunds, in the time between tohse bakcgrounds apeears, you are loading in memory (not in screen), the next image, or images or sounds, when the image it´s in memory completly loaded, then you can use, or not, depends the part on you want appears the image sound or graphics, but whit this mode, you don´t make a little stop, if you try to load somthing about 500kb, you can perceive a very little stop... for this my question....

Again sorry if this it´s waht you understood from the start of the post, how I say, my homebrew english somtimes it´s not enough.

Thanks,
Iván J

fuzzy70

Slydog's suggestion would definitely help with using such a system, the code to use I think would have to be specific to the type of game being coded. Like I said earlier a 1 direction scroller is easiest as you know what coming up, change that to a multiway scroller then the complications start creeping in as what if you are going up & start loading the next "up" graphic, then the player changes & goes east so you need the "east" graphic.

If it is just a texture or such for a new enemy that appears at a certain stage/score then that follows the 1 direction scroller example as you know whats coming up.

All of it is possible, just needs proper planning for the project in hand as I don't think you could write a generic "works in all examples" routine, may be wrong though.

One way you could possibly do it, depending on what you want to load/stream is rather than load the graphic in one go is read say 10% of it per game loop then MEM2SPRITE or whatever the case may be.

Again I may be totally wrong & barking up the wrong tree here  :whistle:

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

spacefractal

Skydog's I could use that too. I could use that for some lesser used images as well sound samples, to prevent unneeded pauses.

Streaming textures is today pretty normal. I remember even a old java game for ten years ago, I used that to download next level meantime you played on that level....
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Moru

Yes, Java and Javascript does this without you needing to do much. For this to work we need to be able to load files in another thread either by starting our own load-thread or just an option to the load command as suggested earlier.

Most online games does this with the world data over the internet and some does it with the textures and other data too. There is an old game engine called http://www.crystalspace3d.org. Written in c++ if I remember right. When I looked at that some years ago the examples were loading everything over the internet, you just downloaded a small exe-file to play.

Ofcourse, then I got GLBasic and then all thoughts of learning C went out the window. Oh, and so did my time for projects too :-)

ampos

Si te he entendido quieres cargar un gráfico/fondo mientras se está jugando, para tener preparado el próximo fondo a mostrar cuando se termine, no?

Zapp

#14
A simple way to do this in GLB could be to call a Function for every frame, but only load a specific amount of data each showscreen. Here is a quick example of what i mean. Without knowing exactly what your looking for this may or may not be helpful, but may give you some kind of idea. Loading 60 images over the course of 60 frames, will give the game/program a smoother appearance than the game "freezing" due to it taking several seconds to load all the images on a single showscreen call.

GLOBAL GameRunning = TRUE
GLOBAL GraphicsLoaded = FALSE
GLOBAL Imagetoload% = 0
GLOBAL Filenames$[]; DIM Filenames$[16]

Filenames() //Put File Names into an array

While Game Running = TRUE     //Main Loop
IF GraphicsLoaded = FALSE THEN LoadData()

Main Program Code

WEND
END

FUNCTION FileNames:   //Filename function

//Put the names of the file you want to load into the array here
For i = 0 to 15
  Filenames$ = "Background" + i
Next

ENDFUNCTION

FUNCTION LoadData:

LOADSPRITE "Media/"+ Filenames$[ImagestoLoad%] + ".png", ImagestoLoad%
INC ImagestoLoad%   //increase the global integer for next frame
IF ImagestoLoad% = 15 THEN GraphicsLoaded = TRUE

ENDFUNCTION