Commit fee8d29a authored by schultz's avatar schultz

added texturecoordinate generation to GLState

parent eb8e4020
......@@ -58,6 +58,7 @@
#include <ACG/GL/acg_glew.hh>
#include "GLState.hh"
#include <ACG/GL/removedEnums.hh>
#include <OpenMesh/Core/Utils/vector_cast.hh>
#include <cstring>
......@@ -122,6 +123,7 @@ GLStateContext::GLStateContext() :
blendFuncState_[1] = GL_ONE_MINUS_SRC_ALPHA;
blendFuncState_[2] = GL_SRC_ALPHA;
blendFuncState_[3] = GL_ONE_MINUS_SRC_ALPHA;
texGenMode_ = GL_EYE_LINEAR;
}
GLState::GLState(bool _updateGL, bool _compatibilityProfile)
......@@ -1510,7 +1512,7 @@ void GLState::syncFromGL()
//-----------------------------------------------------------------------------
void GLState::enable(GLenum _cap)
void GLState::enable(GLenum _cap, bool _warn)
{
if (!glStateLock_.test(_cap))
{
......@@ -1518,13 +1520,19 @@ void GLState::enable(GLenum _cap)
if (!stateStack_.back().glStateEnabled_.test(_cap))
#endif
{
glEnable(_cap);
if (ACG::compatibilityProfile() || removedEnums.find(_cap) == removedEnums.end())
glEnable(_cap);
else
{
if(_warn)
std::cerr << "OpenGL Warning:You are trying to use a GLenum that has been removed for OpenGL core profiles." << std::endl;
}
stateStack_.back().glStateEnabled_.set(_cap);
}
}
}
void GLState::disable(GLenum _cap)
void GLState::disable(GLenum _cap, bool _warn)
{
if (!glStateLock_.test(_cap))
{
......@@ -1532,7 +1540,13 @@ void GLState::disable(GLenum _cap)
if (stateStack_.back().glStateEnabled_.test(_cap))
#endif
{
glDisable(_cap);
if (ACG::compatibilityProfile() || removedEnums.find(_cap) == removedEnums.end())
glDisable(_cap);
else
{
if (_warn)
std::cerr << "OpenGL Warning:You are trying to use a GLenum that has been removed for OpenGL core profiles." << std::endl;
}
stateStack_.back().glStateEnabled_.reset(_cap);
}
}
......@@ -1997,6 +2011,30 @@ void GLState::getTexcoordPointer(GLint* _size, GLenum* _type, GLsizei* _stride,
if (_pointer) *_pointer = stateStack_.back().texcoordPointer_.pointer;
}
void GLState::setTexGenMode(GLenum _coord, GLenum _name, GLint _param)
{
if (ACG::compatibilityProfile())
{
glTexGeni(_coord, _name, _param);
}
else
{
stateStack_.back().texGenMode_ = _param;
}
}
void GLState::getTexGenMode(GLenum _coord, GLenum _name, GLint* _param)
{
if (ACG::compatibilityProfile())
{
glGetTexGeniv(_coord, _name, _param);
}
else
{
*_param = stateStack_.back().texGenMode_;
}
}
//---------------------------------------------------------------------
// draw buffer functions
......@@ -2078,10 +2116,10 @@ void GLState::bindFramebuffer(GLenum _target, GLuint _framebuffer)
#endif
{
#ifndef __APPLE__
if (!glBindFramebuffer)
glewInit();
if (glBindFramebuffer == nullptr)
glewInit();
#endif
glBindFramebuffer(_target, _framebuffer);
glBindFramebuffer(_target, _framebuffer);
stateStack_.back().framebuffers_[i] = _framebuffer;
}
}
......
......@@ -154,6 +154,8 @@ public:
// active texture unit: GL_TEXTUREi
GLenum activeTexture_;
// texture generation mode we only support one mode for all coordinates
GLint texGenMode_;
struct TextureStage
{
......@@ -276,10 +278,10 @@ private:
public:
/// replaces glEnable, but supports locking
static void enable(GLenum _cap);
static void enable(GLenum _cap, bool _warnRemoved = true);
/// replaces glDisable, but supports locking
static void disable(GLenum _cap);
static void disable(GLenum _cap, bool _warnRemoved = true);
/// locks a specific cap state, such that enable() or disable() has no effect
static void lockState(GLenum _cap);
......@@ -511,6 +513,10 @@ public:
static void texcoordPointer(const Vec4d* _p) {texcoordPointer(4, GL_DOUBLE, 0, _p); }
static void setTexGenMode(GLenum _coord, GLenum _name, GLint _param);
static void getTexGenMode(GLenum _coord, GLenum _name, GLint* _param);
/// lock color pointer
static void lockTexcoordPointer() {colorPointerLock_ = true;}
/// unlock vertex pointer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment