Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX image constraints  (Read 1080 times)
0 Members and 1 Guest are viewing this topic.
Offline kingroka123

JGO Knight


Medals: 29
Projects: 5
Exp: 1 year


Gamer's Helmet


« Posted 2013-07-11 20:45:26 »

You know how in libGdx where texture dimensions can only be in the power of two? How can i get around or get rid of that. thanks

Offline alaslipknot
« Reply #1 - Posted 2013-07-11 21:03:56 »

by enabling openGl 2.0
1  
cfg.useGL20 = true;

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Offline kingroka123

JGO Knight


Medals: 29
Projects: 5
Exp: 1 year


Gamer's Helmet


« Reply #2 - Posted 2013-07-11 21:11:18 »

by enabling openGl 2.0
1  
cfg.useGL20 = true;


It's already enabled.

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

JGO Coder


Medals: 14


L___ o_ G___ a__ P___


« Reply #3 - Posted 2013-07-11 21:42:07 »

Why do you need to get rid of it? Just for convenience, or for a more functional reason?

Because I do find it inconvenient, but one can always just crop the region of the texture needed inside the program.

Offline kingroka123

JGO Knight


Medals: 29
Projects: 5
Exp: 1 year


Gamer's Helmet


« Reply #4 - Posted 2013-07-11 23:41:17 »

Convenience mostly

Offline heisenbergman

JGO Coder


Medals: 14


L___ o_ G___ a__ P___


« Reply #5 - Posted 2013-07-12 01:12:47 »

I see. Well I'm not sure myself how to get rid of it, so I just store my images in a bigger file (like, I store my 40x24 texture in a 64x32 image) and just crop out the 40x24 region that I need inside the program.

NOTE: I think the veteran advice is that it's probably the best idea to store all your images in a single sprite sheet that you can select the individual images from later on. I plan to do this at the very end of my project. Just in case you aren't already doing this, it might be best to keep this in mind Wink

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #6 - Posted 2013-07-12 01:34:26 »

1  
2  
boolean useOpenGLES2 = true;
new LwjglApplication(listener, title, width, height, useOpenGLES2);

That's what I have, anyways.
Offline davedes
« Reply #7 - Posted 2013-07-12 02:58:10 »

Some devices won't support NPOT textures even if GLES20 is enabled. Also, performance tends to be better using POT textures than it will be with NPOT textures.

It's best just to use POT textures; you can use PixmapPacker if you want to automatically pack textures into a POT size. Or you can just render your NPOT texture into the next greatest POT with
isPowerOfTwo(int)
and
nextPowerOfTwo(int)
. Note that doing this will mean the texture will not be managed.
https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures

You should also think about using texture atlases, as it will greatly improve performance. It's not a good idea to "wait until the end" to implement them; as they might influence decisions about how you implement certain rendering techniques. For example; if your game needs many texture atlases, it can be better to implement a sorting or some other mechanism, so that you are reducing your batch count per frame.

Offline heisenbergman

JGO Coder


Medals: 14


L___ o_ G___ a__ P___


« Reply #8 - Posted 2013-07-12 03:08:04 »

In what situation would a game need many texture atlases?

What would be an example of a mechanism that would reduce the batch count per frame? (actually... what's being referred to by "batch count per frame"?)

thanks!

Offline davedes
« Reply #9 - Posted 2013-07-12 14:10:34 »

batch count = "render calls"

https://github.com/mattdesl/lwjgl-basics/wiki/Sprite-Batching

A game with hundreds of sprites that don't fit into a single 1024x1024 atlas might benefit from a sorting mechanism. Aside from some games needing hundreds of icons and sprite sheet animations (items, tiles, spells, etc), you also need HUD/GUI elements and fonts (different sizes, styles, etc can pile up).

In this case you need to be smart about rendering, and about texture packing. It makes more sense to pack your HUD/GUI elements into a different atlas than your game tiles; then render all of your tiles in the same batch, and all of your HUD/GUI in the same batch. Also; since things like changing projection matrices, setting blend functions, switching shaders, etc. require flushing the batch, it's not just texture atlases to be concerned about.

Other games need to be even more careful. Unless I'm mistaken, Illarion (which uses LibGDX) dynamically packs texture atlases based on what sprites/tiles are nearby the player. This is because the scenes are extremely complex, and the characters are made up of many components of wearable items/clothing.

You can debug render calls with SpriteBatch.renderCalls (print it out after ending the batch).

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

JGO Coder


Medals: 14


L___ o_ G___ a__ P___


« Reply #10 - Posted 2013-07-25 00:33:53 »

^ Whoa, I didn't notice that you posted a reply to my inquiry already. Very informative, thanks!

Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #11 - Posted 2013-07-25 20:16:45 »

Secret libgdx tech:
Texture.setEnforcePotImages(false);
FileTextureData.copyToPOT = true;
Has caveats, enjoy. Smiley

Pages: [1]
  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.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!