Giter VIP home page Giter VIP logo

ofxtextureatlas's Introduction

ofxTextureAtlas : What is this

Build Status

This will allow you to draw lots of different images on screen with a minimal number of texture binds. First, you must create the atlases. Supply a list of images you want to be able to draw later, and create atlases for them. You can specify the atlas size, the max image size, interal format (with alpha, etc), and if you want mipmaps or not.

cats atlas

See original image.

The addon accepts any image aspect ratio, so images can be all of different aspect ratios on the same atlas (ie not only sprite sheets). It does rectangle packing to maximize the atlas space.

Each atlas is created in an fbo + a data structure, which can be saved to disk for later use. An atlas is saved to disk as an image file (png / jpg) and an XML. The xml holds a list of the images files that are contained inside the atlas, the atlas size, and each of the rects that defines where the image is in the atlas.

This is what an Atlas looks like:

cats atlas

You can easly load atlases from disk (multi threaded, as loading from XML is very slow) and use the TextureAtlasDrawer class to draw any images you need, regardless of which atlas they fell into. It will create an ofMesh on the fly for each atlas that holds an image that happens to be in the list of images you want to draw, minimizing the number of texture binds().

#Dependencies

Requires ofxXmlSettings and my fork of ofxRectangleUtils.

#Examples

To run the examples, first create some atlases. Open up exampleCreate, add lots of images into bin/data/images/cats and run it; it will create some atlases into bin/data/textureCache

Then, to draw using the atlas, try the other example, exampleDraw. Copy the atlases created in bin/data/textureCache with exampleCreate into the bin/data/textureCache of exampleDraw, and run it. Use the mouse wheel to zoom in and out.

ofxtextureatlas's People

Contributors

armadillu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ofxtextureatlas's Issues

can't seem to appropriately sort draw order

I'm unsure if this is supported, but it seems that changing the order of texture draws doesn't seem to appropriately impact the final result. How can I effectively control the draw order of textures in the atlas, in order to create the appearance of z depth, for example?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.