#include <openglimage.hpp>
Inheritance diagram for gcn::OpenGLImage:
Definition at line 82 of file openglimage.hpp.
Public Member Functions | |
OpenGLImage (unsigned int *pixels, int width, int height, bool convertToDisplayFormat=true) | |
Constructor. | |
OpenGLImage (GLuint textureHandle, int width, int height, bool autoFree) | |
Constructor. | |
virtual | ~OpenGLImage () |
Destructor. | |
virtual GLuint | getTextureHandle () const |
Gets the OpenGL texture handle for the image. | |
virtual int | getTextureWidth () const |
Gets the width of texture. | |
virtual int | getTextureHeight () const |
Gets the height of the texture. | |
virtual void | free () |
Frees an image. | |
virtual int | getWidth () const |
Gets the width of the Image. | |
virtual int | getHeight () const |
Gets the height of the Image. | |
virtual Color | getPixel (int x, int y) |
Gets the color of a pixel at coordinate (x, y) in the image. | |
virtual void | putPixel (int x, int y, const Color &color) |
Puts a pixel with a certain color at coordinate (x, y). | |
virtual void | convertToDisplayFormat () |
Converts the image, if possible, to display format. | |
Protected Attributes | |
GLuint | mTextureHandle |
unsigned int * | mPixels |
bool | mAutoFree |
int | mWidth |
int | mHeight |
int | mTextureWidth |
int | mTextureHeight |
gcn::OpenGLImage::OpenGLImage | ( | unsigned int * | pixels, | |
int | width, | |||
int | height, | |||
bool | convertToDisplayFormat = true | |||
) |
Constructor.
Loads an image from an array of pixels. The pixel array is is copied in the constructor and should thus be freed after the constructor has been called.
NOTE: The functions getPixel and putPixel are only guaranteed to work before an image has been converted to display format.
pixels | to load from. | |
width | the width of the image. | |
height | the height of the image. | |
convertToDisplayFormat | true if the image should be converted to display, false otherwise. |
Definition at line 67 of file openglimage.cpp.
References convertToDisplayFormat(), mAutoFree, mHeight, mPixels, mTextureHeight, mTextureWidth, and mWidth.
gcn::OpenGLImage::OpenGLImage | ( | GLuint | textureHandle, | |
int | width, | |||
int | height, | |||
bool | autoFree | |||
) |
Constructor.
Load an image from an OpenGL texture handle. The width and height specifies the size of the "interesting" part of the texture, the real width and height of the texture are assumed to be the closest higher power of two.
textureHandle | the texture handle from which to load. | |
width | the width of the image. | |
height | the height of the image. | |
autoFree | true if the surface should automatically be deleted. |
Definition at line 124 of file openglimage.cpp.
References mAutoFree, mHeight, mPixels, mTextureHandle, mTextureHeight, mTextureWidth, and mWidth.
void gcn::OpenGLImage::convertToDisplayFormat | ( | ) | [virtual] |
Converts the image, if possible, to display format.
IMPORTANT: Only guaranteed to work before the image has been converted to display format.
Implements gcn::Image.
Definition at line 241 of file openglimage.cpp.
References mPixels, mTextureHandle, mTextureHeight, and mTextureWidth.
Referenced by OpenGLImage().
int gcn::OpenGLImage::getHeight | ( | ) | const [virtual] |
Gets the height of the Image.
Implements gcn::Image.
Definition at line 186 of file openglimage.cpp.
References mHeight.
Color gcn::OpenGLImage::getPixel | ( | int | x, | |
int | y | |||
) | [virtual] |
Gets the color of a pixel at coordinate (x, y) in the image.
IMPORTANT: Only guaranteed to work before the image has been converted to display format.
x | the x coordinate. | |
y | the y coordinate. |
Implements gcn::Image.
Definition at line 191 of file openglimage.cpp.
References mHeight, mPixels, mTextureWidth, and mWidth.
GLuint gcn::OpenGLImage::getTextureHandle | ( | ) | const [virtual] |
Gets the OpenGL texture handle for the image.
Definition at line 153 of file openglimage.cpp.
References mTextureHandle.
Referenced by gcn::OpenGLGraphics::drawImage().
int gcn::OpenGLImage::getTextureHeight | ( | ) | const [virtual] |
Gets the height of the texture.
Definition at line 163 of file openglimage.cpp.
References mTextureHeight.
Referenced by gcn::OpenGLGraphics::drawImage().
int gcn::OpenGLImage::getTextureWidth | ( | ) | const [virtual] |
Gets the width of texture.
Definition at line 158 of file openglimage.cpp.
References mTextureWidth.
Referenced by gcn::OpenGLGraphics::drawImage().
int gcn::OpenGLImage::getWidth | ( | ) | const [virtual] |
Gets the width of the Image.
Implements gcn::Image.
Definition at line 181 of file openglimage.cpp.
References mWidth.
void gcn::OpenGLImage::putPixel | ( | int | x, | |
int | y, | |||
const Color & | color | |||
) | [virtual] |
Puts a pixel with a certain color at coordinate (x, y).
x | the x coordinate. | |
y | the y coordinate. | |
color | the color of the pixel to put. |
Implements gcn::Image.
Definition at line 220 of file openglimage.cpp.
References gcn::Color::a, gcn::Color::b, gcn::Color::g, mHeight, mPixels, mTextureWidth, mWidth, and gcn::Color::r.