本文整理汇总了C++中VertexShader::handle方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexShader::handle方法的具体用法?C++ VertexShader::handle怎么用?C++ VertexShader::handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexShader
的用法示例。
在下文中一共展示了VertexShader::handle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
ShaderProgram::ShaderProgram(
const string &filename,
const VertexShader &vertexShader,
const FragmentShader &fragmentShader) : _name(filename), _handle(0), _linked(0)
{
try
{
if (vertexShader.fail()) throw std::runtime_error("Invalid vertex shader");
if (fragmentShader.fail()) throw std::runtime_error("Invalid fragment shader");
if (GLEW_VERSION_2_0)
{
// Create program and attach vertex and fragment shaders
_handle = glCreateProgram();
glAttachShader(_handle, vertexShader.handle());
glAttachShader(_handle, fragmentShader.handle());
// Perform link stage
glLinkProgram(_handle);
glGetProgramiv(_handle, GL_LINK_STATUS, &_linked);
// Validate program
glValidateProgram(_handle);
printInfoLog();
// Check for success
if (GL_FALSE == _linked)
throw std::runtime_error("Link stage failed");
}
else if (GLEW_VERSION_1_5)
{
// Create program and attach vertex and fragment shaders
_handle = glCreateProgramObjectARB();
glAttachObjectARB(_handle, vertexShader.handle());
glAttachObjectARB(_handle, fragmentShader.handle());
// Perform link stage
glLinkProgramARB(_handle);
glGetObjectParameterivARB(_handle, GL_OBJECT_LINK_STATUS_ARB, &_linked);
// Validate program
glValidateProgramARB(_handle);
printInfoLog();
// Check for success
if (GL_FALSE == _linked)
throw std::runtime_error("Link stage failed");
}
cout << "* Shader \"" << _name << "\" successfully linked" << endl;
}
catch (std::runtime_error &err)
{
cerr << "Error: Faild to create shader " << _name << endl;
cerr << "Reason: " << err.what() << endl;
}
}