本文整理汇总了C++中Shader::LinkProgram方法的典型用法代码示例。如果您正苦于以下问题:C++ Shader::LinkProgram方法的具体用法?C++ Shader::LinkProgram怎么用?C++ Shader::LinkProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shader
的用法示例。
在下文中一共展示了Shader::LinkProgram方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromFile
Shader* Shader::LoadFromFile(const char *vertexShaderFile,
const char *fragmentShaderFile)
{
Shader *shader = new Shader();
shader->m_vertShaderId = CompileShader(GL_VERTEX_SHADER, vertexShaderFile);
if (shader->m_vertShaderId == 0)
{
assert(false);
delete shader;
return NULL;
}
shader->m_fragShaderId = CompileShader(GL_FRAGMENT_SHADER, fragmentShaderFile);
if (shader->m_fragShaderId == 0)
{
assert(false);
delete shader;
return NULL;
}
shader->m_programId = glCreateProgram();
glAttachShader(shader->m_programId, shader->m_vertShaderId);
glAttachShader(shader->m_programId, shader->m_fragShaderId);
shader->LinkProgram();
return shader;
}
示例2: InitializeGraphics
bool GameController::InitializeGraphics(const std::string &basePath)
{
Log::LogT("Initializing Graphics");
uint32_t screenWidth = TaxiGame::Environment::GetInstance()->GetScreenWidth();
uint32_t screenHeight = TaxiGame::Environment::GetInstance()->GetScreenHeight();
m_content = new Content(m_graphicsEngine);
InterfaceProvider::m_content = m_content;
m_content->LoadTextures(basePath + "data/gui/");
m_content->LoadTextures(basePath + "data/textures/");
m_content->LoadShaders(basePath + "data/shaders/");
m_content->LoadModels(basePath + "data/models/");
m_content->LoadAnimations(basePath + "data/animations/");
m_content->LoadMaterials(basePath + "data/materials/");
m_content->CombineResources();
DrawingRoutines::Initialize();
DrawingRoutines::SetProjectionMatrix(sm::Matrix::PerspectiveMatrix(45.0f, static_cast<float>(screenWidth) / static_cast<float>(screenHeight), 0.1f, 1000.0f));
Shader *shader = m_content->Get<Shader>("sprite");
SpriteBatch *spriteBatch = new SpriteBatch(shader, sm::Matrix::Ortho2DMatrix(0, screenWidth, screenHeight, 0));
SpritesMap *spritesMap = new SpritesMap();
if (!spritesMap->LoadFromFile(basePath + "data/gui/SpritesMap.xml", m_content))
return false;
InterfaceProvider::m_graphicsEngine = m_graphicsEngine;
InterfaceProvider::m_spriteBatch = spriteBatch;
InterfaceProvider::m_spritesMap = spritesMap;
InterfaceProvider::m_fonts["digital_bold_24"] = FontRenderer::LoadFromFile((basePath + "data/fonts/digital_bold_24.xml").c_str(), spriteBatch);
InterfaceProvider::m_fonts["fenix_18"] = FontRenderer::LoadFromFile((basePath + "data/fonts/fenix_18.xml").c_str(), spriteBatch);
InterfaceProvider::m_fonts["fenix_26"] = FontRenderer::LoadFromFile((basePath + "data/fonts/fenix_26.xml").c_str(), spriteBatch);
debugSphere = m_content->Get<Model>("debug_sphere");
assert(debugSphere != NULL);
Shader *spriteShader = m_content->Get<Shader>("Sprite2");
assert(spriteShader != NULL);
spriteShader->BindVertexChannel(0, "a_position");
spriteShader->LinkProgram();
Sprite::Initialize(spriteShader);
Control::SetSpriteBatch(spriteBatch);
return true;
}