NGL  6.5
The NCCA Graphics Library
Texture.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Jon Macey
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef TEXTURE_H_
18 #define TEXTURE_H_
19 #include "Image.h"
22 #include "Types.h"
23 #include <string>
24 
25 namespace ngl
26 {
27 
28 //----------------------------------------------------------------------------------------------------------------------
40 //----------------------------------------------------------------------------------------------------------------------
41 
43 {
44 public :
45  //----------------------------------------------------------------------------------------------------------------------
47  //----------------------------------------------------------------------------------------------------------------------
48  Texture()=default;
49  //----------------------------------------------------------------------------------------------------------------------
51  //----------------------------------------------------------------------------------------------------------------------
52  ~Texture()=default;
53  //----------------------------------------------------------------------------------------------------------------------
55  //----------------------------------------------------------------------------------------------------------------------
56  Texture(const Texture &)=delete;
57  Texture & operator =(const Texture &)=delete;
58 
59  //----------------------------------------------------------------------------------------------------------------------
62  //----------------------------------------------------------------------------------------------------------------------
63  Texture(const std::string &_fname );
64  //----------------------------------------------------------------------------------------------------------------------
69  //----------------------------------------------------------------------------------------------------------------------
70  bool loadImage(const std::string &_fname );
71  //----------------------------------------------------------------------------------------------------------------------
74  //----------------------------------------------------------------------------------------------------------------------
75  unsigned char *getPixels() const {return m_image.getPixels();}
76  //----------------------------------------------------------------------------------------------------------------------
79  //----------------------------------------------------------------------------------------------------------------------
80  GLuint setTextureGL() const noexcept;
81  //----------------------------------------------------------------------------------------------------------------------
84  //----------------------------------------------------------------------------------------------------------------------
85  void setMultiTexture(const GLint _id ) noexcept;
86  //----------------------------------------------------------------------------------------------------------------------
89  //----------------------------------------------------------------------------------------------------------------------
90  GLuint getWidth()const noexcept{return m_width;}
91  //----------------------------------------------------------------------------------------------------------------------
94  //----------------------------------------------------------------------------------------------------------------------
95  GLuint getHeight()const noexcept{return m_height;}
96  //----------------------------------------------------------------------------------------------------------------------
99  //----------------------------------------------------------------------------------------------------------------------
100  GLuint getFormat()const noexcept{return m_format;}
101 
102  const Image & getImage() const {return m_image;}
103 
104 protected :
105  //----------------------------------------------------------------------------------------------------------------------
108  //----------------------------------------------------------------------------------------------------------------------
110  //----------------------------------------------------------------------------------------------------------------------
112  //----------------------------------------------------------------------------------------------------------------------
113  GLuint m_width=0;
114  //----------------------------------------------------------------------------------------------------------------------
116  //----------------------------------------------------------------------------------------------------------------------
117  GLuint m_height=0;
118  //----------------------------------------------------------------------------------------------------------------------
120  //----------------------------------------------------------------------------------------------------------------------
121  GLuint m_channels=3;
122  //----------------------------------------------------------------------------------------------------------------------
124  //----------------------------------------------------------------------------------------------------------------------
125  GLint m_multiTextureID=0;
126  //----------------------------------------------------------------------------------------------------------------------
128  //----------------------------------------------------------------------------------------------------------------------
129  GLuint m_format=GL_RGB;
130 
131 };
132 
133 }
134 #endif
135 //----------------------------------------------------------------------------------------------------------------------
136 
137 
unsigned int GLuint
Definition: glew.h:280
main definition of types and namespace
#define NGL_DLLEXPORT
Definition: Types.h:65
unsigned char * getPixels() const
method to access the pixel data pointer
Definition: Texture.h:75
implementation files for RibExport class
Definition: AABB.cpp:22
GLuint getWidth() const noexcept
Get the width of the texture.
Definition: Texture.h:90
Image m_image
the actual image data loaded packed in r,g,b,a format in contiguous memory stored in a smart_pointer ...
Definition: Texture.h:109
const Image & getImage() const
Definition: Texture.h:102
simple texture object using QImage to load and convert to OpenGL texturing, needs loads of work for m...
Definition: Texture.h:42
#define GL_RGB
Definition: glew.h:680
A generic Image loader / wrapper for different Image libs this allows us to load an image to be used ...
GLuint getHeight() const noexcept
Get the height of the texture.
Definition: Texture.h:95
int GLint
Definition: glew.h:281
GLuint getFormat() const noexcept
Get the pixel format.
Definition: Texture.h:100
GLsizei const GLchar *const * string
Definition: glew.h:1847