• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ AddShader函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中AddShader函数的典型用法代码示例。如果您正苦于以下问题:C++ AddShader函数的具体用法?C++ AddShader怎么用?C++ AddShader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了AddShader函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Init

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

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

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

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

    m_WVPLocation = GetUniformLocation("gWVP");
    m_WorldMatrixLocation = GetUniformLocation("gWorld");
    m_lightWorldPosLoc = GetUniformLocation("gLightWorldPos");

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

    return true;
}
开发者ID:andriyut,项目名称:ogldev,代码行数:30,代码来源:shadow_map_technique.cpp


示例17: Init

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

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

    if (!AddShader(GL_FRAGMENT_SHADER, "shaders/null_technique.fs")) {
        return false;
    }
    BindAttribLocation(0, "Position");
    if (!Finalize()) {
        return false;
    }

    m_WVPLocation = GetUniformLocation("gWVP");

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

	return true;
}
开发者ID:GLDemos,项目名称:ogldev-glsl130,代码行数:26,代码来源:null_technique.cpp


示例18: AddShader

FCGLShaderProgramRef FCGLShaderManager::AddProgram( std::string name, std::string shaderName )
{
	FCGLShaderProgramRefMapByStringIter i = m_programs.find( name );
		
	if( i == m_programs.end() ) 
	{
		std::string vertexShaderName = shaderName + ".vsh";
		std::string fragmentShaderName = shaderName + ".fsh";
		
		FCGLShaderRef vertexShader = AddShader( vertexShaderName );
		FCGLShaderRef fragmentShader = AddShader( fragmentShaderName );
		
		// build program
		
		if( name == kFCKeyShaderDebug ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgramDebug( vertexShader, fragmentShader ) );
		} 
		else if ( name == kFCKeyShaderWireframe ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgramWireframe( vertexShader, fragmentShader ) );
		} 
		else if ( name == kFCKeyShaderFlatUnlit ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgramFlatUnlit( vertexShader, fragmentShader ) );
		} 
		else if ( name == kFCKeyShaderNoTexVLit ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgramNoTexVLit( vertexShader, fragmentShader ) );
		} 
		else if ( name == kFCKeyShaderNoTexPLit ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgramNoTexPLit( vertexShader, fragmentShader ) );
		} 
		else if ( name == kFCKeyShader1TexVLit ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgram1TexVLit( vertexShader, fragmentShader ) );
		} 
		else if ( name == kFCKeyShader1TexPLit ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgram1TexPLit( vertexShader, fragmentShader ) );
		} 
		else if ( name == kFCKeyShaderTest ) 
		{
			m_programs[ name ] = FCGLShaderProgramRef( new FCGLShaderProgramTest( vertexShader, fragmentShader ) );
		} 
		else {
			FC_FATAL( std::string("Unknown shader: ") + name );
		}
		
		FC_LOG( std::string("Linked GL program: ") + name );
		
//		[self.programs setValue:ret forKey:name];
	}
	
	return m_programs[ name ];
}
开发者ID:chenze4949,项目名称:FC,代码行数:57,代码来源:FCGLShaderManager.cpp


示例19: glCreateProgram

ShaderProgram::ShaderProgram(Shader *vertex, Shader *fragment)
{
    m_filename = "";
    m_object = glCreateProgram();
    
    AddShader(Shader::Create(vertex->m_filename));
    AddShader(Shader::Create(fragment->m_filename));
    
    Link();
}
开发者ID:UIKit0,项目名称:hatching-shader,代码行数:10,代码来源:Shaders.cpp


示例20: SetCurrentDirectory

void Window::TextureDisplayer_Activation(){
    SetCurrentDirectory("TextureLoad");
    TextureDisplayer_Adress=AddShader("TexLoad.frag",GL_FRAGMENT_SHADER,-1);
    AddShader("TexLoad.geo",GL_GEOMETRY_SHADER,TextureDisplayer_Adress);
    AddShader("TexLoad.vert",GL_VERTEX_SHADER,TextureDisplayer_Adress);
    ConsoleEcho("12345");
    GLuint Type[1]={GL_GEOMETRY_SHADER_BIT | GL_VERTEX_SHADER_BIT |GL_FRAGMENT_SHADER_BIT};
    SetActiveInternProgram(&TextureDisplayer_Adress,Type,1);
    TextureDisplayer_Inited=true;
    ConsoleEcho("Tes Suposé activé");
}
开发者ID:Qlala,项目名称:Engine,代码行数:11,代码来源:window.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AddSolidFlags函数代码示例发布时间:2022-05-30
下一篇:
C++ AddSequential函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap