Questions regarding Textures and TextureLoader

Started by Iceweasel44, December 05, 2012, 02:19:28

Previous topic - Next topic

Iceweasel44

So I can make quads and texture them, but I will want to have different textures on different quads. The screen will be, for the most part, tiled. Each tile will take image data from a single tileset, but I may have multiple tilesets "in play" on different tiles throughout the screen.

While I can get things working with a single texture, and then just give tiles on screen coordinates grab different tiles from that tileset, I don't know what is happening behind the scenes...

Point of confusion, at the moment: What is texture.bind doing? And why do I get an exception about needing to do resource loading after initialization when I call TextureLoader.getTexture "too early" - is it already interacting with the GPU? I thought that's what texture.bind was for.

I intend to make some subtle changes to a tileset such that there will be 64 possible iterations of a single tile - with a 512*512 starting tileset, this makes a 512*(512*64) sized image, which gives me an error about the texture being too large for hardware (GL_MAX_TEXTURE_SIZE is 16384 - 128*128.). However, I can make a texture of size 512*(512*32) , which gives me a 512*16384 sized texture, and it seems to be OK with that... So perhaps I can use a texture up to 16384*16384 pixels? 16384 pixels is more than enough to work with, as I could make a 512*8*512*8 tileset to get what I need within that limit (However, I don't want to push limits of MY hardware - want this to work on "lesser" hardware as well). It seems like having a bunch of smaller Texture objects would be more manageable.  If that's the case, how fast is the texture.bind operation? Seems like I will be doing 64 binds per render pass at minimum, with the possibility of more.

Javadoc on this seems to be pretty weak... Could not find relevant wiki or wiki pages. Don't feel inclined to search for a wiki for me, but if you happen to know of one with information regarding these things in particular, let me know.

Fool Running

1) Calling TextureLoader.getTexture() does interact with the GPU. It does the uploading of the texture data to OpenGL.
2) texture.bind() tells OpenGL that you want to use that texture for the next batch of rendering.
3) The size you are getting back from GL_MAX_TEXTURE_SIZE is the size on both the x and the y axis (so if it returns 4096 then the maximum texture size is 4096x4096). A safe size that most graphics cards are capable of handling is 1024x1024.

I think the best thing you could do would be to try it and see how bad it is. Also, sorting your tiles so you don't do many texture.bind() calls per frame would help. Also, creating a texture on the fly during loading that is the graphics card's maximum size and putting as many tiles on each texture as possible would help.

I also find it strange that you need 64 iterations of a single tile. That seems a bit excessive (especially if every tile has 64 frames). What do you have in your tile set that needs so many frames?
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D