PROTO::KLUDGE  0.1
Quick prototyping library for games using SDL and OpenGL.
GLTexture.hpp
Go to the documentation of this file.
1 #ifndef GLTEXTURE_HPP
2 #define GLTEXTURE_HPP
3 
4 #include <stdio.h>
5 #include <string>
6 
7 #include "GL/glew.h"
8 
9 #include <SDL2/SDL_image.h>
10 
12 
13 namespace pk
14 {
15 
26 {
27  CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
28  CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER,
29  MIRRORED_REPEAT = GL_MIRRORED_REPEAT,
30  REPEAT = GL_REPEAT,
31  MIRROR_CLAMP_TO_EDGE = GL_MIRROR_CLAMP_TO_EDGE
32 };
33 
44 {
45  NEAREST = GL_NEAREST,
46  LINEAR = GL_LINEAR,
47  NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST,
48  LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST,
49  LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR
50 };
51 
57 class GLTexture
58 {
59  private:
64  GLTexture(){};
65 
71  void updateParameters();
72 
73  public:
74 
75  virtual ~GLTexture();
76 
83  GLTexture(std::string path);
84 
93 
100  void setTextureRect(GLRect rect){ m_rect = rect; updateParameters(); };
101 
110  void setTextureCoordinateWrapParameters(GLint S, GLint T, GLint R);
111 
119  void setTextureFilterParameters(GLint min, GLint mag);
120 
126  void load(std::string path);
127 
133  void use();
134 
140  void disable();
141 
146  void clear();
147 
148 private:
149  SDL_Surface* m_surf;
151  GLuint m_textureID;
159 };
160 
161 }
162 
163 #endif // GLTEXTURE_HPP
void load(std::string path)
Load the GLTexture from an image file on the path.
SDL_Surface * m_surf
An SDL surface useful for loading pixel data from a file.
Definition: GLTexture.hpp:149
Definition: Game.hpp:7
Definition: GLTexture.hpp:31
int m_bitDepth
The bit depth of the texture.
Definition: GLTexture.hpp:153
Definition: GLTexture.hpp:49
Definition: GLTexture.hpp:47
GLTexture()
Default constructor - INACCESSIBLE!
Definition: GLTexture.hpp:64
Definition: GLTexture.hpp:28
Definition: GLTexture.hpp:48
void clear()
Clear all of the GLTexture data.
void disable()
Disables the GLTexture by unbinding the texture and calling glDisable(...).
Definition: GLTexture.hpp:30
GLint m_textureFilter_MAG
The texture parameter for the magnifying function.
Definition: GLTexture.hpp:158
GLint m_textureCoordinate_R
The wrap parameter for the R coordinate of the texture.
Definition: GLTexture.hpp:156
GLRect getTextureRect()
Get the GLTexture&#39;s texture rect with its bounds.
Definition: GLTexture.hpp:92
void setTextureCoordinateWrapParameters(GLint S, GLint T, GLint R)
Set the texture coordinate wrap parameters for the texture.
Definition: GLTexture.hpp:100
void setTextureFilterParameters(GLint min, GLint mag)
Set the texture filter parameters for the texture.
GLRect m_rect
The GLRect defining the bounds of the texture.
Definition: GLTexture.hpp:152
GLTextureFilter
Values for setting the texture filter functions for GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, and GL_TEXTURE_WRAP_R. These values have been aliased with member data (SEE MEMBER DATA FOR DETAILS). For further reference, refer to the OpenGL refpages: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexParameter.xhtml.
Definition: GLTexture.hpp:43
GLuint m_textureID
The identifier for the texture.
Definition: GLTexture.hpp:151
Definition: GLTexture.hpp:46
Useful for defining size and origin of an OpenGL object.
Definition: GLTransformable.hpp:15
Definition: GLTexture.hpp:45
void use()
Use the GLTexture by activating and binding it to your OpenGL program.
int m_pixelFormat
Stores the pixel format of the image that is loaded.
Definition: GLTexture.hpp:150
GLint m_textureCoordinate_T
The wrap parameter for the T coordinate of the texture.
Definition: GLTexture.hpp:155
void setTextureRect(GLRect rect)
Set the GLTexture&#39;s texture rect.
Definition: GLTexture.hpp:100
Definition: GLTexture.hpp:29
virtual ~GLTexture()
GLint m_textureCoordinate_S
The wrap parameter for the S coordinate of the texture.
Definition: GLTexture.hpp:154
Class for creating textures usable with OpenGL from SDL.
Definition: GLTexture.hpp:57
GLTextureWrap
Definition: GLTexture.hpp:25
GLint m_textureFilter_MIN
The texture parameter for the minifying function.
Definition: GLTexture.hpp:157
Definition: GLTexture.hpp:27
void updateParameters()
Internally resets the texture parameters so that textures render as expected.
Definition: GLTexture.hpp:64