本文整理汇总了C++中GLSLProgram::compileShaderFromString方法的典型用法代码示例。如果您正苦于以下问题:C++ GLSLProgram::compileShaderFromString方法的具体用法?C++ GLSLProgram::compileShaderFromString怎么用?C++ GLSLProgram::compileShaderFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLSLProgram
的用法示例。
在下文中一共展示了GLSLProgram::compileShaderFromString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromStrings
//Loads and compiles vertice and fragment shaders from strings into one GLSLProgram*
GLSLProgram* ShaderManager::LoadFromStrings(std::string vertName, std::string fragName, std::string vertString, std::string fragString)
{
GLSLProgram* prog = new GLSLProgram();
///Compile the vertex portion of the shader
if(!prog->compileShaderFromString(vertString, GLSLShader::VERTEX))
{
printf("Vertex shader failed to compile from string!\n%s", prog->log().c_str());
assert(false && "Vertex shader failed to compile from string");
return NULL;
}
///Compile the fragment portion of the shader
if(!prog->compileShaderFromString(fragString, GLSLShader::FRAGMENT))
{
printf("Fragment shader failed to compile from string!\n%s", prog->log().c_str());
assert(false && "Fragment shader failed to compile from string");
return NULL;
}
///Links the shader to OpenGL using the handle obtained during the compile
if ( !prog->link() )
{
printf("Shader program failed to link!\n%s", prog->log().c_str());
assert(false && "Shader program failed to link.");
return NULL;
}
assert(prog != NULL);
return prog;
}
示例2: LoadFromStrings
GLSLProgram* ShaderManager::LoadFromStrings(const char* vertName, const char*fragName, std::string vertString, std::string fragString)
{
GLSLProgram* prog = new GLSLProgram();
if(!prog->compileShaderFromString(vertString, GLSLShader::VERTEX))
{
printf("Vertex shader failed to compile from string!\n%s", prog->log().c_str());
sLog(Level::Severe) << "Vertex shader <" << vertName << "> failed to compile from string." << prog->log();
assert(false && "Vertex shader failed to compile from string");
return NULL;
}
if(!prog->compileShaderFromString(fragString, GLSLShader::FRAGMENT))
{
printf("Fragment shader failed to compile from string!\n%s", prog->log().c_str());
sLog(Level::Severe) << "Fragment shader <" << fragName << "> failed to compile from string." << prog->log();
assert(false && "Fragment shader failed to compile from string");
return NULL;
}
if(!prog->link())
{
printf("Shader program failed to link!\n%s", prog->log().c_str());
sLog(Level::Severe) << "Shader program failed to link." << prog->log();
assert(false && "Shader program failed to link.");
return NULL;
}
assert(prog != NULL);
return prog;
}
示例3: SetupRC
///////////////////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering context.
// This is the first opportunity to do any OpenGL related tasks.
void SetupRC()
{
// Black background
glClearColor(0.0f , 0.0f , 0.0f , 1.0f );
prog.compileShaderFromString (szIdentityShaderVP, GLSLShader:: VERTEX);
prog.compileShaderFromString (szIdentityShaderFP, GLSLShader:: FRAGMENT);
prog.link ();
prog.use ();
/////////////////// Create the VBO ////////////////////
GLfloat positionData [] = {
-0.8f, -0.8f , 0.0f ,
0.8f, -0.8f, 0.0f,
0.0f, 0.8f, 0.0f };
GLfloat colorData[] = {
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f };
// Create and populate the buffer objects
GLuint vboHandles[2];
glGenBuffers(2, vboHandles);
GLuint positionBufferHandle = vboHandles[0];
GLuint colorBufferHandle = vboHandles[1];
glBindBuffer(GL_ARRAY_BUFFER, positionBufferHandle);
glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(GLfloat), positionData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, colorBufferHandle);
glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(GLfloat), colorData, GL_STATIC_DRAW);
// Create and set-up the vertex array object
glGenVertexArrays( 1, &vaoHandle );
glBindVertexArray(vaoHandle);
glEnableVertexAttribArray(0); // Vertex position
glEnableVertexAttribArray(1); // Vertex color
glBindBuffer(GL_ARRAY_BUFFER, positionBufferHandle);
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );
glBindBuffer(GL_ARRAY_BUFFER, colorBufferHandle);
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );
}