Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Apr 26, 2024 11:32

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 10 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Many textures
BeitragVerfasst: Mo Dez 26, 2005 08:51 
Hi
i have to load about ~10000 sprites.
How to do it?? I tried with textures(512x512, 256 images per texture) i get about 42 textures, but when i load it into memory, program takes about 66MB! What should i do??


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Dez 26, 2005 10:37 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
10000 sprites are really much. I think the best way should be to load not all at ones. Load it if you need them. Otherway you should check if you can use some smaller texture format. Try to load RGBA4 instread of RGBA (8 Bit). If the sprite are gray then use GL_LUMINANCE instead GL_RGB.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Dez 28, 2005 12:02 
ok i did it whis way: i load bmpdata into arrays[3072 bytes each sprite]. It takes me about 30Mb, it's not so bad. But then i have problem. I crete textures when rendering, and memory using grows and grows... I should free texture after render, but how to do it??


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Dez 28, 2005 13:50 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
That's an very good question. I dosn't know your application so ich can't tell you the one and only 100 percent right answer. One thing you should never do. Dosn't create your texture every frame. You can create the texture for the sprites you need at this moment. Create twice isn't necessary. If you can group your sprites into regions could help. You entered region 1 (terrain like) sprites 1-2000 were loaded.

Try to find out what sprites you need and how long. For example. The sprite xy is used by 20 Objects. All objects were destroyed so you also can destroy the sprite. New object is creates so you must also create the sprite. If you can't count which sprites you need you also can use some time (30 seconds etc.). If isn't needed since 30 seconds you can free ist. But the best way is the reference count way. Count how many objects used the sprite.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Dez 28, 2005 14:13 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
I feel like I heared that it is faster to use allready allocated textures again, instead of deleating them and recreate. May Lossy can say something about that... 8) (or may vice versa. Im not sure... :oops: )

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Dez 28, 2005 14:26 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
If you trys to update some region of an Texture you should use the methode glTexSubImage2D. But if the size or internal format has changes and you must to use the methode glTexImage2D on an allocated texture its better to delete and regenerate it. So OpenGL dosn't must recycle the memory. They could easily free and reallocate the memory.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Dez 30, 2005 13:53 
ok i did it this way:
when it renders frame it cheks that sprite "z" is already loaded. If no then loads it. When i'm using this sprite i making "timestamp". Every "x" frames i check which sprites were'n use for "y" time and the unload them. Working very good. CPU usage is 0-5%(never was higher than 10%).

But i have one more problem:
I have to make sprites transparent when the color is ex. 255,0,255. Well, I need a mask. I cant create masks on start(data such as sprites) because memory using will be ~80MB. The question is: how "dynamic" create a mask??


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Dez 30, 2005 14:05 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
You can create mask before you upload texturedata such as at the begining. On small sprites the generation of an mask dosn't take much time.

What you're using to load textures? With my textureloader you easily can create an mask with the method AddAlphaFromColorKey. With other loaders we need to see some code.

To reduce your cpu usage you can run the check only one in a second. Or check it every frame but only 500 sprites. In the next frame the next 500 sprites (500-1000 etc). It gaves you smaller constant usage instead sometimes bigger usage.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Dez 30, 2005 14:10 
i'm using Jan Horn's unit to load textures. But now i'll test Yours one :wink:


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Dez 30, 2005 14:20 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
For some code look in our wiki. Use it in object oriented way. In the procedural way you can't add an mask.


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 10 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 31 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.111s | 17 Queries | GZIP : On ]