Commit ae3393ad authored by Jan Möbius's avatar Jan Möbius

Geometry shader support in shaderutils

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12706 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 34776b1e
......@@ -174,6 +174,13 @@ namespace GLSL {
FragmentShader::FragmentShader() : Shader(GL_FRAGMENT_SHADER) {}
FragmentShader::~FragmentShader() {}
//--------------------------------------------------------------------------
// Geometry shader
//--------------------------------------------------------------------------
GeometryShader::GeometryShader() : Shader(GL_GEOMETRY_SHADER_EXT) {}
GeometryShader::~GeometryShader() {}
//--------------------------------------------------------------------------
// Shader program object
//--------------------------------------------------------------------------
......@@ -369,6 +376,19 @@ namespace GLSL {
return attributeLocation;
}
void Program::setGeometryInputType(GLint type) {
glProgramParameteriEXT(this->m_programId, GL_GEOMETRY_INPUT_TYPE_EXT, type);
}
void Program::setGeometryOutputType(GLint type) {
glProgramParameteriEXT(this->m_programId, GL_GEOMETRY_OUTPUT_TYPE_EXT, type);
}
void Program::setGeometryVertexCount(GLint numVerticesOut){
glProgramParameteriEXT(this->m_programId, GL_GEOMETRY_VERTICES_OUT_EXT, numVerticesOut);
}
/** \brief Loads the shader source
*
* The shader is assumed to be placed in ../shader relative to the
......@@ -430,6 +450,20 @@ namespace GLSL {
return fragmentShader;
}
/** \brief Loads, compiles and installs a new vertex shader.
*/
GLSL::PtrGeometryShader loadGeometryShader(const char *name) {
PtrGeometryShader geometryShader = 0;
StringList sourceVertex = loadShader(name);
if (sourceVertex.size() != 0) {
geometryShader = GLSL::PtrGeometryShader(new GLSL::GeometryShader());
geometryShader->setSource(sourceVertex);
geometryShader->compile();
}
return geometryShader;
}
}
......
......@@ -125,6 +125,20 @@ namespace GLSL {
//--------------------------------------------------------------------------
/** \brief GLSL geometry shader.
*/
class ACGDLLEXPORT GeometryShader : public Shader {
public:
GeometryShader();
virtual ~GeometryShader();
};
typedef GeometryShader* PtrGeometryShader;
typedef const GeometryShader* PtrConstGeometryShader;
//--------------------------------------------------------------------------
/** \brief GLSL program class.
*
* A GLSL program links together the vertex and fragment shaders.
......@@ -157,6 +171,19 @@ namespace GLSL {
int getAttributeLocation(const char *name);
int getUniformLocation(const char *name);
// geometry shader params
// valid input types: GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_EXT, GL_TRIANGLES, GL_TRIANGLES_ADJACENCY_EXT
void setGeometryInputType(GLint type);
// valid output types: GL_POINTS, GL_LINE_STRIP, GL_TRIANGLE_STRIP
void setGeometryOutputType(GLint type);
// Sets the maximum vertex output of the geometry shader.
// query GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT to get the gpu limitation
void setGeometryVertexCount(GLint numVerticesOut);
void use();
void disable();
......@@ -178,6 +205,7 @@ namespace GLSL {
GLSL::PtrVertexShader ACGDLLEXPORT loadVertexShader(const char *name);
GLSL::PtrFragmentShader ACGDLLEXPORT loadFragmentShader(const char *name);
GLSL::PtrGeometryShader ACGDLLEXPORT loadGeometryShader(const char *name);
}
......
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