25 #include "glfTexture.hh"
26 #include "glfException.hh"
34 GLF_THROW_EXCEPTION(
"First Swap partner has no GL-Object assigned!");
37 GLF_THROW_EXCEPTION(
"Second Swap partner has no GL-Object assigned!");
40 GLF_THROW_EXCEPTION(
"swap partners relate to different targets!");
42 GLuint swapCache = A.
id_;
75 glDeleteTextures(1, &
id_);
84 glGenTextures(1, &
id_);
92 glTexParameteri(
target_, GL_TEXTURE_MIN_FILTER, (GLint) minFilter);
93 GLF_THROW_ON_OPENGL_ERROR;
100 glTexParameteri(
target_, GL_TEXTURE_MAG_FILTER, (GLint) magFilter);
101 GLF_THROW_ON_OPENGL_ERROR;
108 glTexParameteri(
target_, GL_TEXTURE_WRAP_S, (GLint) wrapS);
109 GLF_THROW_ON_OPENGL_ERROR;
116 glTexParameteri(
target_, GL_TEXTURE_WRAP_T, (GLint) wrapT);
117 GLF_THROW_ON_OPENGL_ERROR;
124 glTexParameteri(
target_, GL_TEXTURE_WRAP_R, (GLint) wrapR);
125 GLF_THROW_ON_OPENGL_ERROR;
132 glTexParameteri(
target_, GL_GENERATE_MIPMAP, (GLint) generateMipMap);
133 GLF_THROW_ON_OPENGL_ERROR;
140 glTexParameteri(
target_, GL_TEXTURE_BASE_LEVEL, (GLint) baseLevel);
141 GLF_THROW_ON_OPENGL_ERROR;
148 glTexParameteri(
target_, GL_TEXTURE_MAX_LEVEL, (GLint) maxLevel);
149 GLF_THROW_ON_OPENGL_ERROR;
158 glTexParameterfv(
target_, GL_TEXTURE_BORDER_COLOR, rgba);
159 GLF_THROW_ON_OPENGL_ERROR;
165 bool supportNonPot =
false;
167 #ifdef BIAS_HAVE_GLEW
168 if (GLEW_ARB_texture_non_power_of_two)
170 supportNonPot =
true;
188 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &TUs);\
190 return
static_cast<int> (TUs);
196 if (!glewIsSupported(
"GL_EXT_framebuffer_object"))
199 "GL_EXT_framebuffer_object is not supported but required "
200 "for glfTexture::GenerateMipMap");
210 if ((textureNr >= GL_TEXTURE0) && (textureNr < (GL_TEXTURE0
218 BIASWARN(
"Invalid texture unit! Valid range is GL_TEXTURE0 - GL_TEXTURE"<<
MAX_TEXTURE_UNITS_-1);
227 GLint textureNrGl = textureNr + GL_TEXTURE0;
228 if ((textureNrGl >= GL_TEXTURE0) && (textureNrGl < (GL_TEXTURE0
244 BIASASSERT(
id_ != 0);
251 BIASASSERT(
id_ != 0);
261 BIASASSERT(
id_ != 0);
263 glActiveTexture(GL_TEXTURE0+number);
void SetBorderColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
Sets the border color for the texture to be used.
static int NextPowerOfTwo(int i)
Returns the smallest power of two that is greater than i.
void Create()
Creates the texture but does not upload any data yet.
void Bind() const
Binds the texture.
void EnlargeToPowerOfTwoIfRequired(bool enlargeToPotIfRequired=true)
Sets whether to enlarge each texture dimension to the next power of two, if non-power-of-two textures...
BIASOpenGLFramework_EXPORT void SwapGLObjects(glfTexture &A, glfTexture &B)
void SetMaxLevel(int maxLevel)
Sets the maximum mip map level to be used.
void SetWrapS(GLenum wrapS)
Sets the wrapping mode for the 1st texture coordinate.
void BindTU() const
Binds the texture.
void SetMinFilter(GLenum minFilter)
Sets the minifying function.
void SetTextureNrInUniformFormat(int textureNr)
Sets the OpenGL texture number (0 - MaxTextureUnit-1).
static int GetMaxSupportedTextureUnits()
Computes a pixel format that can be used with glGetTexImage for an internal format of a texture...
void SetGenerateMipMap(bool generateMipMap)
Sets whether to automatically generate mipmaps when the first mipmap is uploaded. ...
void SetWrapT(GLenum wrapT)
Sets the wrapping mode for the 2nd texture coordinate.
void SetBaseLevel(int baseLevel)
Sets the minimum (base) mip map level to be used.
void SetWrapR(GLenum wrapR)
Sets the wrapping mode for the 3rd texture coordinate.
void GenerateMipMap()
Explicitly generates the mipmaps of the texture in hardware.
void SetTextureNr(GLint textureNr)
Sets the OpenGL texture number (GL_TEXTURE0 - GL_TEXTURE[MaxTextureUnit-1]).
glfTexture(GLenum target)
void SetMagFilter(GLenum magFilter)
Sets the magnification function.