...
 
Commits (1)
# Try to find glslang/SPIRV
# Once done, this will define
# SPIRV_FOUND
# SPIRV_INCLUDE_DIR
# SPIRV_LIBRARIES
## SPIRV
find_path(SPIRV_INCLUDE_DIR
NAMES SPIRV/SpvTools.h
PATHS "${CMAKE_SOURCE_DIR}/"
DOC "SPIRV Include Directory"
)
find_library(SPIRV_LIBRARY
NAMES SPIRV
PATHS "${CMAKE_SOURCE_DIR}/"
DOC "SPIRV Libraries"
)
IF (SPIRV_LIBRARY)
SET(SPIRV_FOUND TRUE)
ELSE(SPIRV_LIBRARY)
SET(SPIRV_FOUND FALSE)
ENDIF(SPIRV_LIBRARY)
# Try to find glslang
# Once done, this will define
# GLSLANG_FOUND
# GLSLANG_INCLUDE_DIR
# GLSLANG_LIBRARY
#
# SPIRV_FOUND
# SPIRV_INCLUDE_DIR
# SPIRV_LIBRARIES
## GLSLANG core
find_path(GLSLANG_INCLUDE_DIR
NAMES glslang/Include/Common.h
PATHS "${CMAKE_SOURCE_DIR}/"
/home/
DOC "GLSLANG Include Directory"
)
find_library(GLSLANG_LIBRARY
NAMES glslang
PATHS "${CMAKE_SOURCE_DIR}/"
/usr/
/home/
DOC "GLSLANG Libraries"
)
IF (GLSLANG_LIBRARY AND GLSLANG_INCLUDE_DIR)
SET(GLSLANG_FOUND TRUE)
ELSE(GLSLANG_LIBRARY AND GLSLANG_INCLUDE_DIR)
SET(GLSLANG_FOUND FALSE)
ENDIF(GLSLANG_LIBRARY AND GLSLANG_INCLUDE_DIR)
......@@ -1860,6 +1860,49 @@ GLuint GLState::getBoundBuf(GLenum _target)
return stateStack_.back().glBufferTargetState_[getBufferTargetIndex(_target)];
}
GLenum GLState::getShaderType(GLuint _shader)
{
auto isShader = glIsShader(_shader);
if(isShader == GL_FALSE) { return GL_NONE; }
GLint type = GL_NONE;
glGetShaderiv(_shader, GL_SHADER_TYPE, &type);
return static_cast<GLenum>(type);
}
GLuint GLState::getAttachedShader(GLuint _program, GLenum _type)
{
if(glIsProgram(_program) == GL_FALSE) { return GL_NONE; }
// vertex, fragment, tess control, tess eval, geometry
static const GLsizei maxNumShaders = 5;
GLuint shaders[maxNumShaders] = {};
GLsizei numShaders = 0;
glGetAttachedShaders(_program, maxNumShaders, &numShaders, shaders);
for(auto i = 0; i < numShaders; ++i) {
const auto& shader = shaders[i];
if(getShaderType(shader) == _type) {
return shader;
}
}
return GL_NONE;
}
size_t GLState::getShaderSourceLength(GLuint _shader)
{
if(glIsShader(_shader) == GL_FALSE) { return 0; }
GLint length = 0;
glGetShaderiv(_shader, GL_SHADER_SOURCE_LENGTH, &length);
return static_cast<size_t>(length);
}
size_t GLState::getShaderSource(GLuint _shader, char *_buffer, size_t _bufferSize)
{
if(glIsShader(_shader) == GL_FALSE) { return 0; }
GLsizei length = 0;
glGetShaderSource(_shader, static_cast<GLsizei>(_bufferSize), &length, _buffer);
return static_cast<size_t>(length);
}
//-----------------------------------------------------------------------------
void GLState::activeTexture(GLenum _texunit)
......@@ -2207,6 +2250,11 @@ GLboolean GLState::unmapBuffer (GLenum target) {
return glUnmapBuffer(target);
}
size_t GLState::getBufferSize(GLenum target) {
GLint size = 0;
glGetBufferParameteriv(target, GL_BUFFER_SIZE, &size);
return static_cast<size_t>(size);
}
//---------------------------------------------------------------------
......
......@@ -570,6 +570,12 @@ public:
*/
static GLboolean unmapBuffer (GLenum target);
/**
* Wraps glGetBufferParameteriv for GL_BUFFER_SIZE
* Useful where glew cannot be included
*/
static size_t getBufferSize(GLenum _target);
/**
* Simple wrapper around glDeleteBuffers.
* Useful where glew cannot be included.
......@@ -593,7 +599,26 @@ public:
/// get currently bound buffer
static GLuint getBoundBuf(GLenum _target);
/// get the type of a shader object
/// returns GL_NONE if the passed name doesn't identify a valid shader object
static GLenum getShaderType(GLuint _shader);
/// get the length of a shaders source
/// returns 0 on failure
static size_t getShaderSourceLength(GLuint _shader);
/// get glsl source from a shader object
/// expects a char array of sufficient size, size can be queried with getShaderSourceLength() before calling this
/// returns the actual size of the source string, excluding null terminator
static size_t getShaderSource(GLuint _shader, char* _buffer, size_t _bufferSize);
/// get the attached shader of type of a program
/// NOTE: this assumes that only _one_ shader of any type is attached to the program!
/// returns GL_NONE if the program doesn't have a shader of requested type attached or if the passed name doesn't
/// identify a valid shader program
static GLuint getAttachedShader(GLuint _program, GLenum _type);
/// replaces glDrawBuffer, supports locking
static void drawBuffer(GLenum _mode);
/// replaces glDrawBuffers, supports locking
......
......@@ -167,7 +167,7 @@ struct ACGDLLEXPORT RenderObject
/// VBO, IBO ids, ignored if VAO is provided
GLuint vertexBuffer,
indexBuffer;
indexBuffer;
/** \brief Use system memory index buffer
*
......