當前位置: 首頁>>代碼示例>>C++>>正文


C++ AddShader函數代碼示例

本文整理匯總了C++中AddShader函數的典型用法代碼示例。如果您正苦於以下問題:C++ AddShader函數的具體用法?C++ AddShader怎麽用?C++ AddShader使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AddShader函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: Init

bool NullTechnique::Init()
{
    if (!Technique::Init()) {
        return false;
    }

    if (!AddShader(GL_VERTEX_SHADER, "../shaders/null_technique_vertex.glsl")) {
        return false;
    }

    if (!AddShader(GL_FRAGMENT_SHADER, "../shaders/null_technique_fragment.glsl")) {
        return false;
    }

    if (!Finalize()) {
        return false;
    }

    m_WVPLocation = GetUniformLocation("gWVP");

  if (m_WVPLocation == INVALID_UNIFORM_LOCATION) {
    return false;
  }

  return true;
}
開發者ID:nburfield,項目名稱:CS791-Advanced-Computer-Graphics,代碼行數:26,代碼來源:null_technique.cpp

示例2: AddShader

//-------------------------------------------------------------------------------------------------
WorldShader::WorldShader( const char *name ) {
	AddShader( "glsl\\worldshader.v.glsl", GL_VERTEX_SHADER );
	AddShader( "glsl\\worldshader.f.glsl", GL_FRAGMENT_SHADER );
	Link();
	
	AddUniform( u_pattern_sampler, "sampler_patterns" );
	AddUniform( u_noise_sampler, "sampler_noise" );
	AddUniform( u_global_translation, "global_translation" );
	AddUniform( u_camera, "camera" );
	AddUniform( u_skylight_color, "skylight_color" );
	AddUniform( u_skylight_intensity, "skylight_intensity" );
	AddUniform( u_fog_distance, "fog_distance" );
	AddUniform( u_fog_length, "fog_length" );
	
	AddAttribute( a_instance_translation, "instance_translation", 1 );
	AddAttribute( a_instance_form, "instance_form", 1 );
	AddAttribute( a_instance_texture, "instance_texture", 1 );
	AddAttribute( a_instance_color, "instance_color", 1, 4 );
	//AddAttribute( attribInstanceColor2, "instance_color_2", 1 );
	//AddAttribute( attribInstanceColor3, "instance_color_3", 1 );
	//AddAttribute( attribInstanceColor4, "instance_color_4", 1 );

	AddUniform( u_texture_sampler, "sampler_texture" );
	AddUniform( u_texture_translation, "texture_translation" );
	AddUniform( u_opacity, "opacity" );
	AddUniform( u_fog_color, "fog_color" );

	AddUniform( u_light_brightness, "light_brightness" );
	AddUniform( u_light_colors, "light_colors" );
	AddUniform( u_light_positions, "light_positions" );

	Register( name );
}
開發者ID:mukunda-,項目名稱:The-Unbound-Project,代碼行數:34,代碼來源:WorldShader.cpp

示例3: Init

bool BlurTech::Init()
{
    if (!Technique::Init()) {
        return false;
    }

    if (!AddShader(GL_VERTEX_SHADER, "../tutorial46/shaders/blur.vs")) {
        return false;
    }


    if (!AddShader(GL_FRAGMENT_SHADER, "../tutorial46/shaders/blur.fs")) {
        return false;
    }

    if (!Finalize()) {
        return false;
    }

    m_inputTextureUnitLocation = GetUniformLocation("gColorMap");

	if (m_inputTextureUnitLocation == INVALID_UNIFORM_LOCATION) {
		return false;
	}
    
    Enable();
    
    glUniform1i(m_inputTextureUnitLocation, INPUT_TEXTURE_UNIT_INDEX);

	return true;
}
開發者ID:andriyut,項目名稱:ogldev,代碼行數:31,代碼來源:blur_tech.cpp

示例4: Init

bool LightingTechnique::Init()
{
	if (!Technique::Init()) {
		return false;
	}

	if (!AddShader(GL_VERTEX_SHADER, "lighting.vs")) {
		return false;
	}

	if (!AddShader(GL_FRAGMENT_SHADER, "lighting.fs")) {
		return false;
	}

	if (!Finalize()) {
		return false;
	}

	m_WVPLocation = GetUniformLocation("gWVP");
	m_samplerLocation = GetUniformLocation("gSampler");
	m_dirLightColorLocation = GetUniformLocation("gDirectionalLight.Color");
	m_dirLightAmbientIntensityLocation = GetUniformLocation("gDirectionalLight.AmbientIntensity");

	if (m_dirLightAmbientIntensityLocation == 0xFFFFFFFF ||
		m_WVPLocation == 0xFFFFFFFF ||
		m_samplerLocation == 0xFFFFFFFF ||
		m_dirLightColorLocation == 0xFFFFFFFF)
	{
		return false;
	}

	return true;
}
開發者ID:qunny0,項目名稱:FTools,代碼行數:33,代碼來源:Lighting_technique.cpp

示例5: Create

    static inline const program_t& Create(const std::string& mat_name , const std::string& preprocessorDefinitions = std::string())
    {
        const uint16_t version = GLSL_VERSION;
        const std::string  comp_str = GLSL_VERSION>=150 ?" compatibility":"";

        const std::string  mat_name_cut = GetMaterialName(mat_name);

        if(GetPrograms().find(mat_name_cut)==GetPrograms().end())
        {
            program_t p;
            p.program = new osg::Program;
            p.program->setName(mat_name_cut);

            static osg::Shader* ssv = AddShader(shaders::VS, "shadow", version, comp_str, string());
            static osg::Shader* ssf = AddShader(shaders::FS, "shadow", version, comp_str, string());

            p.program->addShader( ssv );
            p.program->addShader( ssf );
            
            p.program->addShader( AddShader(shaders::VS, mat_name_cut, version, comp_str, preprocessorDefinitions));
            p.program->addShader( AddShader(shaders::FS, mat_name_cut, version, comp_str, preprocessorDefinitions));

            p.program->addBindAttribLocation( "tangent" , 6 );
            p.program->addBindAttribLocation( "binormal", 7 );

            GetPrograms()[mat_name_cut]=p;
        }

        return GetPrograms()[mat_name_cut];
    }
開發者ID:whztt07,項目名稱:test_osg,代碼行數:30,代碼來源:materials.cpp

示例6: Shader

bool Res::Init() {
	Shader* shader = nullptr;
	Texture* texture = nullptr;

	// block shader
	shader = new Shader();
	if (!shader->Init("res/block.vert", "res/block.frag")) return false;
	AddShader("block", shader);

	// simpler color shader
	shader = new Shader();
	if (!shader->Init("res/color.vert", "res/color.frag")) return false;
	AddShader("color", shader);


	std::vector<byte> buffer, image;
	LodePNG::loadFile(buffer, "res/blocks.png");
	LodePNG::Decoder decoder;
	decoder.decode(image, buffer);

	int dim = decoder.getWidth();

	texture = Texture::Create3DTexture(dim, dim, decoder.getHeight() / dim, image.data());
	AddTexture("blocks", texture);

	return true;
}
開發者ID:xunatai,項目名稱:cubiverse,代碼行數:27,代碼來源:Res.cpp

示例7: CompileShaders

static void CompileShaders()
{
	GLuint ShaderProgram = glCreateProgram();

	AddShader(ShaderProgram, GL_VERTEX_SHADER, pVS);
	AddShader(ShaderProgram, GL_FRAGMENT_SHADER, pFS);

	glLinkProgram(ShaderProgram);
	GLint Success;
	glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &Success);
	if (!Success)
	{
		GLchar InfoLog[1024] = {0};
		glGetProgramInfoLog(ShaderProgram, 1024, NULL, InfoLog);
		fprintf(stderr, "Error : Link Error '%s'\n", InfoLog);
		exit(0);
	}
	gWorldLocation = glGetUniformLocation(ShaderProgram, "gWorld");

	assert(gWorldLocation != 0xFFFFFFFF);
	glValidateProgram(ShaderProgram);
	glGetProgramiv(ShaderProgram, GL_VALIDATE_STATUS, &Success);
	if (!Success)
	{
		GLchar InfoLog[1024] = {0};
		glGetProgramInfoLog(ShaderProgram, 1024, NULL, InfoLog);
		fprintf(stderr, "Error : Invalid shader program '%s'\n", InfoLog);
		exit(1);
	}
	glUseProgram(ShaderProgram);
}
開發者ID:RamboWu,項目名稱:openglex,代碼行數:31,代碼來源:tutorial08.cpp

示例8: Init

bool ShadowMapTechnique::Init()
{
    if (!Technique::Init()) {
        return false;
    }

    if (!AddShader(GL_VERTEX_SHADER, "shadow_map.vs")) {
        return false;
    }

    if (!AddShader(GL_FRAGMENT_SHADER, "shadow_map.fs")) {
        return false;
    }

    if (!Finalize()) {
        return false;
    }

    m_WVPLocation = GetUniformLocation("gWVP");
    m_textureLocation = GetUniformLocation("gShadowMap");

    if (m_WVPLocation == INVALID_UNIFORM_LOCATION ||
        m_textureLocation == INVALID_UNIFORM_LOCATION) {
        return false;
    }

    return true;
}
開發者ID:c14006078,項目名稱:opengl,代碼行數:28,代碼來源:shadow_map_technique.cpp

示例9: IObject

Shader::Shader(const std::string& vertexPath, const std::string& fragmentPath) : IObject("shader")
{
	AddShader(ShaderType::Vertex, vertexPath);
	AddShader(ShaderType::Fragment, fragmentPath);

	Reload(true);
}
開發者ID:JuDelCo,項目名稱:JuEngine,代碼行數:7,代碼來源:Shader.cpp

示例10: Init

bool LineShader::Init()
{
	if (!Shader::Init()) {
		return false;
	}

	if (!AddShader(GL_VERTEX_SHADER, "Resources/shader/Line.vs")) {
		return false;
	}
	if (!AddShader(GL_FRAGMENT_SHADER, "Resources/shader/Line.fs")) {
		return false;
	}
	if (!Finalize()) {
		return false;
	}

	m_MVPLocation = GetUniformLocation("MVP");
	if (m_MVPLocation == INVALID_UNIFORM_LOCATION) {
		return false;
	}

	m_LineColorLocation = GetUniformLocation("LineColor");
	if (m_LineColorLocation == INVALID_UNIFORM_LOCATION) {
		return false;
	}

	return true;
}
開發者ID:Code-Guy,項目名稱:Paradise,代碼行數:28,代碼來源:lineshader.cpp

示例11: CompileShader

void CompileShader()
{
	shaderProgram = glCreateProgram();
	string vs, fs;
	if (!ReadFile(VSFile, vs))
		exit(1);
	if (!ReadFile(FSFile, fs))
		exit(1);

	AddShader(shaderProgram, vs.c_str(), GL_VERTEX_SHADER);
	AddShader(shaderProgram, fs.c_str(), GL_FRAGMENT_SHADER);

	GLint success;
	GLchar errorLog[1024];
	glLinkProgram(shaderProgram);
	glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
	if (success == 0)
	{
		glGetProgramInfoLog(shaderProgram, 1024, NULL, errorLog);
		fprintf(stderr, "Link error : %s\n", errorLog);
		exit(1);
	}

	glValidateProgram(shaderProgram);
	glGetProgramiv(shaderProgram, GL_VALIDATE_STATUS, &success);
	if (success == 0)
	{
		glGetProgramInfoLog(shaderProgram, 1024, NULL, errorLog);
		fprintf(stderr, "Validate error : %s\n", errorLog);
		exit(1);
	}
}
開發者ID:onerain88,項目名稱:OGLDev,代碼行數:32,代碼來源:Source.cpp

示例12: Init

bool MotionBlurTechnique::Init()
{
    if (!Technique::Init()) {
        return false;
    }

    if (!AddShader(GL_VERTEX_SHADER, "shaders/motion_blur.vs")) {
        return false;
    }

    if (!AddShader(GL_FRAGMENT_SHADER, "shaders/motion_blur.fs")) {
        return false;
    }

    if (!Finalize()) {
        return false;
    }
    
    m_colorTextureLocation = GetUniformLocation("gColorTexture");
    m_motionTextureLocation = GetUniformLocation("gMotionTexture");
    
    if (m_motionTextureLocation == INVALID_UNIFORM_LOCATION ||
        m_colorTextureLocation == INVALID_UNIFORM_LOCATION) {
        return false;
    }

	return true;
}
開發者ID:c14006078,項目名稱:opengl,代碼行數:28,代碼來源:motion_blur_technique.cpp

示例13: Init

bool DSDirLightPassTech::Init()
{
	if (!Technique::Init())
	{
		return false;
	}

	if (!AddShader(GL_VERTEX_SHADER, "shaders/light_pass.vs"))
	{
		return false;
	}

	if (!AddShader(GL_FRAGMENT_SHADER, "shaders/dir_light_pass.fs"))
	{
		return false;
	}

	if (!Finalize()) {
		return false;
	}

	m_dirLightLocation.Color = GetUniformLocation("gDirectionalLight.Base.Color");
	m_dirLightLocation.AmbientIntensity = GetUniformLocation("gDirectionalLight.Base.AmbientIntensity");
	m_dirLightLocation.Direction = GetUniformLocation("gDirectionalLight.Direction");
	m_dirLightLocation.DiffuseIntensity = GetUniformLocation("gDirectionalLight.Base.DiffuseIntensity");

	if (m_dirLightLocation.AmbientIntensity == INVALID_UNIFORM_LOCATION ||
		m_dirLightLocation.Color == INVALID_UNIFORM_LOCATION ||
		m_dirLightLocation.DiffuseIntensity == INVALID_UNIFORM_LOCATION ||
		m_dirLightLocation.Direction == INVALID_UNIFORM_LOCATION) {
		return false;
	}

	return DSLightPassTech::Init();
}
開發者ID:WendyHanzer,項目名稱:4s,代碼行數:35,代碼來源:ds_dir_light_pass_tech.cpp

示例14: Init

bool GeomPassTech::Init()
{
	if (!Technique::Init()) {
		return false;
	}

	if (!AddShader(GL_VERTEX_SHADER, "engine/shaders/geometry_pass.vs")) {
		return false;
	}

	if (!AddShader(GL_FRAGMENT_SHADER, "engine/shaders/geometry_pass.fs")) {
		return false;
	}

	if (!Finalize()) {
		return false;
	}

	m_WVPLocation = GetUniformLocation("gWVP");

	if (m_WVPLocation == INVALID_UNIFORM_LOCATION) {
		return false;
	}

	return true;
}
開發者ID:FNickRU,項目名稱:OGL_project,代碼行數:26,代碼來源:geom_pass_tech.cpp

示例15: Init

bool PickingTechnique::Init()
{
    if (!Technique::Init()) {
        return false;
    }

    if (!AddShader(GL_VERTEX_SHADER, pVS)) {
        return false;
    }

    if (!AddShader(GL_FRAGMENT_SHADER, pFS)) {
        return false;
    }
    
    if (!Finalize()) {
        return false;
    }

    m_WVPLocation = GetUniformLocation("gWVP");
    m_objectIndexLocation = GetUniformLocation("gObjectIndex");
    m_drawIndexLocation = GetUniformLocation("gDrawIndex");

    if (m_WVPLocation == INVALID_UNIFORM_LOCATION ||
        m_objectIndexLocation == INVALID_UNIFORM_LOCATION ||
        m_drawIndexLocation == INVALID_UNIFORM_LOCATION) {
        return false;
    }

    return true;
}
開發者ID:rue-ryuzaki,項目名稱:Visual-OpenGL,代碼行數:30,代碼來源:picking_technique.cpp


注:本文中的AddShader函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。