Texture

Simple OO wrapper around the concept of a texture in openGL.

Since Texture is a child of ResourceManaged, all memory management is taken care of.

Children

Image

Operators

  • Texture = Texture
  • bool : True if texture is loaded, false if not.
  • ostream& << Texture
Summary
Simple OO wrapper around the concept of a texture in openGL.
Default constructor, initalizes internal state of Texture.
Copy constructor, copies another Texture.
Initializing constructor, loads Texture via call to open.
Opens an image file, currently supported image types are BMP, GIF, JPEG, PCX, PNG, and TGA.
Makes texture the current OpenGL texture.
Gets width of texture.
Gets height of texture.
Define a new named resource.
Define a new unaliased resource.

(Con/ De)structors

Texture

Texture()

Default constructor, initalizes internal state of Texture.

Texture

Texture(const Texture &rhs)

Copy constructor, copies another Texture.

Parameters

rhsTexture to construct copy of.

Texture

Texture(const std::string &name)

Initializing constructor, loads Texture via call to open.

Parameters

nameName of the Texture <Resource> to open.

See Also

open

General

open

void open(const std::string &name)

Opens an image file, currently supported image types are BMP, GIF, JPEG, PCX, PNG, and TGA.

Loading is done via a href=”Coronahttp://corona.sf.net">Corona</a.

Parameters

nameName of the Texture <Resource> to open.

bind

void bind() const

Makes texture the current OpenGL texture.

Accessors

getWidth

scalar getWidth() const

Gets width of texture.

Returns

Width of texture.

getHeight

scalar getHeight() const

Gets height of texture.

Returns

Height of texture.

Resource Creation

addResource

static void addResource(const std::string &name,
const std::string &path)

Define a new named resource.  (Ex.  Image::addResource(“monkey”,”images/monkey.png”) would make it so that any attempts to load “monkey” would load the image images/monkey.png)

Parameters

nameName to give to resource.
pathPath of resource data file.

addResource

static void addResource(const std::string &path)

Define a new unaliased resource.  (name == path).  (Ex.  Image::addResource(“images/monkey.png”) is essentially the same as Image::addResource(“images/monkey.png”,”images/monkey.png”)

Parameters:. path - Path of resource data file.

Texture()
Default constructor, initalizes internal state of Texture.
void open(const std::string &name)
Opens an image file, currently supported image types are BMP, GIF, JPEG, PCX, PNG, and TGA.
void bind() const
Makes texture the current OpenGL texture.
scalar getWidth() const
Gets width of texture.
scalar getHeight() const
Gets height of texture.
static void addResource(const std::string &name,
const std::string &path)
Define a new named resource.
Base template class, to be used as a base from which classes which have resources that can be controlled, such as textures and music, can be derived.
Image is a class which is used to store a single image, for use in 2D games.