Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Texture Atlas Maker

, 1 Apr 2012 BSD
A utility to create texture atlases for 2D OpenGL games
AtlasExample_iphone_project.zip
AtlasExample
.DS_Store
__MACOSX
AtlasExample
._.DS_Store
AtlasExample
.DS_Store
AtlasExample
._.DS_Store
AtlasAppDelegate.mm
AtlasExample-Info.plist
AtlasExample-Prefix.pch
._AtlasExample-Prefix.pch
EAGLView.mm
en.lproj
InfoPlist.strings
en.lproj
._InfoPlist.strings
MainWindow.xib
ImagePNG.mm
._ImagePNG.mm
images0.tga
main.m
._main.m
Shaders
Shader.fsh
Shaders
._Shader.fsh
Shader.vsh
._Shader.vsh
AtlasExample.xcodeproj
project.pbxproj
project.xcworkspace
contents.xcworkspacedata
xcuserdata
lefty.xcuserdatad
UserInterfaceState.xcuserstate
xcuserdata
lefty.xcuserdatad
xcdebugger
Breakpoints.xcbkptlist
xcschemes
AtlasExample.xcscheme
xcschememanagement.plist
AtlasExampleTests
AtlasExampleTests-Info.plist
AtlasExampleTests-Prefix.pch
AtlasExampleTests
._AtlasExampleTests-Prefix.pch
AtlasExampleTests.m
._AtlasExampleTests.m
en.lproj
InfoPlist.strings
en.lproj
._InfoPlist.strings
AtlasExample_iPhone_project_2.1.zip
.DS_Store
._.DS_Store
.DS_Store
._.DS_Store
AtlasAppDelegate.mm
AtlasExample-Info.plist
AtlasExample-Prefix.pch
._AtlasExample-Prefix.pch
EAGLView.mm
InfoPlist.strings
._InfoPlist.strings
MainWindow.xib
ImagePNG.mm
._ImagePNG.mm
imagesNelly0.tga
main.m
._main.m
Shader.fsh
._Shader.fsh
Shader.vsh
._Shader.vsh
project.pbxproj
contents.xcworkspacedata
UserInterfaceState.xcuserstate
Breakpoints.xcbkptlist
AtlasExample.xcscheme
xcschememanagement.plist
AtlasExampleTests-Info.plist
AtlasExampleTests-Prefix.pch
._AtlasExampleTests-Prefix.pch
AtlasExampleTests.m
._AtlasExampleTests.m
InfoPlist.strings
._InfoPlist.strings
AtlasMaker.zip
AtlasMaker
.classpath
.project
bin
icon.png
images
icon.png
output.png
settings.png
output.png
settings.png
src
AtlasMaker_jar.zip
AtlasMaker.jar
AtlasMaker_jar_2.0.zip
AtlasMaker.jar
AtlasMaker_jar_2.1.zip
AtlasMaker.jar
AtlasMaker_jar_2.2.1.zip
AtlasMaker.jar
AtlasMaker_jar_2.2.zip
AtlasMaker.jar
AtlasMaker_source.2.2.1.zip
.classpath
.project
.settings
org.eclipse.jdt.core.prefs
atlasMaker.properties
icon.png
icon.png
settings.png
settings.png
AtlasMaker_source.zip
.classpath
.project
icon.png
icon.png
output.png
settings.png
output.png
settings.png
AtlasMaker_source_2.0.zip
.classpath
.project
atlasMaker.properties
icon.png
icon.png
settings.png
settings.png
AtlasMaker_source_2.1.zip
.classpath
.project
org.eclipse.jdt.core.prefs
atlasMaker.properties
icon.png
icon.png
settings.png
settings.png
AtlasMaker_source_2.2.zip
.classpath
.project
org.eclipse.jdt.core.prefs
icon.png
icon.png
settings.png
settings.png
#ifndef _ATLASIMAGE_H_INCLUDED_
#define _ATLASIMAGE_H_INCLUDED_


class ImageGL;
class XParser;
class Rect;

const int verticesPerQuad = 4;
const int indicesPerQuad = 6;
const int compVertPos = 2;
const int compVertTex = 2;

class AtlasImage
{
public:
	AtlasImage(ImageGL* pTexture) : m_pImageGL(pTexture) {}
	AtlasImage(const AtlasImage& atlasImage);
	AtlasImage() : m_pImageGL(NULL) {}
	void Load(const XParser* pXParser);
	void Render(int x, int y) const;
	void Release();
	int GetHeight() const
	{
		return m_height;
	}
	int GetWidth() const
	{
		return m_width;
	}
	int GetXOffset() const
	{
		return m_xOffset;
	}
	void SetXOffset(int xOffset)
	{
		m_xOffset = xOffset;
	}
	int GetYOffset() const
	{
		return m_yOffset;
	}
	void SetYOffset(int yOffset)
	{
		m_yOffset = yOffset;
	}
	const string& GetName() const
	{
		return *m_pName;
	}
	void SetName(const string& name)
	{
		m_pName = &name;
	}
	ImageGL* GetTexture() const
	{
		return m_pImageGL;
	}
	void SetImageGL(ImageGL* pImageGL)
	{
		m_pImageGL = pImageGL;
	}
	int GetTransHeight() const
	{
		return m_transHeight;
	}
	int GetTransWidth() const
	{
		return m_transWidth;
	}
	friend class TexturedQuad; 
protected:
	bool CreateVertices(float* vertices, int x, int y, 
		float scale, float rotation, int ancor) const;
	const string* m_pName;	// only for debug purposes
	int m_x;
	int m_y;
	int m_width;
	int m_height;
	int m_transWidth;
	int m_transHeight;
	int m_xOffset;
	int m_yOffset;
	bool m_transparent;
	float m_texCoords[verticesPerQuad*compVertTex];
	ImageGL* m_pImageGL;
};

void CreateQuad(float* pTexCoords, 
	int x, int y, int width, int height,
	int texWidth, int texHeight);




#endif // _ATLASIMAGE_H_INCLUDED_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License

Share

About the Author

ed welch
Software Developer Astronautz
Spain Spain
After working in the software industry for many years, I've started my own games company that specialises in strategy games for mobile platforms.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411019.1 | Last Updated 1 Apr 2012
Article Copyright 2012 by ed welch
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid