Commit 0a5d316d authored by Jan Möbius's avatar Jan Möbius
Browse files

Christopher: moving more calls to glstate

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12355 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 97ab2db3
......@@ -777,7 +777,7 @@ DrawMeshT<Mesh>::createVBO()
if (!vbo_)
glGenBuffersARB(1, &vbo_);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
ACG::GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
if (!flatMode_ && textureMode_)
{
......@@ -821,7 +821,7 @@ DrawMeshT<Mesh>::createVBO()
}
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}
template <class Mesh>
......@@ -835,7 +835,7 @@ DrawMeshT<Mesh>::createIBO()
if (!ibo_)
glGenBuffersARB(1, &ibo_);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo_);
ACG::GLState::bindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo_);
indexType_ = GL_UNSIGNED_INT;
if (numVerts_ <= 0xFFFF)
......@@ -877,7 +877,7 @@ DrawMeshT<Mesh>::createIBO()
}
}
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, lineIBO_);
ACG::GLState::bindBufferARB(GL_ELEMENT_ARRAY_BUFFER, lineIBO_);
// 2 or 4 byte indices:
if (indexType_ == GL_UNSIGNED_SHORT)
......@@ -892,7 +892,7 @@ DrawMeshT<Mesh>::createIBO()
delete [] pLineBuffer;
}
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
ACG::GLState::bindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
}
template <class Mesh>
......@@ -933,51 +933,51 @@ void DrawMeshT<Mesh>::bindBuffers()
else
rebuild();
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, vbo_);
// prepare color mode
if (colorMode_)
{
if (colorMode_ == 1)
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (char*)32);
ACG::GLState::colorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (char*)32);
else
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (char*)36);
ACG::GLState::colorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (char*)36);
glEnableClientState(GL_COLOR_ARRAY);
ACG::GLState::enableClientState(GL_COLOR_ARRAY);
}
// vertex decl
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), 0);
glEnableClientState(GL_VERTEX_ARRAY);
ACG::GLState::vertexPointer(3, GL_FLOAT, sizeof(Vertex), 0);
ACG::GLState::enableClientState(GL_VERTEX_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (char*)12);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
ACG::GLState::texcoordPointer(2, GL_FLOAT, sizeof(Vertex), (char*)12);
ACG::GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(Vertex), (char*)20);
glEnableClientState(GL_NORMAL_ARRAY);
ACG::GLState::normalPointer(GL_FLOAT, sizeof(Vertex), (char*)20);
ACG::GLState::enableClientState(GL_NORMAL_ARRAY);
// glNormalPointerEXT(3, GL_FLOAT, sizeof(Vertex), (char*)(20)); // glNormalPointerEXT crashes sth. in OpenGL
// ACG::GLState::normalPointerEXT(3, GL_FLOAT, sizeof(Vertex), (char*)(20)); // ACG::GLState::normalPointerEXT crashes sth. in OpenGL
// glTangentPointerEXT(4, GL_FLOAT, sizeof(Vertex), (void*)(32));
// glEnableClientState(GL_TANGENT_ARRAY_EXT);
// ACG::GLState::enableClientState(GL_TANGENT_ARRAY_EXT);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo_);
ACG::GLState::bindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo_);
}
template <class Mesh>
void DrawMeshT<Mesh>::unbindBuffers()
{
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
// glDisableClientState(GL_TANGENT_ARRAY_EXT);
ACG::GLState::disableClientState(GL_VERTEX_ARRAY);
ACG::GLState::disableClientState(GL_TEXTURE_COORD_ARRAY);
ACG::GLState::disableClientState(GL_NORMAL_ARRAY);
// ACG::GLState::disableClientState(GL_TANGENT_ARRAY_EXT);
if (colorMode_)
glDisableClientState(GL_COLOR_ARRAY);
ACG::GLState::disableClientState(GL_COLOR_ARRAY);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::bindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
}
template <class Mesh>
......@@ -1015,7 +1015,7 @@ void DrawMeshT<Mesh>::drawLines()
{
bindBuffers();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, lineIBO_);
ACG::GLState::bindBuffer(GL_ELEMENT_ARRAY_BUFFER, lineIBO_);
glDrawElements(GL_LINES, mesh_.n_edges() * 2, indexType_, 0);
......
......@@ -387,7 +387,7 @@ public:
*
* This function will return a pointer to the first element of the picking buffer.
* Use updatePickingVertices to update the buffer before you render it via
* glColorPointer.
* ACG::GLState::colorPointer.
*
* @return pointer to the first element of the picking buffer
*/
......@@ -404,7 +404,7 @@ public:
*
* This function will return a pointer to the first element of the picking buffer.
* Use updatePickingVertices to update the buffer before you render it via
* glVertexPointer.
* ACG::GLState::vertexPointer.
*
* @return pointer to the first element of the picking buffer
*/
......@@ -443,7 +443,7 @@ public:
*
* This function will return a pointer to the first element of the picking buffer.
* Use updatePickingEdges to update the buffer before you render it via
* glColorPointer.
* ACG::GLState::colorPointer.
*
* @return pointer to the first element of the picking buffer
*/
......@@ -474,7 +474,7 @@ public:
*
* This function will return a pointer to the first element of the picking buffer.
* Use updatePickingFaces to update the buffer before you render it via
* glColorPointer.
* ACG::GLState::colorPointer.
*
* @return pointer to the per face picking color buffer
*/
......@@ -491,7 +491,7 @@ public:
*
* This function will return a pointer to the first element of the picking buffer.
* Use updatePickingFaces to update the buffer before you render it via
* glColorPointer.
* ACG::GLState::colorPointer.
*
* @return pointer to the first element of the picking buffer
*/
......@@ -524,7 +524,7 @@ public:
*
* This function will return a pointer to the first element of the picking buffer.
* Use updatePickingAny to update the buffer before you render it via
* glColorPointer.
* ACG::GLState::colorPointer.
*
* @return Pointer to the first element of the picking buffer
*/
......
......@@ -7,7 +7,7 @@
//== INCLUDES =================================================================
#include "FBO.hh"
#include "GLState.hh"
//== NAMESPACES ===============================================================
......@@ -139,7 +139,7 @@ bind()
return false;
// bind framebuffer object
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbo_ );
ACG::GLState::bindFramebuffer( GL_FRAMEBUFFER_EXT, fbo_ );
return true;
}
......@@ -151,7 +151,7 @@ FBO::
unbind()
{
//set to normal rendering
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
ACG::GLState::bindFramebuffer( GL_FRAMEBUFFER_EXT, 0 );
}
//-----------------------------------------------------------------------------
......
......@@ -151,106 +151,106 @@ inline void glColor(const Vec4uc& _v) { glColor4ubv(_v.data()); }
//-------------------------------------------------------------- glVertexPointer
/// Wrapper: glVertexPointer for Vec2f
//-------------------------------------------------------------- ACG::GLState::vertexPointer
/*
/// Wrapper: ACG::GLState::vertexPointer for Vec2f
inline void glVertexPointer(const Vec2f* _p)
{ ::glVertexPointer(2, GL_FLOAT, 0, _p); }
/// Wrapper: glVertexPointer for Vec2d
inline void glVertexPointer(const Vec2d* _p)
{ ::glVertexPointer(2, GL_DOUBLE, 0, _p); }
/// Wrapper: glVertexPointer for Vec3f
inline void glVertexPointer(const Vec3f* _p)
{ ::glVertexPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: glVertexPointer for Vec3d
inline void glVertexPointer(const Vec3d* _p)
{ ::glVertexPointer(3, GL_DOUBLE, 0, _p); }
/// Wrapper: glVertexPointer for Vec4f
inline void glVertexPointer(const Vec4f* _p)
{ ::glVertexPointer(4, GL_FLOAT, 0, _p); }
/// Wrapper: glVertexPointer for Vec4d
inline void glVertexPointer(const Vec4d* _p)
{ ::glVertexPointer(4, GL_DOUBLE, 0, _p); }
{ ::ACG::GLState::vertexPointer(2, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec2d
inline void ACG::GLState::vertexPointer(const Vec2d* _p)
{ ::ACG::GLState::vertexPointer(2, GL_DOUBLE, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec3f
inline void ACG::GLState::vertexPointer(const Vec3f* _p)
{ ::ACG::GLState::vertexPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec3d
inline void ACG::GLState::vertexPointer(const Vec3d* _p)
{ ::ACG::GLState::vertexPointer(3, GL_DOUBLE, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec4f
inline void ACG::GLState::vertexPointer(const Vec4f* _p)
{ ::ACG::GLState::vertexPointer(4, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec4d
inline void ACG::GLState::vertexPointer(const Vec4d* _p)
{ ::ACG::GLState::vertexPointer(4, GL_DOUBLE, 0, _p); }
/// original method
inline void glVertexPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::glVertexPointer(n, t, s, p); }
inline void ACG::GLState::vertexPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::vertexPointer(n, t, s, p); }
//-------------------------------------------------------------- glNormalPointer
//-------------------------------------------------------------- ACG::GLState::normalPointer
/// Wrapper: glNormalPointer for Vec3f
inline void glNormalPointer(const Vec3f* _p)
{ ::glNormalPointer(GL_FLOAT, 0, _p); }
/// Wrapper: glNormalPointer for Vec3d
inline void glNormalPointer(const Vec3d* _p)
{ ::glNormalPointer(GL_DOUBLE, 0, _p); }
/// Wrapper: ACG::GLState::normalPointer for Vec3f
inline void ACG::GLState::normalPointer(const Vec3f* _p)
{ ::ACG::GLState::normalPointer(GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::normalPointer for Vec3d
inline void ACG::GLState::normalPointer(const Vec3d* _p)
{ ::ACG::GLState::normalPointer(GL_DOUBLE, 0, _p); }
/// original method
inline void glNormalPointer(GLenum t, GLsizei s, const GLvoid *p)
{ ::glNormalPointer(t, s, p); }
inline void ACG::GLState::normalPointer(GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::normalPointer(t, s, p); }
//--------------------------------------------------------------- glColorPointer
//--------------------------------------------------------------- ACG::GLState::colorPointer
/// Wrapper: glColorPointer for Vec3uc
inline void glColorPointer(const Vec3uc* _p)
{ ::glColorPointer(3, GL_UNSIGNED_BYTE, 0, _p); }
/// Wrapper: glColorPointer for Vec3f
inline void glColorPointer(const Vec3f* _p)
{ ::glColorPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::colorPointer for Vec3uc
inline void ACG::GLState::colorPointer(const Vec3uc* _p)
{ ::ACG::GLState::colorPointer(3, GL_UNSIGNED_BYTE, 0, _p); }
/// Wrapper: ACG::GLState::colorPointer for Vec3f
inline void ACG::GLState::colorPointer(const Vec3f* _p)
{ ::ACG::GLState::colorPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: glColorPointer for Vec4uc
inline void glColorPointer(const Vec4uc* _p)
{ ::glColorPointer(4, GL_UNSIGNED_BYTE, 0, _p); }
/// Wrapper: glColorPointer for Vec4f
inline void glColorPointer(const Vec4f* _p)
{ ::glColorPointer(4, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::colorPointer for Vec4uc
inline void ACG::GLState::colorPointer(const Vec4uc* _p)
{ ::ACG::GLState::colorPointer(4, GL_UNSIGNED_BYTE, 0, _p); }
/// Wrapper: ACG::GLState::colorPointer for Vec4f
inline void ACG::GLState::colorPointer(const Vec4f* _p)
{ ::ACG::GLState::colorPointer(4, GL_FLOAT, 0, _p); }
/// original method
inline void glColorPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::glColorPointer(n, t, s, p); }
inline void ACG::GLState::colorPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::colorPointer(n, t, s, p); }
//------------------------------------------------------------ glTexCoordPointer
//------------------------------------------------------------ ACG::GLState::texcoordPointer
/// Wrapper: glTexCoordPointer for float
inline void glTexCoordPointer(const float* _p)
{ ::glTexCoordPointer(1, GL_FLOAT, 0, _p); }
/// Wrapper: glTexCoordPointer for Vec2d
inline void glTexCoordPointer(const double* _p)
{ ::glTexCoordPointer(1, GL_DOUBLE, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for float
inline void ACG::GLState::texcoordPointer(const float* _p)
{ ::ACG::GLState::texcoordPointer(1, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec2d
inline void ACG::GLState::texcoordPointer(const double* _p)
{ ::ACG::GLState::texcoordPointer(1, GL_DOUBLE, 0, _p); }
/// Wrapper: glTexCoordPointer for Vec2f
inline void glTexCoordPointer(const Vec2f* _p)
{ ::glTexCoordPointer(2, GL_FLOAT, 0, _p); }
/// Wrapper: glTexCoordPointer for Vec2d
inline void glTexCoordPointer(const Vec2d* _p)
{ ::glTexCoordPointer(2, GL_DOUBLE, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec2f
inline void ACG::GLState::texcoordPointer(const Vec2f* _p)
{ ::ACG::GLState::texcoordPointer(2, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec2d
inline void ACG::GLState::texcoordPointer(const Vec2d* _p)
{ ::ACG::GLState::texcoordPointer(2, GL_DOUBLE, 0, _p); }
/// Wrapper: glTexCoordPointer for Vec3f
inline void glTexCoordPointer(const Vec3f* _p)
{ ::glTexCoordPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: glTexCoordPointer for Vec3d
inline void glTexCoordPointer(const Vec3d* _p)
{ ::glTexCoordPointer(3, GL_DOUBLE, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec3f
inline void ACG::GLState::texcoordPointer(const Vec3f* _p)
{ ::ACG::GLState::texcoordPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec3d
inline void ACG::GLState::texcoordPointer(const Vec3d* _p)
{ ::ACG::GLState::texcoordPointer(3, GL_DOUBLE, 0, _p); }
/// Wrapper: glTexCoordPointer for Vec4f
inline void glTexCoordPointer(const Vec4f* _p)
{ ::glTexCoordPointer(4, GL_FLOAT, 0, _p); }
/// Wrapper: glTexCoordPointer for Vec4d
inline void glTexCoordPointer(const Vec4d* _p)
{ ::glTexCoordPointer(4, GL_DOUBLE, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec4f
inline void ACG::GLState::texcoordPointer(const Vec4f* _p)
{ ::ACG::GLState::texcoordPointer(4, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec4d
inline void ACG::GLState::texcoordPointer(const Vec4d* _p)
{ ::ACG::GLState::texcoordPointer(4, GL_DOUBLE, 0, _p); }
/// original method
inline void glTexCoordPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::glTexCoordPointer(n, t, s, p); }
inline void ACG::GLState::texcoordPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::texcoordPointer(n, t, s, p); }
*/
//-----------------------------------------------------------------------------
......
......@@ -127,8 +127,8 @@ public:
void del() { if(valid) glDeleteBuffersARB(1, &vbo); valid = false; }
bool is_valid() const { return valid; }
void bind() { if(!valid) gen(); glBindBufferARB(target, vbo); }
void unbind() { glBindBufferARB(target, 0); }
void bind() { if(!valid) gen(); ACG::GLState::bindBuffer(target, vbo); }
void unbind() { ACG::GLState::bindBuffer(target, 0); }
void upload(GLsizeiptr size, const GLvoid* data, GLenum usage)
{
......@@ -196,7 +196,7 @@ public:
void activate()
{
if (unit != GL_NONE) glActiveTextureARB(unit);
if (unit != GL_NONE) ACG::GLState::activeTexture(unit);
}
void parameter(GLenum pname, GLint i)
......
......@@ -521,7 +521,7 @@ draw(GLState& _state, const DrawModes::DrawMode& _drawMode) {
enable_arrays(0);
// Unbind all remaining buffers
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB , 0 );
ACG::GLState::bindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB , 0 );
glPopAttrib();
}
......@@ -573,8 +573,8 @@ MeshNodeT<Mesh>::
enable_arrays(unsigned int _arrays) {
// Unbind everything to ensure sane settings
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::bindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
//===================================================================
// per Edge Vertex Array
......@@ -588,16 +588,16 @@ enable_arrays(unsigned int _arrays) {
enabled_arrays_ |= PER_EDGE_VERTEX_ARRAY;
// For this version we load the colors directly not from vbo
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glVertexPointer( drawMesh_->perEdgeVertexBuffer() );
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::vertexPointer( drawMesh_->perEdgeVertexBuffer() );
glEnableClientState(GL_VERTEX_ARRAY);
ACG::GLState::enableClientState(GL_VERTEX_ARRAY);
}
} else if (enabled_arrays_ & PER_EDGE_VERTEX_ARRAY) {
// Disable Vertex array
enabled_arrays_ &= ~PER_EDGE_VERTEX_ARRAY;
glDisableClientState(GL_VERTEX_ARRAY);
ACG::GLState::disableClientState(GL_VERTEX_ARRAY);
}
//===================================================================
......@@ -612,16 +612,16 @@ enable_arrays(unsigned int _arrays) {
enabled_arrays_ |= PER_EDGE_COLOR_ARRAY;
// For this version we load the colors directly not from vbo
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glColorPointer( drawMesh_->perEdgeColorBuffer() );
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::colorPointer( drawMesh_->perEdgeColorBuffer() );
glEnableClientState(GL_COLOR_ARRAY);
ACG::GLState::enableClientState(GL_COLOR_ARRAY);
}