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


C++ getShader函数代码示例

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


在下文中一共展示了getShader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: glEnable

	void Model::render(const RenderConf & _conf) const
	{
		if (!getShader())
			return;

		if (!Configurator::isDepthTestEnabled())
			glEnable(GL_DEPTH_TEST);

		Shader & shader = *getShader();
		shader.use();

		bool useCustomConf = _conf != RenderConf::Default;

		const auto & lights = useCustomConf ? _conf.lights : getLights();
		const auto & matrices = useCustomConf ? _conf.matrices : getMatrices();

		shader.setMat4f("mvp", matrices.mvp)
			.setMat4f("model", matrices.transform)
			.setMat4f("inverseModel", matrices.inverseTransform)
			.setVec3("cameraPos", matrices.cameraPosition)
			.setFloat("material.shininess", 5.f)
			.setLights("light", lights.cbegin(), lights.cend())
			.setBoolean("useColorOnly", m_useColorOnly)
			.setColor("singleColor", m_color);

		renderMeshes();

		Shader::unuse();

		if (!Configurator::isDepthTestEnabled())
			glDisable(GL_DEPTH_TEST);
	}
开发者ID:Crisspl,项目名称:FHL-plus-EndlessRunnerGame,代码行数:32,代码来源:Model.cpp

示例2: if

void SSAOPass::configBlurQuadStateSet(osg::Group *g, char dir, osg::TextureRectangle *outSSAOTex)
{
    osg::ref_ptr<osg::StateSet> ss = g->getOrCreateStateSet();
    if(dir == 'y')
    {
        ss->setAttributeAndModes(getShader(_blurY_shader), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
    }
    else if(dir == 'x')
    {
        ss->setAttributeAndModes(getShader(_blurX_shader), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
    }
    else
    {
        fprintf(stderr, "Shadow Group, blur dir err\n");
        exit(0);
    }
    ss->addUniform(new osg::Uniform("u_ssaoTex", 0));
    ss->setTextureAttribute(0, outSSAOTex);
    
    ss->addUniform(new osg::Uniform("u_depthTex", 1));
    ss->setTextureAttribute(1, _sharedDepthTex);
    
    ss->addUniform(new osg::Uniform("u_inv_screenSize", osg::Vec2(1.0 / _screenWidth, 1.0 / _screenHeight)));
    float s = 128.0f, e = 131070.0f, fs = 1.0f / s, fe = 1.0f / e, fd = fs - fe;
    
    ss->addUniform(new osg::Uniform("fs", fs));
    ss->addUniform(new osg::Uniform("fd", fd));
}
开发者ID:wqxhouse,项目名称:VRApp,代码行数:28,代码来源:SSAOPass.cpp

示例3: getShader

		void DCTextBox::e_draw()
		{
			::X39::Singletons::MATERIAL* mat = ::X39::Singletons::MaterialManager::getInstance().getMaterialByIndex(1);
			int textureIndex = 1;
			getShader().use();
			if(width < 16 || height < 16)
			{
				drawTexture2D(mat, textureIndex, 0, 0, mat->textures[0]->width, mat->textures[0]->height, posX, posY, width, height, getShader());
			}
			else
			{
				//TopLeft corner
				drawTexture2D(mat, textureIndex, 0, 0, 16, 16, posX, posY, 16, 16, getShader());
				if(height > 32)
				{
					//Left Side
					drawTexture2D(mat, textureIndex, 0, 16, 16, 16, posX, posY + 16, 16, height - 32, getShader());
				}
				//BottomLeft corner
				drawTexture2D(mat, textureIndex, 0, 64 - 16, 16, 16, posX, posY + height - 16, 16, 16, getShader());

				//TopRight corner
				drawTexture2D(mat, textureIndex, 64 - 16, 0, 16, 16, posX + width - 16, posY, 16, 16, getShader());
				if(height > 32)
				{
					//Right Side
					drawTexture2D(mat, textureIndex, 64 - 16, 16, 16, 16, posX + width - 16, posY + 16, 16, height - 32, getShader());
				}
				//BottomRight corner
				drawTexture2D(mat, textureIndex, 64 - 16, 64 - 16, 16, 16, posX + width - 16, posY + height - 16, 16, 16, getShader());
				
				if(width > 32)
				{
					//Top side
					drawTexture2D(mat, textureIndex, 16, 0, 16, 16, posX + 16, posY, width - 32, 16, getShader());
					
					if(height > 32)
					{
						//Middle side
						drawTexture2D(mat, textureIndex, 16, 16, 16, 16, posX + 16, posY + 16, width - 32, height - 32, getShader());
					}
					//Bottom side
					drawTexture2D(mat, textureIndex, 16, 64 - 16, 16, 16, posX + 16, posY + height - 16, width - 32, 16, getShader());
				}
			}
			getShader().unuse();
			if(!innerText.empty())
				drawTextLine2D(::X39::Singletons::FontManager::getInstance().getFont(0), innerText.c_str(), height / FONTSIZEBASE, posX, posY, width);
			if(deleteButtonPressed)
			{
				deleteButtonPressedTimeout++;
				if(deleteButtonPressedTimeout > 22)
				{
					deleteButtonPressedTimeout = 20;
					if(innerText.size() > 0)
						innerText.pop_back();
				}
			}
		}
开发者ID:X39,项目名称:X39_OpenGL_Application,代码行数:59,代码来源:DCTextBox.cpp

示例4: getShader

 void Shader::reload() {
     this->m_shader.setupShaderFromSource(GL_VERTEX_SHADER, getShader(GL_VERTEX_SHADER));
     this->m_shader.setupShaderFromSource(GL_FRAGMENT_SHADER, getShader(GL_FRAGMENT_SHADER));
     if(ofIsGLProgrammableRenderer()) {
         this->m_shader.bindDefaults();
     }
     this->m_shader.linkProgram();
 }
开发者ID:mattebb,项目名称:ofxShadersFX,代码行数:8,代码来源:ofxShadersFX.cpp

示例5: getShader

    void Material::update()
    {
        getShader()->use();

        getShader()->setUniform("color", diffuseColor);

        // ToDo: set specularColor
        // ToDo: set shininess

    }
开发者ID:SOTR,项目名称:OpenGLTest,代码行数:10,代码来源:material.cpp

示例6: getShader

osg::ref_ptr<osg::Program> OSGShaderFactory::createShaderProgram( const std::string& vertexProgram, const std::string& fragmentProgram )
{
    osg::ref_ptr<osg::Program> program = new osg::Program;
    
    osg::ref_ptr<osg::Shader> vertexShader = getShader( vertexProgram, osg::Shader::VERTEX );
    osg::ref_ptr<osg::Shader> fragmentShader = getShader( fragmentProgram, osg::Shader::FRAGMENT );
    
    program->addShader( vertexShader );
    program->addShader( fragmentShader );
    
    return program;
}
开发者ID:allanschottler,项目名称:WaterSurface,代码行数:12,代码来源:OSGShaderFactory.cpp

示例7: getShader

void Rectangle::draw()
{
	getShader()->beginShader();
    if (getShader()->drawShaded()) {
		getShader()->beginShading();
    	beginList();
    	if(!isCached())
    	{
			glRectf(x, y, width, height);
		}
    	endList();
 	    getShader()->endShading();
	}
    if (getShader()->drawOutline()) {
    	getShader()->beginOutline();
		beginList();
    	if(!isCached())
    	{
			glRectf(x, y, width, height);
		}
    	endList();
    	getShader()->endOutline();

    }
    getShader()->endShader();
}
开发者ID:BackupTheBerlios,项目名称:athene,代码行数:26,代码来源:rectangle.cpp

示例8: getShader

/*
 *	Shall return a shader where offsets of members in
 *	lightsource uniform buffer and shadowmap matrix uniform buffer can be queried,
 *	if the global shader features indicate their possible usage;
 *
 *	note: an instance transform uniform block is not necessary, as every instance manager
 *	has its "own" shader to query from; only the other two uniform blocks have a "global" character
 */
Shader* ShaderManager::getUniformBufferOffsetQueryShader(bool forShadowMapGeneration)
{
	//shaderfeatures to request from the shadermanager a minimalistic shader containing the
	//uniform buffer declaration, so that offsets can be queried
//	static ShaderFeaturesLocal sfl =
//		ShaderFeaturesLocal(
//				RENDERING_TECHNIQUE_DEFAULT_LIGHTING, //lighting, for the creation of the lightsource uniform block
//				TEXTURE_TYPE_2D_RECT, //play no role, dummy..
//				VISUAL_MATERIAL_TYPE_DEFAULT_LIGHTING, //lighting, for the creation of the lightsource uniform block
//				ShadingFeatures(
//						SHADING_FEATURE_DIRECT_LIGHTING //lighting, for the creation of the lightsource uniform block
//						//TODO add shadowing when the rest is stable
//				),
//				false //no global instance buffer query needed
//	);

	if(forShadowMapGeneration)
	{
		//shadow map generation,layout(shared) uniform ShadowCameraTransformBuffer block
		//note the ShadowCameraTransformBuffer is used twice:
		//	- for generation of shadowmaps in a geometry shader
		//	- for shadowmap lookup in a fragment shader
		//though the same buffer object is used, the logical uniform block in the shaders is different;
		//to omit bugs as far as possible, two meta infos for the same buffer will be maintained
		//queried;
		return getShader(
			ShaderFeaturesLocal(
				RENDERING_TECHNIQUE_SHADOWMAP_GENERATION,
				TEXTURE_TYPE_2D_RECT, //play no role, dummy..
				VISUAL_MATERIAL_TYPE_NONE,
				ShadingFeatures(SHADING_FEATURE_NONE),
				false //no global instance buffer query needed
			)
		);
	}
	else
	{
		//lighting, for the creation of the "layout(shared) uniform LightSourceBuffer"  block
		return getShader(
			ShaderFeaturesLocal(
				RENDERING_TECHNIQUE_DEFAULT_LIGHTING,
				TEXTURE_TYPE_2D_RECT, //play no role, dummy..
				VISUAL_MATERIAL_TYPE_DEFAULT_LIGHTING,
				ShadingFeatures(SHADING_FEATURE_DIRECT_LIGHTING),
				false //no global instance buffer query needed
			)
		);
	}

}
开发者ID:tychi,项目名称:Flewnit,代码行数:58,代码来源:ShaderManager.cpp

示例9: getShader

void GPUNullFilter::applyOnGPU(GLTexturePtr pSrcTex)
{
    getShader()->activate();
    m_pTextureParam->set(0);
    draw(pSrcTex);

}
开发者ID:JohnChu,项目名称:libavg,代码行数:7,代码来源:GPUNullFilter.cpp

示例10: getShader

 bool Render::rawFrame(CZScene &scene,CZNode *pRootNode, CZMat4 &projMat)
 {
     curShader = getShader(kDirectionalLightShading);
     
     if (curShader == NULL)
     {
         LOG_ERROR("there's no shader designated\n");
         return false;
     }
     curShader->begin();
     
     // common uniforms
     glUniform3f(curShader->getUniformLocation("ambientLight.intensities"),
                 scene.ambientLight.intensity.x,
                 scene.ambientLight.intensity.y,
                 scene.ambientLight.intensity.z);
     
     glUniform3f(curShader->getUniformLocation("directionalLight.direction"),
                 scene.directionalLight.direction.x,scene.directionalLight.direction.y,scene.directionalLight.direction.z);
     
     glUniform3f(curShader->getUniformLocation("eyePosition"),scene.eyePosition.x,scene.eyePosition.y,scene.eyePosition.z);
     
     glUniform3f(curShader->getUniformLocation("directionalLight.intensities"),
                 scene.directionalLight.intensity.x,
                 scene.directionalLight.intensity.y,
                 scene.directionalLight.intensity.z);
     CZCheckGLError();
     
     draw(pRootNode, projMat);
     CZCheckGLError();
     
     curShader->end();
     
     return true;
 }
开发者ID:CharlyZhang,项目名称:Vuforia-iOS-Lib,代码行数:35,代码来源:Render.cpp

示例11: getShader

int ShaderManager::saveProgress(const char *shaderName, char *errorText, Editor *editor)
{
	Shader *shader;
	int retVal = getShader(shaderName, &shader, errorText);
	if (retVal) return retVal;

	SYSTEMTIME sysTime;
	GetSystemTime(&sysTime);

	char filename[SM_MAX_FILENAME_LENGTH+1];
	sprintf_s(filename, SM_MAX_FILENAME_LENGTH, "%s%s.%d_%d_%d_%d_%d_%d",
		SM_PROGRESS_DIRECTORY, shaderName, sysTime.wYear, sysTime.wMonth,
		sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
	FILE *fid;
	if (fopen_s(&fid, filename, "wb"))
	{
		sprintf_s(errorText, MAX_ERROR_LENGTH,
			      "Could not write to '%s'", filename);
		return -1;
	}
	fwrite(shader->getShaderText(), sizeof(char), strlen(shader->getShaderText()), fid);
	fclose(fid);

	// If there is an editor attached, set a snapshot
	if (editor)
	{
		editor->setSnapshot(filename);
	}

	return 0;
}
开发者ID:chock-mostlyharmless,项目名称:mostlyharmless,代码行数:31,代码来源:ShaderManager.cpp

示例12: configureStateSet

void SSAOPass::configureStateSet()
{
    osg::Matrix projMatrix = _mainCamera->getProjectionMatrix();
    osg::Matrix inverseProjMat = osg::Matrix::inverse(projMatrix);
    
    _stateSet->setAttributeAndModes(getShader(_ssao_shader_id), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
    _stateSet->addUniform(new osg::Uniform("u_occluderBias", _occulderBias));
    _stateSet->addUniform(new osg::Uniform("u_samplingRadius", _samplingRadius));
    _stateSet->addUniform(new osg::Uniform("u_attenuation", osg::Vec2(_constantAttenuation, _linearAttenuation)));
    _stateSet->addUniform(new osg::Uniform("u_farDistance", _farPlaneDist));
    _stateSet->addUniform(new osg::Uniform("u_inverseProjMatrix", inverseProjMat));
    _stateSet->addUniform(new osg::Uniform("u_randomJitterTex", 0));
    _stateSet->addUniform(new osg::Uniform("u_normalAndDepthTex", 1));
    _stateSet->addUniform(new osg::Uniform("u_positionTex", 2));
    _stateSet->addUniform(new osg::Uniform("u_screen_wh", osg::Vec2(_screenWidth, _screenHeight)));
    
//    _stateSet->addUniform(new osg::Uniform("u_debug", 3));
//    _stateSet->setTextureAttributeAndModes(3, _debug);
//    
    _stateSet->setTextureAttribute(0, _randomTexture2D);
    _stateSet->setTextureAttribute(1, getInTexture(_in_normal_tex));
    _stateSet->setTextureAttribute(2, getInTexture(_in_position_tex));
//
//    float w = _mainCamera->getViewport()->width();
//    float h = _mainCamera->getViewport()->height();
//    osg::Vec2 texelSize = osg::Vec2(1.0f/w, 1.0f/h);
//    _stateSet->addUniform(new osg::Uniform("u_texelSize", texelSize));
    
    //_screenQuad->getOrCreateStateSet()->setUpdateCallback(new SSAOStateCallback(_mainCamera, this));
    _stateSet->setUpdateCallback(new SSAOStateCallback(_mainCamera, this));
}
开发者ID:wqxhouse,项目名称:VRApp,代码行数:31,代码来源:SSAOPass.cpp

示例13: getFBO

void GPUChromaKeyFilter::applyOnGPU(GLTexturePtr pSrcTex)
{
    // Set up double-buffering
    int curBufferIndex = m_Erosion%2;
    getFBO(curBufferIndex)->activate();
    getShader()->activate();
    m_pTextureParam->set(0);

    float h, s, l;
    m_Color.toHSL(h, s, l);
    m_pHKeyParam->set(h);
    m_pHToleranceParam->set(m_HTolerance*360);
    m_pHSoftToleranceParam->set((m_HTolerance+m_Softness)*360.0f);
    m_pSKeyParam->set(s);
    m_pSToleranceParam->set(m_STolerance);
    m_pSSoftToleranceParam->set(m_STolerance+m_Softness);
    m_pLKeyParam->set(l);
    m_pLToleranceParam->set(m_LTolerance);
    m_pLSoftToleranceParam->set(m_LTolerance+m_Softness);
    m_pSpillThresholdParam->set(m_SpillThreshold*360);
    m_pIsLastParam->set(int(m_Erosion==0));
    draw(pSrcTex);

    for (int i = 0; i < m_Erosion; ++i) {
        curBufferIndex = (curBufferIndex+1)%2;
        getFBO(curBufferIndex)->activate();
        OGLShaderPtr pShader = avg::getShader(SHADERID_EROSION);
        pShader->activate();
        m_pErosionTextureParam->set(0);
        m_pErosionIsLastParam->set(int(i==m_Erosion-1));
        getDestTex((curBufferIndex+1)%2)->activate(GL_TEXTURE0);
        m_pProjection2->draw(avg::getShader(SHADERID_EROSION));
    }
}
开发者ID:lynxis,项目名称:libavg,代码行数:34,代码来源:GPUChromaKeyFilter.cpp

示例14: getShader

GLuint ObjectManager::obtainShader( const void* key, const GLenum type )
{
    const GLuint id = getShader( key );
    if( id != INVALID )
        return id;
    return newShader( key, type );
}
开发者ID:Angels-group,项目名称:Equalizer,代码行数:7,代码来源:objectManager.cpp

示例15: getScale

void Margin::draw()
{

	Vector3D * scale = getScale();

	getVSML()->loadIdentity(VSMathLib::MODEL);

	// Margin
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(getPosition()->getX(), getPosition()->getY(), getPosition()->getZ());
	getVSML()->scale(scale->getX(), scale->getY(), scale->getZ());

	// cube
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(-0.5f, -0.5f, -0.5f);
	glUseProgram((*getShader()).getProgramIndex());
	
	getVSML()->matricesToGL();
	glBindVertexArray(vaoMargin);
	glDrawElements(GL_TRIANGLES, faceCountMargin * 3, GL_UNSIGNED_INT, 0);
	getVSML()->popMatrix(VSMathLib::MODEL);
	// cube

	getVSML()->popMatrix(VSMathLib::MODEL);
	// Margin
}
开发者ID:Andre-Pires,项目名称:Three-Dimensional-Visualization-and-Animation,代码行数:26,代码来源:Margin.cpp


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