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


C++ ShaderManager类代码示例

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


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

示例1: InitGL

void InitGL() {
	// Init opengl(depth test, blending, lighting and so on...)
	glEnable(GL_DEPTH_TEST);

	glClearColor(0,0,0,1);

	ShaderManager *sMan = ShaderManager::getDefaultManager();
	shader = sMan->createShader("C:/Andrea/GLSL/version130/prova2.vert", "C:/Andrea/GLSL/version130/prova2.geom", "C:/Andrea/GLSL/version130/prova2.frag");

	glGenVertexArrays(1, &vao); // create vao
	glGenBuffers(2, vbo); // create vbo

	glBindVertexArray(vao);

	int posLocation = shader->getAttributeLocation("in_Position");

	cout << posLocation << endl;

	//vertices position attribute
	glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
	glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(GLfloat), vertices, GL_STATIC_DRAW);
	glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);

	//vertices indices
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[1]);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * sizeof(GLuint), indices, GL_STATIC_DRAW);

	glEnableVertexAttribArray(0);
	
	glBindVertexArray(0);
}
开发者ID:erbuka,项目名称:andrea,代码行数:31,代码来源:Main.cpp

示例2: InitZephyrModules

void InitZephyrModules()
{
  // A. Timer
  Core::Timer *mTimer = new Timer();
  mTimer->Initialize();
  mTimer->Reset();

  // B. Filesystem
  Core::FileSystem *fsMngr = new Core::Win32FileSystem();
  fsMngr->Initialize();

  // C. Input manager
  Input::SCTInputManager *inputMngr	= new Input::SCTInputManagerWin32(mHinst, mHwnd);
	inputMngr->Initialize();
  
	inputMngr->CreateKeyboardDevice();
	std::cout<<"$> Keyboard Device has been initialized\n";
  
	inputMngr->CreateMouseDevice();
  std::cout<<"$> Mouse Device has been initialized\n";

  // D. Shader manager
  ShaderManager *mShaderManager = new CgGLShaderManager();
  mShaderManager->SetDebugMode(true); // Always?
  mShaderManager->Initialize();
}
开发者ID:dotv0id,项目名称:TerrainEditor,代码行数:26,代码来源:main.cpp

示例3: GLBox

	GLBox()
	{
		App = new sf::Window(sf::VideoMode(RES_WIDTH, RES_HEIGHT, 32), "Bubbles!");

		// Setting up shaders
		FILE * logFile;
		logFile = fopen("log text", "wb");
		if(NULL == logFile)
		{
			printf("Unable to open log file. Exiting...\n");
			exit(2);
		}
		__glewInit(logFile);

		ShaderManager shaders = ShaderManager(logFile);
		char const * bubbleDrawVert = "BubbleShaders/bubbleRender3dModel.vert";
		char const * bubbleDrawFrag = "BubbleShaders/bubbleRender3dModel.frag";
		bubbleShaderProg = shaders.buildShaderProgram(&bubbleDrawVert, &bubbleDrawFrag, 1, 1);

		Clock = sf::Clock();
		mode = BUBBLE_MODE;
		gfxinit();

		while (App->IsOpened())
		{
			App->SetActive();
			handleEvents();
			setShader();
			setShaderVariables(bubbleShaderProg);
			display();
			App->Display();
		}

		fclose(logFile);
	}
开发者ID:JohnMacAslan,项目名称:Bubbles,代码行数:35,代码来源:display.cpp

示例4: draw

/**
*	Draw scene
**/
void Scene::draw(ShaderManager & shaderManager)
{
	for(ModelVector::iterator it = modelVector.begin(); it != modelVector.end(); ++it)
	{
		
		if((*it) != 0)
		{
			// Only render transperent objects in the transperent stage
			if((*it)->isTransperent() && shaderManager.getStateManager().getRenderingStage() != StateManager::TRANSPARENCY_STAGE) continue;
			else if(!(*it)->isTransperent() && shaderManager.getStateManager().getRenderingStage() == StateManager::TRANSPARENCY_STAGE) continue;

			for(Model::EntityVector::iterator entIt = (*it)->getAllEntities().begin(); entIt != (*it)->getAllEntities().end(); ++entIt)
			{
				glPushMatrix();
				glTranslatef(entIt->position.x,entIt->position.y,entIt->position.z);
				glRotatef(entIt->rotation.w,entIt->rotation.x,entIt->rotation.y,entIt->rotation.z);
				glScalef(entIt->scale.x,entIt->scale.y,entIt->scale.z);
				shaderManager.updateModelviewPerspectiveMatrix();
				if(shaderManager.getStateManager().getRenderingStage() == StateManager::TRANSPARENCY_STAGE)
				{
					glm::mat4x4 tlMat = glm::translate(glm::mat4x4(1.0),entIt->position);
					//glm::mat4x4 rotMat = glm::rotate(tlMat, entIt->rotation.w,glm::vec3(entIt->rotation.x,entIt->rotation.y,entIt->rotation.z));
					//glm::mat4x4 scMat = glm::scale(rotMat, entIt->scale);
					shaderManager.setCgParam(tlMat,"modelMatrix",VERTEX);
				}
				(*it)->draw(shaderManager);
				glPopMatrix();
			}
		}
	}
}
开发者ID:CrizMobius,项目名称:Deferred-Shader,代码行数:34,代码来源:Scene.cpp

示例5: RenderScene

void ShadowMapDemo::RenderScene( ShaderManager& shader_mgr )
{
//	m_pShadowMapManager->ShaderTechniqueForShadowCaster();

	GraphicsDevice().SetRenderState( RenderStateType::ALPHA_BLEND, false );
	GraphicsDevice().SetRenderState( RenderStateType::LIGHTING,    m_Lighting );

	shared_ptr<ShaderLightManager> pLightMgr = shader_mgr.GetShaderLightManager();
	if( pLightMgr )
		pLightMgr->CommitChanges();

	int num_mesh_rows = 5;
	for( int i=0; i<num_mesh_rows; i++ )
	{
		Matrix34 pose( Matrix34Identity() );
		pose.vPosition = Vector3( 0.0f, (float)i * 1.25f, (float)i * 5.0f + 2.0f );

		shader_mgr.SetWorldTransform( pose );

		shared_ptr<BasicMesh> pMesh = m_Mesh.GetMesh();
		if( pMesh )
			pMesh->Render( shader_mgr );
	}

	shader_mgr.SetWorldTransform( Matrix44Identity() );
	shared_ptr<BasicMesh> pFloor = m_FloorMesh.GetMesh();
	if( pFloor )
		pFloor->Render( shader_mgr );

//	PrimitiveShapeRenderer renderer;
//	renderer.SetShader(  );
//	renderer.RenderBox( Vector3( 100.0f, 0.1f, 100.0f ), Matrix34( Vector3(0.0f,-0.05f,0.0f), Matrix33Identity() ) );
}
开发者ID:nyankosoft,项目名称:amorphous,代码行数:33,代码来源:ShadowMapDemo.cpp

示例6: SetLightsToShader

/// Update light-related shader variables
void SetLightsToShader( CCopyEntity& entity, ShaderManager& rShaderMgr )
{
	shared_ptr<ShaderLightManager> pShaderLightMgr = rShaderMgr.GetShaderLightManager();

	int i, num_current_lights = entity.GetNumLights();
	LightEntity *pLightEntity = NULL;

	// clear any lights currenly stored in the shader light manager
	pShaderLightMgr->ClearLights();

	ShaderLightParamsWriter light_params_writer( pShaderLightMgr.get() );

	for( i=0; i<num_current_lights; i++ )
	{
		EntityHandle<LightEntity>& light_entity = entity.GetLight( i );
		LightEntity *pLightEntity = light_entity.GetRawPtr();
		if( !pLightEntity )
			continue;

//		pLightEntity->SetLightToShader( pShaderLightMgr );

		// copy light properties to the shader registers
		pLightEntity->GetLightObject()->Accept( light_params_writer );
	}

	pShaderLightMgr->CommitChanges();
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:28,代码来源:BaseEntity_Draw.cpp

示例7: main

int main(int argc, char** argv){
    StringHelper::init();
    Log >> new ConsoleLogger();
    //Set filter to include all.
    Log.setLevelFilter(LogManager::ll_Verbose);
    for(int i = 1; i < argc; i+=2){
        Log << argv[i];
        ShaderManager manager;
        manager.loadRaw(argv[i]);
        manager.save(argv[i+1]);
        ShaderManager saveTest;
        saveTest.load(argv[i+1]);
    }
    Log.close();
    return 0;
}
开发者ID:artur-kink,项目名称:nhns,代码行数:16,代码来源:main.cpp

示例8: Draw

void CPURenderer::Draw(VolumeDataset &volume, ShaderManager &shaderManager, Camera &camera)
{
	GLuint shaderProgramID = shaderManager.UseShader(TextureShader);
	raycaster->Raycast(volume, transferFunction, shaderProgramID, camera);

	
}
开发者ID:luosz,项目名称:artivvis-development-repository,代码行数:7,代码来源:CPURenderer.cpp

示例9: ToGLPrimitiveType

void C2DPrimitiveRenderer_GL::Render( General2DVertex *paVertex, int num_vertices, PrimitiveType::Name primitive_type )
{
	ShaderHandle shader
		= sg_2DPrimitiveCommonShaders.GetShader( C2DPrimitiveCommonShaders::ST_DIFFUSE_COLOR );

	ShaderManager *pShaderMgr = shader.GetShaderManager();

	if( !pShaderMgr )
	{
		LOG_PRINT_ERROR( "The shader for 2D primitives is not available." );
		return;
	}

	pShaderMgr->Begin();

	RenderViaVertexAttribArray( paVertex, num_vertices, NULL, 0, ToGLPrimitiveType(primitive_type) );
}
开发者ID:nyankosoft,项目名称:amorphous,代码行数:17,代码来源:2DPrimitiveRenderer_GL.cpp

示例10: RestoreOffsetWorldTransform

static void RestoreOffsetWorldTransform( ShaderManager& rShaderManager )
{
	Matrix44 matWorld, matView;
	rShaderManager.GetWorldTransform( matWorld );
	rShaderManager.GetViewTransform( matView );

	matWorld(0,3) = s_OrigWorldPos.x;
	matWorld(1,3) = s_OrigWorldPos.y;
	matWorld(2,3) = s_OrigWorldPos.z;

	matView(0,3) = s_OrigViewTrans.x;
	matView(1,3) = s_OrigViewTrans.y;
	matView(2,3) = s_OrigViewTrans.z;

	rShaderManager.SetWorldTransform( matWorld );
	rShaderManager.SetViewTransform( matView );
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:17,代码来源:BaseEntity_Draw.cpp

示例11: glCreateProgram

ShaderProgram::ShaderProgram(std::string* fileName)
{
    this->name.assign(*fileName);
    this->status = true;

    this->id          = glCreateProgram();
    this->shaderCount = 0;

    ShaderManager*             shaderManager = ShaderManager::getShaderManager();
    std::vector<std::string*>* strings       = Util::Parsing::getStringArray(&this->name);
    int                        linkStatus    = 0;


    for(unsigned int index = 0; index < strings->size(); index++)
    {
        //Ignore blank and comment lines.
        if(Util::StringLib::isWhiteSpace((*strings)[index])       ||
           Util::StringLib::startsWith((*strings)[index], "\\\\") ||
           Util::StringLib::startsWith((*strings)[index], "#"))    
        {
            continue;
        }

        this->shaders[this->shaderCount] = shaderManager->getShader((*strings)[index]);
        glAttachShader(this->id, this->shaders[shaderCount]->id);
        this->shaderCount++;
    }

    glLinkProgram( this->id); 
    glGetProgramiv(this->id, GL_LINK_STATUS, &linkStatus);

    if(linkStatus == 0) //GL_FALSE
    {
        char* errorLogBuffer = NULL;
        int   errorLength    = 0;

        glGetProgramiv(this->id, GL_INFO_LOG_LENGTH, &errorLength);
        errorLogBuffer = new char[errorLength];
        memset(errorLogBuffer, 0, errorLength);
        glGetProgramInfoLog(this->id, errorLength, NULL, errorLogBuffer);

        Main::die(errorLogBuffer);
    }

    delete strings;
}
开发者ID:Tempest12,项目名称:ss,代码行数:46,代码来源:ShaderProgram.cpp

示例12: createBuffers

HRESULT MeshGroup::createDeviceStuffs(ID3D11Device* device)
{
	HRESULT hr = S_OK;
	hr = createBuffers(device);
	if (FAILED(hr)) return hr;

	ShaderManager shaderManager = ShaderManager::sharedShaderManager();

	for (auto kv : materials) {
		MeshMaterial *material = kv.second;
		if (material->hasTexture) {
			material->pixelShader = shaderManager.pixelShaderForTexture(device);
		} else {
			material->pixelShader = shaderManager.pixelShaderForNoTexture(device);
		}
	}
}
开发者ID:aderussell,项目名称:Solar-System,代码行数:17,代码来源:MeshGroup.cpp

示例13: StreamAllFoliage

void FoliageMesh::StreamAllFoliage( Mesh* root )
{
	Lilith3D* lilith = Lilith3D::Instance();
	if ( lilith->RenderFoliage() && root )
	{
		L3PERFTRACK

		//const Vector3F& eye = lilith->GetCamera()->Eye();

		ShaderManager* shaderman = ShaderManager::Instance();
		const Shader* shader = shaderman->GetShader( ShaderManager::FOLIAGE_SHADER );

		L3State state;
		state.blend = true;
		state.shader = shader;

		// FIXME: choose a proper texture name for the foliage, and document that
		// all foliage needs to use the same texture.
		state.texture = TextureManager::Instance()->GetTexture( "grass1", 0 );
		StateManager::Enable( state );

		float fOffset = float( Lilith3D::GetTimeClock()->Msec() ) / 900.0f;
		shaderman->SetUniform( shader, "offset", fOffset );
		shaderman->SetUniform( shader, "eyeDirection", lilith->GetCamera()->Direction() );
		glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

		while ( root )
		{
			GLASSERT( root->Type() == FOLIAGEMESH );
			FoliageMesh* foliageMesh = (FoliageMesh*)root;
			
			// FIXME: PreStreamOut checks for cull - do our own culling, pull in the blending for
			// foliage much closer. (Also change the shader). 2 calls to OpenGL can be removed 
			// by setting the matrix rather than PUSH-MULT-POP
			//
			if ( foliageMesh->PreStreamOut( FOLIAGE_FADE, FOLIAGE_FADEOUT, 0 ) )
			{
				foliageMesh->GetStaticResource()->StreamOutVertex();
				foliageMesh->PostStreamOut();
			}
			root = root->nextRender;
		}
	}
}
开发者ID:gefariasjr,项目名称:projetofinal1,代码行数:44,代码来源:mesh.cpp

示例14: memset

LODManager::LODManager() {
  if (!EnabledLOD.Get())
    return;

  WorldSpace = 0;

  memset(Meshes, 0, sizeof(Meshes));
  memset(Colors, 0, sizeof(Colors));
  memset(Normals, 0, sizeof(Normals));

  memset(MeshIDs, 0xFE, sizeof(MeshIDs));
  memset(ColrIDs, 0xFE, sizeof(ColrIDs));
  memset(NormIDs, 0xFE, sizeof(NormIDs));

  ShaderManager *sm = ShaderManager::GetSingleton();

  /* look-ups will always be done with the original shader-address */
  if ((vNear = sm->GetBuiltInShader("LODNEAR.vso"))) {
    vNear->GetBinary(); vNear->ConstructDX9Shader(SHADER_REPLACED);
    vShader[GRID_FARNEAR] = vNear->pDX9VertexShader; }
  if ((pNear = sm->GetBuiltInShader("LODNEAR.pso"))) {
    pNear->GetBinary(); pNear->ConstructDX9Shader(SHADER_REPLACED);
    pShader[GRID_FARNEAR] = pNear->pDX9PixelShader; }

  /* look-ups will always be done with the original shader-address */
  if ((vFar = sm->GetBuiltInShader("LODFAR.vso"))) {
    vFar->GetBinary(); vFar->ConstructDX9Shader(SHADER_REPLACED);
    vShader[GRID_FARFAR] = vFar->pDX9VertexShader; }
  if ((pFar = sm->GetBuiltInShader("LODFAR.pso"))) {
    pFar->GetBinary(); pFar->ConstructDX9Shader(SHADER_REPLACED);
    pShader[GRID_FARFAR] = pFar->pDX9PixelShader; }

  /* look-ups will always be done with the original shader-address */
  if ((vInf = sm->GetBuiltInShader("LODINF.vso"))) {
    vInf->GetBinary(); vInf->ConstructDX9Shader(SHADER_REPLACED);
    vShader[GRID_FARINF] = vInf->pDX9VertexShader; }
  if ((pInf = sm->GetBuiltInShader("LODINF.pso"))) {
    pInf->GetBinary(); pInf->ConstructDX9Shader(SHADER_REPLACED);
    pShader[GRID_FARINF] = pInf->pDX9PixelShader; }

  /* look-ups will always be done with the original shader-address */
  if ((vWater = sm->GetBuiltInShader("LODWATER.vso"))) {
    vWater->GetBinary(); vWater->ConstructDX9Shader(SHADER_REPLACED);
    vShaderW = vWater->pDX9VertexShader; }
  if ((pWater = sm->GetBuiltInShader("LODWATER.pso"))) {
    pWater->GetBinary(); pWater->ConstructDX9Shader(SHADER_REPLACED);
    pShaderW = pWater->pDX9PixelShader; }
}
开发者ID:shadeMe,项目名称:Oblivion-Graphics-Extender-v3,代码行数:48,代码来源:LODManager.cpp

示例15: initShaders

void initShaders() {	
	//ASCH - 25/05/2016 - Initialisation des shaders	
	sm.init();
	shader_programme = sm.getShader_programme();
	vs = sm.getVertexShader(); 
	fs = sm.getFragShader();	
	
	//ASCH 25/05/2016 - Chargement des objets de scene
	for_each(objetsDeScene.begin(), objetsDeScene.end(), charger);
	
	/* A CONTROLER DANS LA CLASSE ObjetDeScene ou shaderManager
	//ASCH 24/09/2015 - Modification pour prendre en compte le multiobjet
	printf("---- taille : %d\n", objets.size());
	vao = new GLuint[objets.size()];

	//Création des tableaux en mémoire
	glGenVertexArrays (objets.size(), vao);
	
	// ASCH 20/04/2015 - Chargement des objets en mémoire graphique
	for(int i = 0; i < objets.size(); i++) {
		objets[i].construireVAO(vao[i], i);
		nbVertex += objets[i].getNbVertex();
	}	
	*/
}
开发者ID:Artegam,项目名称:Engine,代码行数:25,代码来源:main.cpp


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