本文整理汇总了C++中GLShader::getGLHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ GLShader::getGLHandle方法的具体用法?C++ GLShader::getGLHandle怎么用?C++ GLShader::getGLHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLShader
的用法示例。
在下文中一共展示了GLShader::getGLHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resourceLoaded
void GLMaterial::resourceLoaded(const resource::ResourceEvent& evt)
{
if (evt.source != nullptr)
{
if (evt.source == mVertexShader)
{
GLShader* pGLShader = static_cast<GLShader*>(mVertexShader);
if (pGLShader != nullptr)
{
glAttachShader(mGLHandle, pGLShader->getGLHandle());
}
}
if (evt.source == mFragmentShader)
{
GLShader* pGLShader = static_cast<GLShader*>(mFragmentShader);
if (pGLShader != nullptr)
{
glAttachShader(mGLHandle, pGLShader->getGLHandle());
}
}
if (evt.source == mGeometryShader)
{
GLShader* pGLShader = static_cast<GLShader*>(mGeometryShader);
if (pGLShader != nullptr)
{
glAttachShader(mGLHandle, pGLShader->getGLHandle());
}
}
if (((mVertexShader == nullptr) || (mVertexShader != nullptr && mVertexShader->getState() == resource::RESOURCE_STATE_LOADED)) &&
((mFragmentShader == nullptr) || (mFragmentShader != nullptr && mFragmentShader->getState() == resource::RESOURCE_STATE_LOADED)) &&
((mGeometryShader == nullptr) || (mGeometryShader != nullptr && mGeometryShader->getState() == resource::RESOURCE_STATE_LOADED)))
{
GLint linked;
glLinkProgram(mGLHandle);
glGetProgramiv(mGLHandle, GL_LINK_STATUS, &linked);
if (linked == 1)
{
char uniformName[PARAMETER_NAME_BUFFERSIZE];
GLenum type;
GLint size;
GLint count;
glGetProgramiv(mGLHandle, GL_ACTIVE_UNIFORMS, &count);
for (GLint idx=0; idx<count; idx++)
{
glGetActiveUniform(mGLHandle, idx, PARAMETER_NAME_BUFFERSIZE, NULL, &size, &type, uniformName);
if (type != GL_SAMPLER_1D && type != GL_SAMPLER_2D && type != GL_SAMPLER_3D)
continue;
ShaderParameterType paramType = SHADER_PARAMETER_TYPE_UNKNOWN;
switch (type)
{
case GL_SAMPLER_1D:
paramType = SHADER_PARAMETER_TYPE_SAMPLER1D;
break;
case GL_SAMPLER_2D:
paramType = SHADER_PARAMETER_TYPE_SAMPLER2D;
break;
case GL_SAMPLER_3D:
paramType = SHADER_PARAMETER_TYPE_SAMPLER3D;
break;
}
addTextureParameter(std::string(uniformName), paramType);
}
//////////////////////////////////
for (unsigned int i = 0; i < mVertexParameters.size(); i++)
{
GLShaderVertexParameter* pGLShaderVertexParameter = static_cast<GLShaderVertexParameter*>(mVertexParameters[i]);
if (pGLShaderVertexParameter == nullptr)
continue;
pGLShaderVertexParameter->ParameterID = glGetAttribLocation(mGLHandle, pGLShaderVertexParameter->mName.c_str());
}
hashmap<std::string, ShaderParameter*>::iterator pi;
for (pi = mParameters.begin(); pi != mParameters.end(); ++pi)
{
GLShaderParameter* pGLShaderParameter = static_cast<GLShaderParameter*>(pi->second);
if (pGLShaderParameter == nullptr)
continue;
pGLShaderParameter->ParameterID = glGetUniformLocation(mGLHandle, pi->first.c_str());
}
//////////////////////////////////
}
}
}
}