So to sum it up, the major difference is, TextureRegion is a Region from a Texture whereas TextureAtlas is a collection of TextureRegions.Ī TextureAtlas class contains a collection of AtlasRegion class which extends TextureRegion class. Now to get a particular TextureRegion from it, you do pokemonFrontAtlas.findRegion("SomePokemon")įindRegion(String name) returns you the textureRegion from the TextureAtlas. Now imagine you packed 100 files using Texture Packer and you want to load a image( Texture) which has file name as "SomePokemon". TextureAtlas pokemonFrontAtlas = new TextureAtlas(("pokemon//pokemon.pack")) pack file, it is loaded using TextureAtlas classįor example imagine a pokemon pack file which has all the pokemons into it. It will pack every texture into one image AND create a. So what we do is we pack the Textures into a bigger Texture using TexturePacker(an application) which then creates a. Now because you want to use TextureRegions, it will be hard to know the dimensions of each and every sub image to load them from Texture Sheet. TextureRegion, takes an area from the Texture according to the dimension you provide, the advantage of having it is that you don't have to load textures again and again and the bigger advantage is you don't have to load each and every texture on GPU as you can do it directly by loading one big texture and extracting sub regions(TextureRegions) from it. When you load a texture in your game by doing Texture t = new Texture(""), you load a texture in GPU. Likewise, if you used whitespace stripping when packing the atlas for a more tight packing, then AtlasRegion contains the required information to reproduce the original image. pack file with de dimensions and coordinates of all of them. You can use something like TexturePacker. when the region is rotated for optimal packing, then the AtlasRegion contains this information so it knows it has to undo that operation when drawing it. Do you need to open paint to count pixels Noooo, you don't. A AtlasRegion is an TextureRegion that contains additional information about the packing.Note that an atlas can contain multiple texture files. Skin files from the libGDX tests can be used as a starting point: uiskin.png, uiskin.atlas, uiskin.json, and default.fnt. Also note that the JSON that libGDX uses differentiates from the standard, where quotes are not used to define keys or values. This file is typically created with the TexturePacker tool. A resource must be declared in the JSON above where it is referenced. You typically load a TextureAtlas from a file which holds all information about the atlas. A TextureAtlas is a container for both one or more Textures and the regions it contains.Practically it thus says: "on that texture at those coordinates and those dimensions this image is located". A TextureRegion is used to define a region of a Texture.Therefor it is common to include multiple images in a single bigger Texture. You typically want to use as less textures as possible (and specifically want to avoid switching between textures). That is: it represents a single 2D texture in GPU memory, which can be used for rendering. A Texture is the libGDX implementation of an OpenGL 2D Texture.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |