• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Yago

libGDX texture load problem

11 posts in this topic

Hello, this is my first post here. At least, I think it is.

 

I'm developing a 2D game with libgdx. I have a PNG that contains the animation sheet for the player character. Naturally, it has transparency. At first, it was 8192*4096, but I needed to add bigger animations that didn't fit in 8192 pixels. So I increased the width to 16384.

 

That's when the problem started: some exception popped up in an irrevelant part of the code. I made sure that THAT part wasn't faulty, and tracked the problem to the Texture object. libgdx refuses to load that image to GPU. No exceptions or anything about this, I just have a null Texture object. The weird thing is that it DOES work if I modify the PNG to one that doesn't have transparency.

 

So if I have a PNG that's 8192 pixels wide, it works, transparent or not. But if the PNG is 16384 pixels wide, it doesn't work if it has transparent pixels. What's up with that?

0

Share this post


Link to post
Share on other sites

Modern cards support many compressed formats, but png is not one of them. Likely you have decompressed the data and pushed it to memory.

 

You are attempting to push 268 megabytes into a single texture.

 

You might have better luck with a dxt4/dxt5 compressed image.

 

It is possible to create a megatexture atlas, but it requires some work to actually implement. 

0

Share this post


Link to post
Share on other sites


You are attempting to push 268 megabytes into a single texture.

 

The PNG seems to be taking up 1,41 MB of space on my drive. Or do you mean that it goes through some sort of decompression process which results in the image being 268 MB?

 

Anyway, I installed the .dds plug-in for my CS4, but it didn't save the file as a .dds no matter what I tried. Do you know of another method instead of dxt compression?

0

Share this post


Link to post
Share on other sites


The PNG seems to be taking up 1,41 MB of space on my drive

It’s not a run-time-compressed format, so it doesn’t matter how much it takes up on your drive.  It consumes 8,192×16,384×4=512 megabytes of GPU memory.

 

I don’t know that size is the issue here though because it will consume the same amount of GPU RAM whether it is RGB or RGBA, but the layer of software that is decompressing it may be running out of memory or something during load and not telling you.

I don’t know libGDX but any library worth its weight in salt should have a way to print or retrieve error messages.

 

frob suggested DXT compression which would be another way to go, and it probably will solve your problems in the long run.

 

I happened to have written one: http://lspiroengine.com/?p=516

Run it with the command line:

lsdxt -file "C:/PATH/MyImage.png" -dxt5 -quick

 

You have a large file, so it will take time.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites


I happened to have written one: http://lspiroengine.com/?p=516

Run it with the command line:

lsdxt -file "C:/PATH/MyImage.png" -dxt5 -quick

 

It worked with some random image I picked that was 1024*1024, but not with the 16384*4096 image that I need. The error is "Failed to open image <file>." Which leads me to think that my image might be corrupted in some way.

0

Share this post


Link to post
Share on other sites


It worked with some random image I picked that was 1024*1024, but not with the 16384*4096 image that I need. The error is "Failed to open image ." Which leads me to think that my image might be corrupted in some way.

 

Are you sure this doesn't have anything to do with Java's heap size being too small to load the image into memory?  Try adjusting the minimum and maximum heap sizes:

 

-Xms128m -Xmx256m

 

Anytime you try to load anything in memory, such as a very large image, but you haven't allowed the max heap size to grow, you'll get weird errors.

0

Share this post


Link to post
Share on other sites


Try adjusting the minimum and maximum heap sizes:

-Xms128m -Xmx256m

 

Also tried with other values like 512|1024. Didn't have an effect.

0

Share this post


Link to post
Share on other sites


At this point, I would try just making a test main() method and try loading the image with the ImageIO class.

 

Yup, the console told me about an out of memory exception when I used ImageIO. But I still can't get the program to run. I set the heap size, it's not enough to make a difference. And Eclipse can't create VM if I increase it. Does it have to be powers of 2?

0

Share this post


Link to post
Share on other sites

Convert the image to .TGA and use it in my program again to create a .DDS.

And also try loading the .TGA directly.

Also if you send me the image I can debug it to see what caused it to fail specifically.

 

 

L. Spiro

Edited by L. Spiro
0

Share this post


Link to post
Share on other sites

Quick question... why are you using a texture instead of TextureAtlas? If you are simply trying to do a sprite sheet, I recommend giving a TextureAtlas a quick try, then using the findRegion method to load in your texture regions... 

There is a nice texturepacker available... https://code.google.com/p/libgdx-texturepacker-gui/'

Very easy to use, just point it at a folder and go. Then make AtlasRegions based off of name of texture and index. May need to rotate if it was rotated... [edit:easier when starting just not to let the packer pack it rotated, but it does make smaller files...]

 

Haven't ever tried that large of a texture, but I believe this is the recommended route by libgdx.

 

Anyway, it probably is a memory issue as mentioned. As the TextureAtlas can have many textures put together but easily accessed, I recommend giving it a try really quickly.

Seems that they recently moved to gethub, so not sure where the reference I was going to give about this was.

Edited by tisdadd
0

Share this post


Link to post
Share on other sites


And also try loading the .TGA directly.

Also if you send me the image I can debug it to see what caused it to fail specifically.

 

Didn't make a difference. And I sent a message with the links to the files.

 


Quick question... why are you using a texture instead of TextureAtlas?

 

Because I didn't know about TextureAtlas before, and the player character's texture is pretty much the ONLY texture in the game at this stage. Hehe.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0