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


C++ Shader::Load方法代码示例

本文整理汇总了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;
}
开发者ID:Jackson-Luff,项目名称:GenGein-Graphics-Engine,代码行数:7,代码来源:SProgram.cpp

示例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;
}
开发者ID:Jackson-Luff,项目名称:GenGein-Graphics-Engine,代码行数:33,代码来源:SProgram.cpp

示例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);
}
开发者ID:segfault11,项目名称:GraphicsProgrammingPractice,代码行数:44,代码来源:Program.cpp

示例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;
};
开发者ID:droidenko,项目名称:dava.framework,代码行数:40,代码来源:MaterialCompiler.cpp

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


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