Commit a79ddb60 authored by Robert Menzel's avatar Robert Menzel

added sampler objects

parent 16474f3d
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2012, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_OPENGL_OBJECTS_SAMPLER_HH
#define ACGL_OPENGL_OBJECTS_SAMPLER_HH
#include <ACGL/ACGL.hh>
#include <ACGL/Base/Macros.hh>
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh>
namespace ACGL{
namespace OpenGL{
/*
* OpenGL Sampler Objects
*/
#if (ACGL_OPENGL_VERSION >= 33)
class Sampler {
ACGL_NOT_COPYABLE(Sampler)
public:
Sampler()
{
glGenSamplers(1, &mObjectName);
if (openGLCriticalErrorOccured() ) {
ACGL::Utils::error() << "could not generate sampler!" << std::endl;
mObjectName = 0;
return;
}
}
~Sampler(void)
{
// sampler 0 will get ignored by OpenGL
glDeleteSamplers(1, &mObjectName);
}
// ==================================================================================================== \/
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
public:
inline GLuint operator() (void) const { return mObjectName; }
inline GLuint getObjectName(void) const { return mObjectName; }
// ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/
// ===================================================================================================== \/
inline void bind(GLuint _textureUnit) const
{
glBindSampler( _textureUnit, mObjectName ); // yes, no adding of GL_TEXTURE0 !
openGLRareError();
}
//! generic parameter setting
inline void parameter( GLenum _parameterName, GLint _parameter ) { glSamplerParameteri( mObjectName, _parameterName, _parameter ); }
inline void parameter( GLenum _parameterName, GLfloat _parameter ) { glSamplerParameterf( mObjectName, _parameterName, _parameter ); }
private:
GLuint mObjectName;
};
ACGL_SHARED_TYPEDEF(Sampler)
#endif // OpenGL >= 3.3
} // OpenGL
} // ACGL
#endif // ACGL_OPENGL_OBJECTS_SAMPLER_HH
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