OpenGLRenderer/Program: Add query methods
This commit is contained in:
@@ -11,11 +11,126 @@ namespace Nz::GL
|
||||
inline void Program::AttachShader(GLuint shader)
|
||||
{
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
context.glAttachShader(m_objectId, shader);
|
||||
}
|
||||
|
||||
inline void Program::Get(GLenum pname, GLint* params) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
return context.glGetProgramiv(m_objectId, pname, params);
|
||||
}
|
||||
|
||||
inline void Program::GetActiveUniform(GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
return context.glGetActiveUniform(m_objectId, index, bufSize, length, size, type, name);
|
||||
}
|
||||
|
||||
inline void Program::GetActiveUniformBlock(GLuint uniformBlockIndex, GLenum pname, GLint* params) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
return context.glGetActiveUniformBlockiv(m_objectId, uniformBlockIndex, pname, params);
|
||||
}
|
||||
|
||||
inline std::vector<GLint> Program::GetActiveUniformBlockUniformIndices(GLuint uniformBlockIndex) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
std::vector<GLint> uniformIndices;
|
||||
|
||||
GLint activeUniformCount = 0;
|
||||
context.glGetActiveUniformBlockiv(m_objectId, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &activeUniformCount);
|
||||
|
||||
if (activeUniformCount > 0)
|
||||
{
|
||||
uniformIndices.resize(static_cast<std::size_t>(activeUniformCount));
|
||||
context.glGetActiveUniformBlockiv(m_objectId, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, uniformIndices.data());
|
||||
}
|
||||
|
||||
return uniformIndices;
|
||||
}
|
||||
|
||||
inline void Program::GetActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
return context.glGetActiveUniformBlockName(m_objectId, uniformBlockIndex, bufSize, length, uniformBlockName);
|
||||
}
|
||||
|
||||
inline std::vector<GLint> Program::GetActiveUniforms(GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
std::vector<GLint> values(uniformCount);
|
||||
context.glGetActiveUniformsiv(m_objectId, uniformCount, uniformIndices, pname, values.data());
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
inline void Program::GetActiveUniforms(GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
return context.glGetActiveUniformsiv(m_objectId, uniformCount, uniformIndices, pname, params);
|
||||
}
|
||||
|
||||
inline std::string Program::GetActiveUniformBlockName(GLuint uniformBlockIndex) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
std::string name;
|
||||
|
||||
GLint nameLength = 0;
|
||||
context.glGetActiveUniformBlockiv(m_objectId, uniformBlockIndex, GL_UNIFORM_BLOCK_NAME_LENGTH, &nameLength);
|
||||
|
||||
if (nameLength > 0)
|
||||
{
|
||||
name.resize(nameLength);
|
||||
|
||||
context.glGetActiveUniformBlockName(m_objectId, uniformBlockIndex, nameLength + 1, nullptr, name.data());
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
inline std::string Program::GetActiveUniformName(GLuint index) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
std::string name;
|
||||
|
||||
GLint maxNameLength = 0;
|
||||
context.glGetProgramiv(m_objectId, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameLength);
|
||||
|
||||
if (maxNameLength > 0)
|
||||
{
|
||||
name.resize(maxNameLength);
|
||||
|
||||
GLsizei length;
|
||||
GLint size;
|
||||
GLenum type;
|
||||
context.glGetActiveUniform(m_objectId, index, maxNameLength, &length, &size, &type, name.data());
|
||||
|
||||
name.resize(length);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
inline bool Program::GetLinkStatus(std::string* error) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
@@ -45,6 +160,19 @@ namespace Nz::GL
|
||||
return true;
|
||||
}
|
||||
|
||||
inline GLuint Program::GetUniformBlockIndex(const char* uniformBlockName) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
return context.glGetUniformBlockIndex(m_objectId, uniformBlockName);
|
||||
}
|
||||
|
||||
inline GLuint Program::GetUniformBlockIndex(const std::string& uniformBlockName) const
|
||||
{
|
||||
return GetUniformBlockIndex(uniformBlockName.c_str());
|
||||
}
|
||||
|
||||
inline GLint Program::GetUniformLocation(const char* uniformName) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
|
||||
Reference in New Issue
Block a user