NGL  6.5
The NCCA Graphics Library
ngl::Texture Class Reference

simple texture object using QImage to load and convert to OpenGL texturing, needs loads of work for multi texture support etc as well as different texture types More...

#include <Texture.h>

+ Collaboration diagram for ngl::Texture:

Public Member Functions

 Texture ()=default
 Constructor using no parameters. More...
 
 ~Texture ()=default
 destructor More...
 
 Texture (const Texture &)=delete
 make not copyable More...
 
Textureoperator= (const Texture &)=delete
 
 Texture (const std::string &_fname)
 Constructor passing the file to load. More...
 
bool loadImage (const std::string &_fname)
 method to load the image file into the texture class More...
 
unsigned char * getPixels () const
 method to access the pixel data pointer More...
 
GLuint setTextureGL () const noexcept
 set the image as an OpenGL texture object More...
 
void setMultiTexture (const GLint _id) noexcept
 set the texture object to be different texture in multitexture More...
 
GLuint getWidth () const noexcept
 Get the width of the texture. More...
 
GLuint getHeight () const noexcept
 Get the height of the texture. More...
 
GLuint getFormat () const noexcept
 Get the pixel format. More...
 
const ImagegetImage () const
 

Protected Attributes

Image m_image
 the actual image data loaded packed in r,g,b,a format in contiguous memory stored in a smart_pointer for safety More...
 
GLuint m_width =0
 the size of the image in the X direction More...
 
GLuint m_height =0
 the size of the image in the Y direction More...
 
GLuint m_channels =3
 A pointer to the start of the image data. More...
 
GLint m_multiTextureID =0
 the MultiTexture ID for the current texture Object More...
 
GLuint m_format =GL_RGB
 the image format (i.e rgb or rgba) More...
 

Detailed Description

simple texture object using QImage to load and convert to OpenGL texturing, needs loads of work for multi texture support etc as well as different texture types

Author
Jonathan Macey
Version
2.0
Date
18/3/10 Added multi texture support
Todo:

make it more flexible for different types of texture operations

write save method at some stage as well this could grab info from framebuffer and replace the frame writer class

Definition at line 42 of file Texture.h.

Constructor & Destructor Documentation

ngl::Texture::Texture ( )
default

Constructor using no parameters.

ngl::Texture::~Texture ( )
default

destructor

ngl::Texture::Texture ( const Texture )
delete

make not copyable

ngl::Texture::Texture ( const std::string _fname)

Constructor passing the file to load.

Parameters
[in]&_fNamethe name of the file to load

Definition at line 30 of file Texture.cpp.

References ngl::Image::channels(), ngl::Image::format(), ngl::Image::height(), ngl::Image::load(), m_channels, m_format, m_height, m_image, m_multiTextureID, m_width, and ngl::Image::width().

+ Here is the call graph for this function:

Member Function Documentation

GLuint ngl::Texture::getFormat ( ) const
inlinenoexcept

Get the pixel format.

Returns
pixel format of the texture

Definition at line 100 of file Texture.h.

GLuint ngl::Texture::getHeight ( ) const
inlinenoexcept

Get the height of the texture.

Returns
height of the texture

Definition at line 95 of file Texture.h.

const Image& ngl::Texture::getImage ( ) const
inline

Definition at line 102 of file Texture.h.

unsigned char* ngl::Texture::getPixels ( ) const
inline

method to access the pixel data pointer

Returns
reference to the pixel data

Definition at line 75 of file Texture.h.

GLuint ngl::Texture::getWidth ( ) const
inlinenoexcept

Get the width of the texture.

Returns
width of the texture

Definition at line 90 of file Texture.h.

bool ngl::Texture::loadImage ( const std::string _fname)

method to load the image file into the texture class

Parameters
[in]_fNamethe name of the file to load imageMagick will determine if it can load the file
Returns
true on success else false if load fails

Definition at line 41 of file Texture.cpp.

References ngl::Image::channels(), ngl::Image::format(), ngl::Image::height(), ngl::Image::load(), m_channels, m_format, m_height, m_image, m_multiTextureID, m_width, and ngl::Image::width().

+ Here is the call graph for this function:

Texture& ngl::Texture::operator= ( const Texture )
delete
void ngl::Texture::setMultiTexture ( const GLint  _id)
noexcept

set the texture object to be different texture in multitexture

Parameters
_idthe texture id

Definition at line 81 of file Texture.cpp.

References m_multiTextureID.

GLuint ngl::Texture::setTextureGL ( ) const
noexcept

set the image as an OpenGL texture object

Returns
the texture object id
Note
this is really inflexible at the moment needs to be made more generic and give more control over the OpenGL texture types etc Could actually be worth creating a texture manager class at some stage along the lines of the Shader manager class, or even a generic manager framework which we could then add items to

Definition at line 64 of file Texture.cpp.

References ngl::Image::getPixels(), GL_LINEAR, GL_TEXTURE0, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_UNSIGNED_BYTE, glActiveTexture, glBindTexture(), glGenerateMipmap, glGenTextures(), glTexImage2D(), glTexParameteri(), m_format, m_height, m_image, m_multiTextureID, and m_width.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

GLuint ngl::Texture::m_channels =3
protected

A pointer to the start of the image data.

Definition at line 121 of file Texture.h.

GLuint ngl::Texture::m_format =GL_RGB
protected

the image format (i.e rgb or rgba)

Definition at line 129 of file Texture.h.

GLuint ngl::Texture::m_height =0
protected

the size of the image in the Y direction

Definition at line 117 of file Texture.h.

Image ngl::Texture::m_image
protected

the actual image data loaded packed in r,g,b,a format in contiguous memory stored in a smart_pointer for safety

Definition at line 109 of file Texture.h.

GLint ngl::Texture::m_multiTextureID =0
protected

the MultiTexture ID for the current texture Object

Definition at line 125 of file Texture.h.

GLuint ngl::Texture::m_width =0
protected

the size of the image in the X direction

Definition at line 113 of file Texture.h.


The documentation for this class was generated from the following files: