当前位置: 首页>>代码示例>>C++>>正文


C++ GLSLProgram::compileShaderFromString方法代码示例

本文整理汇总了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;
}
开发者ID:cppcooper,项目名称:Rover---Recursive-Pathfinding,代码行数:32,代码来源:Shader_Manager.cpp

示例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;
}
开发者ID:Gibgezr,项目名称:blit3d,代码行数:31,代码来源:ShaderManager.cpp

示例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 );
}
开发者ID:Junch,项目名称:glewMac,代码行数:49,代码来源:main.cpp


注:本文中的GLSLProgram::compileShaderFromString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。