Exemple #1
0
ShaderType
UsdRiMaterialAPI::_GetSourceShaderObject(const UsdShadeOutput &output,
                                         bool ignoreBaseMaterial) const
{
    // If output doesn't have a valid property, return an invalid shader.
    if (!output.GetProperty()) {
        return ShaderType();
    }

    if (ignoreBaseMaterial && 
        UsdShadeConnectableAPI::IsSourceConnectionFromBaseMaterial(output)) {
        return ShaderType();
    }

    UsdShadeConnectableAPI source;
    TfToken sourceName;
    UsdShadeAttributeType sourceType;

    if (UsdShadeConnectableAPI::GetConnectedSource(output, 
            &source, &sourceName, &sourceType)) {
        return ShaderType(source.GetPrim());
    }

    return ShaderType();
}
bool CGLCommonGpuProgram::Compile(const string& src)
{
	GLint shaderType = ShaderType();
	GLuint shaderObjHandle = glCreateShader(shaderType);

	// compile
	const GLchar* shaderSrcArray[] = { src.c_str() };
	glShaderSource(shaderObjHandle, 1, shaderSrcArray, nullptr);
	glCompileShader(shaderObjHandle);

	// check if there is any error
	GLint result;
	glGetShaderiv(shaderObjHandle, GL_COMPILE_STATUS, &result);
	if (result == GL_FALSE)
	{
		glGetShaderiv(shaderObjHandle, GL_INFO_LOG_LENGTH, &result);
		char* errorStr = new char[result];

		glGetShaderInfoLog(shaderObjHandle, result, nullptr, errorStr);
		Debug::Print(boost::wformat(TEXT("glGetShaderInfoLog : %1%")) % errorStr);
		m_ErrorString = errorStr;

		Safe_Delete(errorStr);
		return false;
	}

	m_ErrorString.clear();
	m_ShaderProgramHandle = shaderObjHandle;

	return true;
}
    /**
     *  @note This function does not apply the changes to the actual
     *  uniform variables in the stage of the program. Use Apply
     *  function to do this after the subroutines are assigned.
     *
     *  @see Apply
     */
    UniformSubroutines& Assign(
      const SubroutineUniform& uniform, const Subroutine& subroutine) {
        assert(uniform.Program() == _program);
        assert(subroutine.Program() == _program);
        assert(uniform.Stage() == ShaderType(_stage));
        assert(subroutine.Stage() == ShaderType(_stage));
        assert(subroutine.Location() >= 0);
        assert(uniform.IsActive());
        assert(uniform.Location() <= GLint(_get_indices().size()));
        assert(uniform.Location() >= 0);

        _get_indices()[std::size_t(uniform.Location())] =
          GLuint(subroutine.Location());

        return *this;
    }
Exemple #4
0
ShaderGroup::ShaderGroup(void) : m_pVertexShader(nullptr),
								 m_pPixelShader(nullptr),
								 m_type(ShaderType(0)),
								 m_isInitialised(false)
{
}