本文整理汇总了C++中Shader::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ Shader::Load方法的具体用法?C++ Shader::Load怎么用?C++ Shader::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shader
的用法示例。
在下文中一共展示了Shader::Load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenShader
Shader& GenShader(std::string a_dir, ShaderID a_ID)
{
Shader* shader = new Shader();
shader->Load(a_dir, a_ID);
return *shader;
}
示例2: AttachShader
bool SProgram::AttachShader(const char* a_directory, ShaderID a_type)
{
Shader* shader = new Shader();
if (!shader->Load(a_directory, a_type))
return false;
shader->AttachToProgram(m_programID);
switch (a_type)
{
case ShaderID::VERT_SHADER:
m_vertShader = shader;
break;
case ShaderID::FRAG_SHADER:
m_fragShader = shader;
break;
case ShaderID::GEOM_SHADER:
m_geomShader = shader;
break;
case ShaderID::TESSC_SHADER:
m_tessCShader = shader;
break;
case ShaderID::TESSE_SHADER:
m_tessEShader = shader;
break;
case ShaderID::DEFAULT:
return false;
default:
return false;
}
return true;
}
示例3: Shader
//------------------------------------------------------------------------------
void GL::Program::AttachShader(const char* filename, GLenum type)
{
if (compiled_)
{
ERROR_WARNING("Program is already compiled.");
return;
}
Shader* shader = new Shader();
shader->Load(filename, type);
// check if a shader was already attached
switch (type)
{
case GL_VERTEX_SHADER:
if (vertexShader_)
{
glDetachShader(program_, *vertexShader_);
delete vertexShader_;
ERROR_WARNING("Vertex shader was replaced.")
}
vertexShader_ = shader;
break;
case GL_FRAGMENT_SHADER:
if (fragmentShader_)
{
glDetachShader(program_, *fragmentShader_);
delete fragmentShader_;
ERROR_WARNING("Vertex shader was replaced.")
}
fragmentShader_ = shader;
break;
}
glAttachShader(program_, *shader);
}
示例4: Compile
MaterialCompiler::eCompileResult MaterialCompiler::Compile(MaterialGraph * _materialGraph, PolygonGroup * _polygonGroup, uint32 maxLights, NMaterial ** resultMaterial)
{
materialGraph = _materialGraph;
polygonGroup = _polygonGroup;
MaterialGraphNode * rootResultNode = materialGraph->GetNodeByName("material");
if (!rootResultNode)
{
return COMPILATION_FAILED;
}
currentMaterial = new NMaterial(maxLights);
RecursiveSetDepthMarker(rootResultNode, 0);
materialGraph->SortByDepthMarkerAndRemoveUnused();
MaterialGraphNode::RecursiveSetRealUsageBack(rootResultNode);
MaterialGraphNode::RecursiveSetRealUsageForward(rootResultNode);
materialCompiledVshName = FilePath::CreateWithNewExtension(materialGraph->GetMaterialPathname(), ".vsh");
materialCompiledFshName = FilePath::CreateWithNewExtension(materialGraph->GetMaterialPathname(), ".fsh");
#if 1
materialCompiledVshName = "~doc:/temp.vsh";
materialCompiledFshName = "~doc:/temp.fsh";
#endif
GenerateCode(materialGraph);
Shader * shader = new Shader();
shader->Load(materialCompiledVshName, materialCompiledFshName);
shader->RecompileAsync();
currentMaterial->SetShader(0, shader);
*resultMaterial = currentMaterial;
return COMPILATION_SUCCESS;
};
示例5: main
int main()
{
Game game(800, 600, "Hello World", false);
Shader shader;
shader.Load("./res/shader");
Mesh mesh;
/*const GLfloat vertices[] = {
-0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 0.0f, // Top-left
0.5f, 0.5f, 1.0f, 0.0f, 1.0f, 0.0f, // Top-right
0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, // Bottom-right
-0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f // Bottom-left
};*/
Vertex vertices[] = { Vertex(glm::vec3(-0.5, 0.5, 1.0), glm::vec3(0.0, 1.0, 0.0)),
Vertex(glm::vec3(0.5, 0.5, 1.0), glm::vec3(1.0, 1.0, 0.0)),
Vertex(glm::vec3(0.5, -0.5, 1.0), glm::vec3(0.0, 0.0, 1.0)),
Vertex(glm::vec3(-0.5, -0.5, 1.0), glm::vec3(0.0, 0.0, 0.0)), };
///setup element array buffer
GLuint elements[] = {
0, 1, 2,
2, 3, 0,
};
GLuint ebo;
glGenBuffers(1, &ebo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
sizeof(elements), elements, GL_STATIC_DRAW);
cout << "Shader programID is: " << shader.GetProgramID() << endl;
mesh.Init(&vertices[0], 4, shader.GetProgramID());
GLenum errCode;
const GLubyte* errString;
errCode = glGetError();
if (errCode != GL_NO_ERROR)
{
cout << "GL error code: " << errCode << endl;
ofstream ofs;
ofs.open("glerror.txt");
ofs << errCode << endl;
ofs.close();
}
if(glIsProgram(shader.GetProgramID()) == GL_FALSE)
{
cout << "The program with id " << shader.GetProgramID() << " does not exist." << endl;
}
else
{
cout << "Shader with program id " << shader.GetProgramID() << " has been created." << endl;
}
float counter = 0.0f;
while(!game.isClosed)
{
game.PollInput();
game.GetWindow()->r = sinf(counter);
game.GetWindow()->g = cosf(counter);
game.GetWindow()->b = cosf(counter);
game.Update();
counter += 0.01f;
if(counter >= 360.0f)
{
counter = 0.0f;
}
}
glDeleteShader(shader.GetProgramID());
game.Quit();
return 0;
}