本文整理汇总了C++中Quad::setGLSLProgram方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::setGLSLProgram方法的具体用法?C++ Quad::setGLSLProgram怎么用?C++ Quad::setGLSLProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::setGLSLProgram方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
// Create and initialize window.
setErrorCallbackAndInit(error_callback);
GraphicsWindow* window = new GraphicsWindow(1200,800,"Test Window",NULL,NULL,key_callback);
window->makeContextCurrent();
// Initalize glew.
initGlew();
// Create and initialize Camera
FreeCamera* camera = new FreeCamera(45.0f, 16.0f/9.0f,
0.0f, 0.0f,
0.1f, 10000.0f,
0.0004f, 3.0f,
glm::vec3(0,0,-50),
glm::vec3(0,1,0),
glm::vec3(0,0,0),
true);
camera->setViewport(window->getWindowWidth(),window->getWindowHeight(),0.5f,0.5f);
// Load accumulation shader for accumulating all the transparent matrials, as well as their alphas.
GLSLProgram* defaultShader = new GLSLProgram();
defaultShader->initShaderProgram("Vert.glsl","","","","Frag.glsl");
// Load screen filling quad shader.
GLSLProgram* screenFillingQuadShader = new GLSLProgram();
screenFillingQuadShader->initShaderProgram("screenFillingQuadVert.glsl","","","","screenFillingQuadFrag.glsl");
// Load accumulation shader for accumulating all the transparent matrials, as well as their alphas.
GLSLProgram* accumTransparencyRevealageShader = new GLSLProgram();
accumTransparencyRevealageShader->initShaderProgram("AccumTransparencyRevealageVert.glsl","","","","AccumTransparencyRevealageFrag.glsl");
// Load Weighted Average shader, which will be used for final compositing (a variation of screen filling quad shader using multiple textures).
GLSLProgram* newOITCoverageShader = new GLSLProgram();
newOITCoverageShader->initShaderProgram("NewOITCoverageVert.glsl","","","","NewOITCoverageFrag.glsl");
// Create screen filling quad.
Quad* screenFillingQuad = new Quad(glm::vec3(-1.0,1.0,0), glm::vec3(-1.0,-1.0,0), glm::vec3(1.0,-1.0,0), glm::vec3(1.0,1.0,0), glm::vec3(0), 0, 0, 0);
screenFillingQuad->initQuad();
screenFillingQuad->setGLSLProgram(*newOITCoverageShader);
TextureManager::GetInstance().loadTexture("../Content/Textures/Particle_Smoke/smoke_particle_red_base.png");
TextureManager::GetInstance().loadTexture("../Content/Textures/Particle_Smoke/smoke_particle_grey_base_2.png");
TextureManager::GetInstance().loadTexture("../Content/Textures/Particle_Smoke/smoke_particle_grey_base_3.png");
Quad* quad1 = new Quad(glm::vec3(100+100,100+100,-1), glm::vec3(100+100,-100+100,-1), glm::vec3(-100+100,-100+100,-1), glm::vec3(-100+100,100+100,-1), glm::vec3(0), 10, 10, 0);
quad1->initQuad();
quad1->initDefaultTexture(255,0,0,89);
quad1->setTexture(TextureManager::GetInstance().getTextureHandle("../Content/Textures/Particle_Smoke/smoke_particle_grey_base_3.png"));
Quad* quad2 = new Quad(glm::vec3(100+100,100+100,-20), glm::vec3(100+100,-100+100,-20), glm::vec3(-100+100,-100+100,-20), glm::vec3(-100+100,100+100,-20), glm::vec3(0), 10, 10, 0);
quad2->initQuad();
quad2->initDefaultTexture(0,255,0,89);
quad2->setTexture(TextureManager::GetInstance().getTextureHandle("../Content/Textures/Particle_Smoke/smoke_particle_grey_base_2.png"));
Quad* quad3 = new Quad(glm::vec3(100+100,100+100,20), glm::vec3(100+100,-100+100,20), glm::vec3(-100+100,-100+100,20), glm::vec3(-100+100,100+100,20), glm::vec3(0), 10, 10, 0);
quad3->initQuad();
quad3->initDefaultTexture(0,0,255,89);
quad3->setTexture(TextureManager::GetInstance().getTextureHandle("../Content/Textures/Particle_Smoke/smoke_particle_red_base.png"));
Quad* quad4 = new Quad(glm::vec3(100+100,100+100,-40), glm::vec3(100+100,-100+100,-40), glm::vec3(-100+100,-100+100,-40), glm::vec3(-100+100,100+100,-40), glm::vec3(0), 10, 10, 0);
quad4->initQuad();
quad4->initDefaultTexture(255,0,127,50);
Quad* quad5 = new Quad(glm::vec3(100+100,100+100,40), glm::vec3(100+100,-100+100,40), glm::vec3(-100+100,-100+100,40), glm::vec3(-100+100,100+100,40), glm::vec3(0), 10, 10, 0);
quad5->initQuad();
quad5->initDefaultTexture(255,127,0,50);
ModelLoader* modelImporter = new ModelLoader();
modelImporter->importModel("../Content/Models/crytek-sponza/sponza.obj", processFlagsOnModelImport);
// Create and initialize model
Model* model = new Model(glm::vec3(0,0,0), "../Content/Models/crytek-sponza/");
model->loadModel(modelImporter->getScene());
// Create framebuffers
std::vector<unsigned int> activeColorAttachmentsOpaque;
std::vector<unsigned int> activeColorAttachmentsTransparent;
Framebuffer* opaqueFrameBuffer = new Framebuffer(window->getWindowWidth(),window->getWindowHeight());
activeColorAttachmentsOpaque.push_back(0);
opaqueFrameBuffer->setColorAttachment(0);
//frameBuffer->setDepthAttachment();
opaqueFrameBuffer->setDepthStencilTexture();
opaqueFrameBuffer->unbind();
Framebuffer* accumFrameBuffer = new Framebuffer(window->getWindowWidth(),window->getWindowHeight());
activeColorAttachmentsTransparent.push_back(0);
activeColorAttachmentsTransparent.push_back(1);
accumFrameBuffer->setColorAttachment(0);
accumFrameBuffer->setColorAttachment(1);
//.........这里部分代码省略.........