Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Destroying Textures to free system resources  (Read 18709 times)
0 Members and 2 Guests are viewing this topic.
Offline uberscott

Senior Newbie




Java games rock!


« Posted 2006-12-02 04:47:59 »

Is there a method to remove/destroy textures to free their system resources?

Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #1 - Posted 2006-12-02 13:15:52 »

Is there a method to remove/destroy textures to free their system resources?

I fear, there isn't Sad. But it shouldn't be hard to implement that. So far you can only waste the whole cache, I remember right. Let's see what other folks say... Then I could implement such a method.

Marvin
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #2 - Posted 2006-12-02 15:12:24 »

Is there a method to remove/destroy textures to free their system resources?
Marvin meant, there isn't *yet* such a possibility Smiley

I guess it must be done on several levels : when a texture loads, first it gets opened by a sun standard image loader, then it's copied in a byte buffer then transferred on the graphic card (opengl texture creation). So it should be freed on the graphic card, not only from the cache, right ? Removing a texture from the cache is really easy. I could provide a method if you wanted.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #3 - Posted 2006-12-02 15:15:39 »

Marvin meant, there isn't *yet* such a possibility Smiley

Of course. Thanks. Sorry for being unprecise Smiley.
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #4 - Posted 2006-12-02 15:28:34 »

So uberscott, do you want to free RAM or VRAM ? In the first case, removing them from the cache would be ok. In the second case, we would call glDeleteTextures

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #5 - Posted 2006-12-02 15:42:23 »

So uberscott, do you want to free RAM or VRAM ? In the first case, removing them from the cache would be ok. In the second case, we would call glDeleteTextures

Just my 1 cent: A Texture object should receive an OpenGL texture handle (like RenderAtom) whan it gets rendered by OpenGL. Then a method markDeleted() should be called (or something like that) so that the renderer can delete it from VRAM. The markDeleted() method should also delete it from Texture cache. And an UnsupportedOperationException should be thrown, if the markDeleted() method is invoked on the fallback-texture.
Don't know, if texture handles can be retrieved from OpenGL, just my 1 cent... Smiley

Marvin
Offline uberscott

Senior Newbie




Java games rock!


« Reply #6 - Posted 2006-12-02 21:27:22 »

I need to free resources from VRAM and RAM. 

I am painting chat messages to a BufferedImage then creating a texture from that. 

I have tried using the SwingGUI for chat messages but the performance is quite bad.  Maybe Text2D objects could be used, but I am having trouble understanding if they actually support word wrapping etc.

If a Texture's contents can be replaced, that word work for me as well. In that case I could store about 10 textures and recycle them as needed.

Anyway, having a method to destroy/uncache individual unused textures seems like a good idea to me.  Please let me know where i can get the new code! 

Thanks guys!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #7 - Posted 2006-12-02 22:19:34 »

Please use the HUD. Examples can be found in org.xith3d.test.ui.HUD3DTest. It doesn't support this texture freeing, but texture recycling. And I could inclide texture wasting transparently (without changing the API). Then you would directly benefit from that without changing your code.

BTW: Text2D supports wrapping. Just insert a '\n' into your String and the line will be wrapped. The same for a Label Widget on the HUD.

Marvin

EDIT: I seem to have made something wrong in the MD2LoaderTest, which is also used in HUD3DTest. So the HUD is not visible. But it works. It's just a problem of the MD2Test. I'll fix it tomorrow. But as I said the HUD works. You can also see it in org.xith3d.test.loaders.BSPLoaderTest (working). And it is documented in "Xith3D in a Nutshell" (XIN) downloadable on xith.org (doc section).
Offline uberscott

Senior Newbie




Java games rock!


« Reply #8 - Posted 2006-12-02 22:44:22 »

I'm still having problems getting the Label text to be properly positioned.... otherwise I would use the hud.  Has the label positioning code been fixed in the current dev version?
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #9 - Posted 2006-12-02 22:54:19 »

I'm still having problems getting the Label text to be properly positioned.... otherwise I would use the hud.  Has the label positioning code been fixed in the current dev version?

If I remember right there was something I fixed some time ago. Should work completely now. Do you know the possibility of alignment on a Label? Don't know, if it was already implemented in 0.8.0.

Marvin
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline hawkwind

Junior Member




Java games rock!


« Reply #10 - Posted 2006-12-03 03:21:29 »

Do labels really respect \n or not.  I have not been able to do this.  I see in the Images section of the example HUD you use a special case where the dimension is set to 1 or 0 which causes some kind of auto size formatting

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
   /**
     * Creates a new Label with the given width, height and z-index.
     *
     * @param size the new size of this Widget
     * @param zIndex the z-index of this Widget
     * @param text the text to display in this TextWidget
     * @param font the Font to be used for the text
     * @param color the color to be used
     * @param alignment the horizontal and vertical alignment
     */

    public Label(Tuple2f size, int zIndex, String text, Font font, Color3f color, TextAlignment alignment)
    {
        super(size, zIndex);
       

        this.autoSize = ((size.x <= 0f) || (size.y <= 0f));
     
1  
2  
   this.size.x = Math.max( size.x, 0f );
        this.size.y = Math.max( size.y, 0f );


Uber...are you creating new BufferImage every time or extracting the ImageComponent2D and modifying the exisiting, assoicated BufferedImage??

Quote
I am painting chat messages to a BufferedImage then creating a texture from that. 
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #11 - Posted 2006-12-03 03:37:42 »

EDIT: I seem to have made something wrong in the MD2LoaderTest, which is also used in HUD3DTest. So the HUD is not visible. But it works. It's just a problem of the MD2Test. I'll fix it tomorrow. But as I said the HUD works.

Fixed. Was an easy one-line-fix Cool.

Marvin
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #12 - Posted 2006-12-03 03:42:45 »

Do labels really respect \n or not.  I have not been able to do this.  I see in the Images section of the example HUD you use a special case where the dimension is set to 1 or 0 which causes some kind of auto size formatting

Autosizing has nothing to do with line wrapping. The size of a Label is irrelevant, if you don't want to position the text exactly.

See line #511 in HUD3DTest:
1  
Button aciButton = new Button(170, 130, "Another\ncool\nbutton",


Well, this is a Button, but it's exactly the same, since, a Button contains a Label. It really works Wink.

Marvin
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #13 - Posted 2006-12-03 19:56:52 »

I have done the Texture-removal-from-VRAM thing. There's a new method in the Texture class called markDeleted(). Invoke this method and it will be deleted from RAM/VRAM. Well I haven't done the removal-from-RAM thing, since the texture cache is somewhat strange. I can't see, why not a simple Hashtable is used there Huh. Amos, are you familiar with the cache? If you're, please have a look at the cache. I have added a remove() method to org.xith3d.utility.cache.ResourceCache with an empty body. There's TODO, which you may easily find. If you're not familiar with it, then I'll continue fighting with it Wink.

BTW. Most of the glDeleteTextures thing was already there. It just wasn't used except a Texture was modified in place, which is certainly very rare.

Marvin
Offline uberscott

Senior Newbie




Java games rock!


« Reply #14 - Posted 2006-12-03 21:19:44 »

I would rather use Label instead of creating an on the fly texture... but in release 0.8.0 Text2D seems to have issues with the fonts.  They are not legible and there seems to be additional space between each of the characters.  Have these issues been resolved?  If so, I will probably get the latest version from SVN.

Thanks for adding the delete feature in the texture, there are other places where i need it too!
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #15 - Posted 2006-12-03 21:32:23 »

I would rather use Label instead of creating an on the fly texture... but in release 0.8.0 Text2D seems to have issues with the fonts.  They are not legible and there seems to be additional space between each of the characters.  Have these issues been resolved?  If so, I will probably get the latest version from SVN.

Yes, these ones have definitely been fixed.

Thanks for adding the delete feature in the texture, there are other places where i need it too!

You're welcome Smiley.

Marvin
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #16 - Posted 2006-12-03 21:38:36 »

I'm currently working on a new StaticLabel Widget, which will be a lot faster for static text contents (or even for not very fluctuative contents).
I've written a new method in TextureCreator, which creates a Texture with a text drawn on it. This is then used for the StaticLabel. The regular Label Widget has a disadvantage, that it is rather slow, but highly flexible. But in many cases on a game's HUD, you'll want to use mostly static texts and benefit from the speed-up.

Marvin
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #17 - Posted 2006-12-04 21:33:57 »

I'm currently working on a new StaticLabel Widget, which will be a lot faster for static text contents (or even for not very fluctuative contents).
I've written a new method in TextureCreator, which creates a Texture with a text drawn on it. This is then used for the StaticLabel. The regular Label Widget has a disadvantage, that it is rather slow, but highly flexible. But in many cases on a game's HUD, you'll want to use mostly static texts and benefit from the speed-up.

done Smiley
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #18 - Posted 2006-12-05 21:06:44 »

I would rather use Label instead of creating an on the fly texture... but in release 0.8.0 Text2D seems to have issues with the fonts.  They are not legible and there seems to be additional space between each of the characters.  Have these issues been resolved?  If so, I will probably get the latest version from SVN.

Thanks for adding the delete feature in the texture, there are other places where i need it too!
I would almost always advise to run the latest SVN version..

But on the other time, maybe it's time for another release ? So who's for 0.9.0 ? (Note : I'm assigned to release tasks so just ask).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #19 - Posted 2006-12-05 21:18:12 »

I have done the Texture-removal-from-VRAM thing. There's a new method in the Texture class called markDeleted(). Invoke this method and it will be deleted from RAM/VRAM. Well I haven't done the removal-from-RAM thing, since the texture cache is somewhat strange. I can't see, why not a simple Hashtable is used there Huh. Amos, are you familiar with the cache? If you're, please have a look at the cache. I have added a remove() method to org.xith3d.utility.cache.ResourceCache with an empty body. There's TODO, which you may easily find. If you're not familiar with it, then I'll continue fighting with it Wink.

BTW. Most of the glDeleteTextures thing was already there. It just wasn't used except a Texture was modified in place, which is certainly very rare.
Well a Hashtable isn't used because it has hard references, which means if you load lots of textures at once, it will never delete the already cached ones (it will rather crash by memory lack than to free them). Cache has soft references. Having a remove method shouldn't be hard. I look at it right now.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #20 - Posted 2006-12-05 21:25:42 »

I would almost always advise to run the latest SVN version..

But on the other time, maybe it's time for another release ? So who's for 0.9.0 ? (Note : I'm assigned to release tasks so just ask).

I thought about this today, too. But I'm more for a 1.0-beta release.

I guess, when the model loaders are all ported (btw. Could you please port the Cal loader, Amos?), the HUD is ready (List, ComboBox, TextField) and Terrain code is complete, the API is stable. Then we should release a 1.0-beta1.

I also thought about modifying the download section on xith.org. There shoud be three versions for download: "current stable release", "current beta release" and "community build release". I think we should build a community buld release very soon, so that people can make use of the current API and features. And as a careful guess I think we should be able to release the first beta of 1.0 this year.

What do you think?

btw. I have concrete imaginations about hte new download section and would like to design it. I hope I can do this this night together with the community build release.

Marvin
Offline hawkwind

Junior Member




Java games rock!


« Reply #21 - Posted 2006-12-06 01:57:51 »

I would suggest a short term poll of users first to identify any killer problems prior to a release.  the failures of the OBJ loader is a killer problem.
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #22 - Posted 2006-12-06 02:36:14 »

I would suggest a short term poll of users first to identify any killer problems prior to a release.  the failures of the OBJ loader is a killer problem.

Yes, it is. And I'll now have a look at it. But this is not a problem of the API, but implementation. And it is exactly, why I suggested to first release a beta version with a stable API and when we sorted out all the implementation bugs, then we can release a final version.

Marvin
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #23 - Posted 2006-12-06 18:46:31 »

I thought about this today, too. But I'm more for a 1.0-beta release.

I guess, when the model loaders are all ported (btw. Could you please port the Cal loader, Amos?), the HUD is ready (List, ComboBox, TextField) and Terrain code is complete, the API is stable. Then we should release a 1.0-beta1.

I also thought about modifying the download section on xith.org. There shoud be three versions for download: "current stable release", "current beta release" and "community build release". I think we should build a community buld release very soon, so that people can make use of the current API and features. And as a careful guess I think we should be able to release the first beta of 1.0 this year.

What do you think?

btw. I have concrete imaginations about hte new download section and would like to design it. I hope I can do this this night together with the community build release.

Marvin
Please explain differences between "stable", "beta", and "community". I think these names aren't really appropriate. I like Mandriva's naming : "cooker", "community", "official".
"Cooker" means Warning ! it's very likely to contains bugs of all sort but on the other hand you have the latest and greatest features, and can report bugs quickly..
"Community" means it's reasonably stable, though you don't have lots of things to adjust for each release, it's nearly stable, no feature in "community" is newer than eg. ~2 weeks (of use)...
"Stable" means that you can use it for your game release : it has been thoroughly tested with several community releases with less and less bugs.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #24 - Posted 2006-12-06 19:55:16 »

Please explain differences between "stable", "beta", and "community". I think these names aren't really appropriate. I like Mandriva's naming : "cooker", "community", "official".
"Cooker" means Warning ! it's very likely to contains bugs of all sort but on the other hand you have the latest and greatest features, and can report bugs quickly..
"Community" means it's reasonably stable, though you don't have lots of things to adjust for each release, it's nearly stable, no feature in "community" is newer than eg. ~2 weeks (of use)...
"Stable" means that you can use it for your game release : it has been thoroughly tested with several community releases with less and less bugs.

Well, names can be discussed Smiley.

stable = stable API, tested, can be used in games
beta = stable API of the coming stable release, but not totally bugfree
community = very fresh build from SVN. Latest and greatest features

I think, "stable" and "beta" are very common names for what it is meant to be and should be used. OK, "Community" is not so common and Cooker is ok. Some projects use "unstable" for this, which says exactly what it is, but doesn't encurage users to try it out. So Cooker is better. "Alpha" would be anther good solution. If nobody has a better idea, I think, we can use "stable", "beta" and "alpha" or "Cooker".

Marvin
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #25 - Posted 2006-12-06 21:02:42 »

I'm for "stable", "community" and "cooker".
"alpha" and "beta" terms refer to a linear progression in one's program releases. You have pre-alpha, beta, and then final release. Xith3D is being developed as lots of small cycles.

Well, just my 2cents, what do the others think ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #26 - Posted 2006-12-07 00:44:44 »

I'm for "stable", "community" and "cooker".
"alpha" and "beta" terms refer to a linear progression in one's program releases. You have pre-alpha, beta, and then final release. Xith3D is being developed as lots of small cycles.

Well, just my 2cents, what do the others think ?

But "community" does not mean, what I want to achive with this release. A beta version is a version "promising" to include all the functionality the final version will include. But is not fully tested and not fully bugfree. We need such a version. We can test everything on our own, but will never find any bug. Only by encuraging people to use this version (and not the latest stable), all bugs can be found. Beta also means "almost ready and more features than the latest stable".

Maybe it sounds like we need four versions: "stable", "beta", "community", and "cooker". But who wants to maintain all these versions Huh And everybody would be confused by all these versions. So three are just enough. And we will certainly continue to develop the way we did: Just code everything we want and once decide to to release the current code. Only by doing this beta stuff to encurage users to try the version we can get a branch really stable.

So I am for: "stable", "beta" and ("alpha" | "Cooker" | "Community").

Marvin
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #27 - Posted 2006-12-07 19:35:17 »

OK so I am for "stable", "beta", and "cooker".

I modified the site, have a look

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #28 - Posted 2006-12-07 20:41:11 »

OK so I am for "stable", "beta", and "cooker".

I modified the site, have a look

Wow. looks just great. Except one thing. The sidebar is not wide enough the display all the content in it without overlapping. Maybe the sidebar needs to be made wider. And is it possible to make the page take the whole screen width? I hate pages being fixed to 800er width. Our audience is not built by our grandmas using with an 800x600 resolution. Having with=screen-width would espeacially help in the board.

Marvin
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #29 - Posted 2006-12-07 22:03:00 »

Wow. looks just great. Except one thing. The sidebar is not wide enough the display all the content in it without overlapping. Maybe the sidebar needs to be made wider. And is it possible to make the page take the whole screen width? I hate pages being fixed to 800er width. Our audience is not built by our grandmas using with an 800x600 resolution. Having with=screen-width would espeacially help in the board.
I'll see what I can do with the template file (may be easy, may be hard, you never know..)...

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!