예제 #1
0
static void RenderSceneCB()
{
    pGameCamera->OnRender();

    glClear(GL_COLOR_BUFFER_BIT);

    static float Scale = 0.0f;

    Scale += 0.1f;

    Pipeline p;
    p.Rotate(0.0f, Scale, 0.0f);
    p.WorldPos(0.0f, 0.0f, 3.0f);
    p.SetCamera(*pGameCamera);
    p.SetPerspectiveProj(gPersProjInfo);

    glUniformMatrix4fv(gWVPLocation, 1, GL_TRUE, (const GLfloat*)p.GetWVPTrans());

    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);

    glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

    glDisableVertexAttribArray(0);

    glutSwapBuffers();
}
예제 #2
0
static void RenderSceneCB()
{
    pGameCamera->OnRender();

    glClear(GL_COLOR_BUFFER_BIT);

    static float Scale = 0.0f;

    Scale += 0.1f;

    Pipeline p;
    p.Rotate(0.0f, Scale, 0.0f);
    p.WorldPos(0.0f, 0.0f, 3.0f);
    p.SetCamera(pGameCamera->GetPos(), pGameCamera->GetTarget(), pGameCamera->GetUp());
    p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 1.0f, 100.0f);

    glUniformMatrix4fv(gWVPLocation, 1, GL_TRUE, (const GLfloat*)p.GetTrans());

    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)12);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
    pTexture->Bind(GL_TEXTURE0);
    glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);

    glutSwapBuffers();
}
예제 #3
0
    virtual void RenderSceneCB()
    {
        m_pGameCamera->OnRender();

        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

        m_scale += 0.01f;

        Pipeline p;
        p.Scale(0.1f, 0.1f, 0.1f);
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, 0.0f, 10.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 1.0f, 100.0f);
        m_pEffect->SetWVP(p.GetWVPTrans());
        m_pEffect->SetWorldMatrix(p.GetWorldTrans());
        m_pEffect->SetDirectionalLight(m_directionalLight);
        m_pEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        m_pEffect->SetMatSpecularIntensity(0.0f);
        m_pEffect->SetMatSpecularPower(0);

        m_pMesh->Render();

        glutSwapBuffers();
    }
예제 #4
0
파일: skybox.cpp 프로젝트: emeiri/ogldev
void SkyBox::Render()
{
    m_pSkyboxTechnique->Enable();
    
    GLint OldCullFaceMode;
    glGetIntegerv(GL_CULL_FACE_MODE, &OldCullFaceMode);
    GLint OldDepthFuncMode;
    glGetIntegerv(GL_DEPTH_FUNC, &OldDepthFuncMode);
    
    glCullFace(GL_FRONT);
    glDepthFunc(GL_LEQUAL);

    Pipeline p;    
    p.Scale(20.0f, 20.0f, 20.0f);
    p.Rotate(0.0f, 0.0f, 0.0f);
    p.WorldPos(m_pCamera->GetPos().x, m_pCamera->GetPos().y, m_pCamera->GetPos().z);
    p.SetCamera(m_pCamera->GetPos(), m_pCamera->GetTarget(), m_pCamera->GetUp());
    p.SetPerspectiveProj(m_persProjInfo);
    m_pSkyboxTechnique->SetWVP(p.GetWVPTrans());
    m_pCubemapTex->Bind(GL_TEXTURE0);
    m_pMesh->Render();  
    
    glCullFace(OldCullFaceMode);        
    glDepthFunc(OldDepthFuncMode);
}
예제 #5
0
파일: main.cpp 프로젝트: andriyut/ogldev
    virtual void RenderSceneCB()
    {
        m_pGameCamera->OnRender();

        glClear(GL_COLOR_BUFFER_BIT);

        m_scale += 0.01f;

        SpotLight sl[2];
        sl[0].DiffuseIntensity = 15.0f;
        sl[0].Color = Vector3f(1.0f, 1.0f, 0.7f);
        sl[0].Position = Vector3f(-0.0f, -1.9f, -0.0f);
        sl[0].Direction = Vector3f(sinf(m_scale), 0.0f, cosf(m_scale));
        sl[0].Attenuation.Linear = 0.1f;
        sl[0].Cutoff = 20.0f;

        sl[1].DiffuseIntensity = 5.0f;
        sl[1].Color = Vector3f(0.0f, 1.0f, 1.0f);
        sl[1].Position = m_pGameCamera->GetPos();
        sl[1].Direction = m_pGameCamera->GetTarget();
        sl[1].Attenuation.Linear = 0.1f;
        sl[1].Cutoff = 10.0f;

        m_pEffect->SetSpotLights(2, sl);


        Pipeline p;
        p.Rotate(0.0f, 0.0f, 0.0f);
        p.WorldPos(0.0f, 0.0f, 1.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 0.1f, 100.0f);
        m_pEffect->SetWVP(p.GetWVPTrans());
        const Matrix4f& WorldTransformation = p.GetWorldTrans();
        m_pEffect->SetWorldMatrix(WorldTransformation);
        m_pEffect->SetDirectionalLight(m_directionalLight);
        m_pEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        m_pEffect->SetMatSpecularIntensity(1.0f);
        m_pEffect->SetMatSpecularPower(32);

        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);
        glEnableVertexAttribArray(2);
        glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)12);
        glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)20);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IBO);
        m_pTexture->Bind(GL_TEXTURE0);
        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

        glDisableVertexAttribArray(0);
        glDisableVertexAttribArray(1);
        glDisableVertexAttribArray(2);

        glutSwapBuffers();
    }
예제 #6
0
    virtual void RenderSceneCB()
    {
        m_scale += 0.01f;

        m_pGameCamera->OnRender();

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        PointLight pl[2];
        pl[0].DiffuseIntensity = 0.25f;
        pl[0].Color = Vector3f(1.0f, 0.5f, 0.0f);
        pl[0].Position = Vector3f(3.0f, 1.0f, FieldDepth * (cosf(m_scale) + 1.0f) / 2.0f);
        pl[0].Attenuation.Linear = 0.1f;
        pl[1].DiffuseIntensity = 0.25f;
        pl[1].Color = Vector3f(0.0f, 0.5f, 1.0f);
        pl[1].Position = Vector3f(7.0f, 1.0f, FieldDepth * (sinf(m_scale) + 1.0f) / 2.0f);
        pl[1].Attenuation.Linear = 0.1f;
        m_pEffect->SetPointLights(2, pl);

        SpotLight sl[2];
        sl[0].DiffuseIntensity = 0.9f;
        sl[0].Color = Vector3f(0.0f, 1.0f, 1.0f);
        sl[0].Position = m_pGameCamera->GetPos();
        sl[0].Direction = m_pGameCamera->GetTarget();
        sl[0].Attenuation.Linear = 0.1f;
        sl[0].Cutoff = 10.0f;

        sl[1].DiffuseIntensity = 0.75f;
        sl[1].Color = Vector3f(0.0f, 0.5f, 1.0f);
        sl[1].Position = Vector3f(7.0f, 1.0f, FieldDepth * (sinf(m_scale) + 1.0f) / 2.0f);
        sl[1].Attenuation.Linear = 0.1f;
        m_pEffect->SetSpotLights(1, sl);

        Pipeline p;
        p.Scale(0.1f, 0.1f, 0.1f);
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, 0.0f, 10.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 1.0f, 100.0f);
        m_pEffect->SetWVP(p.GetWVPTrans());
        m_pEffect->SetWorldMatrix(p.GetWorldTrans());
        m_pEffect->SetDirectionalLight(m_directionalLight);
        m_pEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        m_pEffect->SetMatSpecularIntensity(0.0f);
        m_pEffect->SetMatSpecularPower(0);

        m_pMesh->Render();

        glutSwapBuffers();
    }
예제 #7
0
  virtual void RenderPass()
  {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    m_pShadowMapTechnique->SetTextureUnit(0);
    m_shadowMapFBO.BindForReading(GL_TEXTURE0);

    Pipeline p;
    p.Scale(5.0f, 5.0f, 5.0f);
    p.WorldPos(0.0f, 0.0f, 10.0f);
    p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
    p.SetPerspectiveProj(m_persProjInfo);
    m_pShadowMapTechnique->SetWorldViewProjection(p.GetWorldViewProjectionTrans());
    m_pQuad->Render();
  }
예제 #8
0
파일: main.cpp 프로젝트: andriyut/ogldev
    virtual void RenderPass()
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_pShadowMapTech->SetTextureUnit(0);
        m_shadowMapFBO.BindForReading(GL_TEXTURE0);

        Pipeline p;
        p.Scale(5.0f, 5.0f, 5.0f);
        p.WorldPos(0.0f, 0.0f, 10.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 1.0f, 50.0f);
        m_pShadowMapTech->SetWVP(p.GetWVPTrans());
        m_pQuad->Render();
    }
예제 #9
0
    virtual void RenderPass()//render to screen
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      
        m_pShadowMapTech->SetTextureUnit(0);//set the value to shaders
        m_shadowMapFBO.BindForReading(GL_TEXTURE0);//the i in GL_TEXTUREi must be same with m_pShadowMapTech->SetTextureUnit(i);

        Pipeline p;
        p.Scale(5.0f, 5.0f, 5.0f);
        p.WorldPos(0.0f, 0.0f, 10.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);
        m_pShadowMapTech->SetWVP(p.GetWVPTrans());
      
        m_pQuad->Render();       
    }
예제 #10
0
    virtual void RenderSceneCB()
    {
        m_scale += 0.0057f;

        m_pGameCamera->OnRender();

        glClear(GL_COLOR_BUFFER_BIT);

        PointLight pl[2];
        pl[0].DiffuseIntensity = 0.5f;
        pl[0].Color = Vector3f(1.0f, 0.5f, 0.0f);
        pl[0].Position = Vector3f(3.0f, 1.0f, FieldDepth * (cosf(m_scale) + 1.0f) / 2.0f);
        pl[0].Attenuation.Linear = 0.1f;
        pl[1].DiffuseIntensity = 0.5f;
        pl[1].Color = Vector3f(0.0f, 0.5f, 1.0f);
        pl[1].Position = Vector3f(7.0f, 1.0f, FieldDepth * (sinf(m_scale) + 1.0f) / 2.0f);
        pl[1].Attenuation.Linear = 0.1f;
        m_pEffect->SetPointLights(2, pl);
        
        Pipeline p;
        p.WorldPos(0.0f, 0.0f, 1.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 1.0f, 100.0f);
        m_pEffect->SetWVP(p.GetWVPTrans());
        const Matrix4f& WorldTransformation = p.GetWorldTrans();
        m_pEffect->SetWorldMatrix(WorldTransformation);
        m_pEffect->SetDirectionalLight(m_directionalLight);
        m_pEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        m_pEffect->SetMatSpecularIntensity(0.0f);
        m_pEffect->SetMatSpecularPower(0);
        
        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);
        glEnableVertexAttribArray(2);
        glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)12);
        glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)20);
        m_pTexture->Bind(GL_TEXTURE0);
        glDrawArrays(GL_TRIANGLES, 0, 6);

        glDisableVertexAttribArray(0);
        glDisableVertexAttribArray(1);
        glDisableVertexAttribArray(2); 

        glutSwapBuffers();
    }
예제 #11
0
    virtual void ShadowMapPass()//draw to the m_shadowMapFBO
    {
        m_shadowMapFBO.BindForWriting();

        glClear(GL_DEPTH_BUFFER_BIT);

        Pipeline p;
        p.Scale(0.1f, 0.1f, 0.1f);//notify that it is very small
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, 0.0f, 5.0f);
        p.SetCamera(m_spotLight.Position, m_spotLight.Direction, Vector3f(0.0f, 1.0f, 0.0f));
        p.SetPerspectiveProj(m_persProjInfo);
        m_pShadowMapTech->SetWVP(p.GetWVPTrans());
        m_pMesh->Render();
        
        glBindFramebuffer(GL_FRAMEBUFFER, 0);//reset to use the default framebuffer
    }
예제 #12
0
  virtual void ShadowMapPass()
  {
    m_shadowMapFBO.BindForWriting();

    glClear(GL_DEPTH_BUFFER_BIT);

    Pipeline p;
    p.Scale(0.1f, 0.1f, 0.1f);
    p.Rotate(0.0f, m_scale, 0.0f);
    p.WorldPos(0.0f, 0.0f, 5.0f);
    p.SetCamera(m_spotLight.Position, m_spotLight.Direction, Vector3f(0.0f, 1.0f, 0.0f));
    p.SetPerspectiveProj(m_persProjInfo);
    m_pShadowMapTechnique->SetWorldViewProjection(p.GetWorldViewProjectionTrans());
    m_pMesh->Render();

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
  }
예제 #13
0
파일: main.cpp 프로젝트: andriyut/ogldev
    virtual void ShadowMapPass()
    {
        m_shadowMapFBO.BindForWriting();

        glClear(GL_DEPTH_BUFFER_BIT);

        Pipeline p;
        p.Scale(0.2f, 0.2f, 0.2f);
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, 0.0f, 5.0f);
        p.SetCamera(m_spotLight.Position, m_spotLight.Direction, Vector3f(0.0f, 1.0f, 0.0f));
        p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 1.0f, 50.0f);
        m_pShadowMapTech->SetWVP(p.GetWVPTrans());
        m_pMesh->Render();

        glBindFramebuffer(GL_FRAMEBUFFER, 0);
    }
예제 #14
0
파일: tutorial35.cpp 프로젝트: tpphu/opengl
    void DSGeometryPass()
    {
		m_DSGeomPassTech.Enable();

        m_gbuffer.BindForWriting();

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		Pipeline p;
        p.Scale(0.1f, 0.1f, 0.1f);
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(-0.8f, -1.0f, 12.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);
        m_DSGeomPassTech.SetWVP(p.GetWVPTrans());        
		m_DSGeomPassTech.SetWorldMatrix(p.GetWorldTrans());
        m_mesh.Render();       
    }
예제 #15
0
파일: main.cpp 프로젝트: LIngBY/ogldev
    void DSPointLightsPass()
    {
        m_DSPointLightPassTech.Enable();
        m_DSPointLightPassTech.SetEyeWorldPos(m_pGameCamera->GetPos());        
        
        Pipeline p;
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);        
           
		for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLight); i++) {
            m_DSPointLightPassTech.SetPointLight(m_pointLight[i]);            
            p.WorldPos(m_pointLight[i].Position);
            float BSphereScale = CalcPointLightBSphere(m_pointLight[i]);
            p.Scale(BSphereScale, BSphereScale, BSphereScale);		
            m_DSPointLightPassTech.SetWVP(p.GetWVPTrans());
            m_bsphere.Render();                   
		}        
    }
예제 #16
0
    void RenderSceneIntoDepth()
    {
        glDrawBuffer(GL_NONE);
              
        m_nullTech.Enable();

        Pipeline p;
        
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);                       
                
        m_boxOrientation.m_rotation = Vector3f(0, m_scale, 0);
        p.Orient(m_boxOrientation);
        m_nullTech.SetWVP(p.GetWVPTrans());        
        m_box.Render();                
        
        p.Orient(m_quadOrientation);
        m_nullTech.SetWVP(p.GetWVPTrans());
        m_quad.Render();             
    }
예제 #17
0
파일: main.cpp 프로젝트: LIngBY/ogldev
    virtual void RenderSceneCB()
    {   
        CalcFPS();
        
        m_scale += 0.005f;
        
        m_pGameCamera->OnRender();

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_pEffect->Enable();
        
        vector<Matrix4f> Transforms;
               
        float RunningTime = (float)((double)GetCurrentTimeMillis() - (double)m_startTime) / 1000.0f;

        m_mesh.BoneTransform(RunningTime, Transforms);
        
        for (uint i = 0 ; i < Transforms.size() ; i++) {
            m_pEffect->SetBoneTransform(i, Transforms[i]);
        }
        
        m_pEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        
        Pipeline p;
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);           
        p.Scale(0.1f, 0.1f, 0.1f);                
             
        Vector3f Pos(m_position);
        p.WorldPos(Pos);        
        p.Rotate(270.0f, 180.0f, 0.0f);       
        m_pEffect->SetWVP(p.GetWVPTrans());
        m_pEffect->SetWorldMatrix(p.GetWorldTrans());            

        m_mesh.Render();
                              
        RenderFPS();
        
        glutSwapBuffers();
    }
예제 #18
0
    void ShadowMapPass()
    {
        glCullFace(GL_FRONT);
        
        m_shadowMapFBO.BindForWriting();

        glClear(GL_DEPTH_BUFFER_BIT);

        m_pShadowMapEffect->Enable();

        Pipeline p;
        p.Scale(0.1f, 0.1f, 0.1f);
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, 0.0f, 3.0f);
        p.SetCamera(m_spotLight.Position, m_spotLight.Direction, Vector3f(0.0f, 1.0f, 0.0f));
        p.SetPerspectiveProj(m_persProjInfo);
        m_pShadowMapEffect->SetWVP(p.GetWVPTrans());
        m_mesh.Render();
        
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
    }
예제 #19
0
    void RenderPass()
    {
        glCullFace(GL_BACK);
        
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_lightingEffect.Enable();
        m_shadowMapFBO.BindForReading(SHADOW_TEXTURE_UNIT);
        m_lightingEffect.SetEyeWorldPos(m_pGameCamera->GetPos());
        
        Pipeline p;
        p.SetPerspectiveProj(m_persProjInfo);    
        p.SetCamera(*m_pGameCamera);
        
        // Render the quads
        m_pGroundTex->Bind(COLOR_TEXTURE_UNIT);
        p.Orient(m_quad1Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());        
        m_quad.Render();
        
        p.Orient(m_quad2Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());        
        m_quad.Render();        

        // Render the meshes
        p.Orient(m_mesh1Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());       
        m_mesh.Render();        
        
        p.Orient(m_mesh2Orientation);
        m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());
        m_lightingEffect.SetWVP(p.GetWVPTrans());       
        m_mesh.Render();                
    }
예제 #20
0
파일: main.cpp 프로젝트: andriyut/ogldev
    virtual void RenderSceneCB()
    {
        m_pGameCamera->OnRender();

        glClear(GL_COLOR_BUFFER_BIT);

        m_scale += 0.1f;

        Pipeline p;
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, 0.0f, 1.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(60.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 1.0f, 100.0f);
        m_pEffect->SetWVP(p.GetWVPTrans());
        const Matrix4f& WorldTransformation = p.GetWorldTrans();
        m_pEffect->SetWorldMatrix(WorldTransformation);
        m_pEffect->SetDirectionalLight(m_directionalLight);
        m_pEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        m_pEffect->SetMatSpecularIntensity(1.0f);
        m_pEffect->SetMatSpecularPower(32);

        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);
        glEnableVertexAttribArray(2);
        glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)12);
        glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)20);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IBO);
        m_pTexture->Bind(GL_TEXTURE0);
        glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

        glDisableVertexAttribArray(0);
        glDisableVertexAttribArray(1);
        glDisableVertexAttribArray(2);

        glutSwapBuffers();
    }
예제 #21
0
파일: main.cpp 프로젝트: andriyut/ogldev
    void PickingPhase()
    {
        Pipeline p;
        p.Scale(0.1f, 0.1f, 0.1f);
        p.Rotate(0.0f, 90.0f, 0.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);

        m_pickingTexture.EnableWriting();
        
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
        m_pickingEffect.Enable();
        
        for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_worldPos) ; i++) {
            p.WorldPos(m_worldPos[i]);
            m_pickingEffect.SetObjectIndex(i);
            m_pickingEffect.SetWVP(p.GetWVPTrans());    
            m_pMesh->Render(&m_pickingEffect);
        }
        
        m_pickingTexture.DisableWriting();        
    }
예제 #22
0
 void RenderPhase()
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
     Pipeline p;
     p.Scale(0.1f, 0.1f, 0.1f);
     p.Rotate(0.0f, 90.0f, 0.0f);
     p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
     p.SetPerspectiveProj(m_persProjInfo);
     
     // If the left mouse button is clicked check if it hit a triangle
     // and color it red
     if (m_leftMouseButton.IsPressed) {
         PickingTexture::PixelInfo Pixel = m_pickingTexture.ReadPixel(m_leftMouseButton.x, WINDOW_HEIGHT - m_leftMouseButton.y - 1);
         GLExitIfError;
         if (Pixel.PrimID != 0) {                
             m_simpleColorEffect.Enable();
             assert(Pixel.ObjectID < ARRAY_SIZE_IN_ELEMENTS(m_worldPos));
             p.WorldPos(m_worldPos[(uint)Pixel.ObjectID]);
             m_simpleColorEffect.SetWVP(p.GetWVPTrans());
             // Must compensate for the decrement in the FS!
             m_pMesh->Render((uint)Pixel.DrawID, (uint)Pixel.PrimID - 1); 
         }
     }
     
     // render the objects as usual
     m_lightingEffect.Enable();
     m_lightingEffect.SetEyeWorldPos(m_pGameCamera->GetPos());
     
     for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_worldPos) ; i++) {
         p.WorldPos(m_worldPos[i]);
         m_lightingEffect.SetWVP(p.GetWVPTrans());
         m_lightingEffect.SetWorldMatrix(p.GetWorldTrans());                
         m_pMesh->Render(NULL);
     }        
 }
예제 #23
0
    void RenderPass()
    {
        glCullFace(GL_BACK);
        
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_pLightingEffect->Enable();
             
        m_shadowMapFBO.BindForReading(GL_TEXTURE1);

        Pipeline p;
        p.SetPerspectiveProj(m_persProjInfo);           
        p.Scale(10.0f, 10.0f, 10.0f);
        p.WorldPos(0.0f, 0.0f, 1.0f);
        p.Rotate(90.0f, 0.0f, 0.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());

        m_pLightingEffect->SetWVP(p.GetWVPTrans());
        m_pLightingEffect->SetWorldMatrix(p.GetWorldTrans());
        p.SetCamera(m_spotLight.Position, m_spotLight.Direction, Vector3f(0.0f, 1.0f, 0.0f));
        m_pLightingEffect->SetLightWVP(p.GetWVPTrans());
        m_pLightingEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        m_pGroundTex->Bind(GL_TEXTURE0);
        m_quad.Render();
 
        p.Scale(0.1f, 0.1f, 0.1f);
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, 0.0f, 3.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        m_pLightingEffect->SetWVP(p.GetWVPTrans());
        m_pLightingEffect->SetWorldMatrix(p.GetWorldTrans());
        p.SetCamera(m_spotLight.Position, m_spotLight.Direction, Vector3f(0.0f, 1.0f, 0.0f));
        m_pLightingEffect->SetLightWVP(p.GetWVPTrans());

        m_mesh.Render();        
    }
예제 #24
0
void Scene::render()
{
    // Efface le tampon d'affichage
    glClear(GL_COLOR_BUFFER_BIT);

    static float Scale = 0.0f;
    Scale += 0.5f;

    Pipeline p;
    p.Rotate(0.0f, Scale, 0.0f);
    p.WorldPos(0.0f, 0.0f, 0.0f);
    p.SetPerspectiveProj(75.0f, 800.0f, 600.0f, 1.0f, 100.0f);

    QVector3D CameraPos(0.0f, 0.0f, 1.1f);
    QVector3D CameraTarget(0.0f, 0.0f, 1.0f);
    QVector3D CameraUp(0.0f, 1.0f, 0.0f);

    p.SetCamera(CameraPos, CameraTarget, CameraUp);

    m_shaderProgram.bind();
    m_shaderProgram.setUniformValue("gWVP", p.GetTrans());

    glDrawElements(GL_LINE_STRIP, m_indices.size(), GL_UNSIGNED_INT, 0);
}
예제 #25
0
 void RenderScene()
 {
     // Render the object as-is
     m_LightingTech.Enable();
                                  
     Pipeline p;
     p.SetPerspectiveProj(m_persProjInfo);
     p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());        
     p.WorldPos(m_boxPos);
     m_LightingTech.SetWorldMatrix(p.GetWorldTrans());        
     m_LightingTech.SetWVP(p.GetWVPTrans());        
     m_mesh.Render();
     
     // Render the object's silhouette
     m_silhouetteTech.Enable();
     
     m_silhouetteTech.SetWorldMatrix(p.GetWorldTrans());        
     m_silhouetteTech.SetWVP(p.GetWVPTrans());        
     m_silhouetteTech.SetLightPos(Vector3f(0.0f, 10.0f, 0.0f));
     
     glLineWidth(5.0f);
     
     m_mesh.Render();        
 }        
예제 #26
0
파일: main.cpp 프로젝트: Barricade/ogldev
    virtual void RenderSceneCB()
    {
        m_pGameCamera->OnRender();
        m_scale += 0.05f;
        
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_pLightingTechnique->Enable();
       
        Pipeline p;        
        p.Scale(0.1f, 0.1f, 0.1f);
        p.Rotate(0.0f, m_scale, 0.0f);
        p.WorldPos(0.0f, -5.0f, 3.0f);
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);
        
        m_pLightingTechnique->SetWVP(p.GetWVPTrans());
        m_pLightingTechnique->SetWorldMatrix(p.GetWorldTrans());
        m_pTankMesh->Render();
        
        m_pSkyBox->Render();
      
        glutSwapBuffers();
    }
예제 #27
0
    virtual void RenderSceneCB()
    {   
        CalcFPS();
        
        m_scale += 0.005f;

        m_pGameCamera->OnRender();

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_pEffect->Enable();
        m_pEffect->SetEyeWorldPos(m_pGameCamera->GetPos());
        
        Pipeline p;
        p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());
        p.SetPerspectiveProj(m_persProjInfo);   
        p.Rotate(0.0f, 90.0f, 0.0f);
        p.Scale(0.005f, 0.005f, 0.005f);                

        Matrix4f WVPMatrics[NUM_INSTANCES];
        Matrix4f WorldMatrices[NUM_INSTANCES];
        
        for (unsigned int i = 0 ; i < NUM_INSTANCES ; i++) {
            Vector3f Pos(m_positions[i]);
            Pos.y += sinf(m_scale) * m_velocity[i];
            p.WorldPos(Pos);        
            WVPMatrics[i] = p.GetWVPTrans().Transpose();
            WorldMatrices[i] = p.GetWorldTrans().Transpose();
        }
        
        m_pMesh->Render(NUM_INSTANCES, WVPMatrics, WorldMatrices);
        
        RenderFPS();
        
        glutSwapBuffers();
    }
예제 #28
0
std::function<void ()> Tutorial::makeDisplayFunc()
{
  switch (_tutorialID) {
  case 1:
  case 2:
  case 3:
    return nullptr;
  case 4:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

      glDrawArrays(GL_TRIANGLES, 0, 3);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 5:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.00001f;

      /// glUniform1f provides a value for the Uniform attribute of the shader.
      /// In this example, sin(scale).
      ///
      /// Internally, the shader uses the value of scale to adjust the Position (x,y) of the vertices.
      ///
      glUniform1f(_gScaleLocation, sinf(scale));

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

      glDrawArrays(GL_TRIANGLES, 0, 3);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 6:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.00001f;

      Matrix4f world;

      world.m[0][0] = 1.0f;
      world.m[0][1] = 0.0f;
      world.m[0][2] = 0.0f;
      world.m[0][3] = sinf(scale);
      world.m[1][0] = 0.0f;
      world.m[1][1] = 1.0f;
      world.m[1][2] = 0.0f;
      world.m[1][3] = 0.0f;
      world.m[2][0] = 0.0f;
      world.m[2][1] = 0.0f;
      world.m[2][2] = 1.0f;
      world.m[2][3] = 0.0f;
      world.m[3][0] = 0.0f;
      world.m[3][1] = 0.0f;
      world.m[3][2] = 0.0f;
      world.m[3][3] = 1.0f;

      glUniformMatrix4fv(_gWorldLocation, 1, GL_TRUE, &world.m[0][0]);

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

      glDrawArrays(GL_TRIANGLES, 0, 3);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 7:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);
      glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

      if (_msOnOff) {
        glEnable(GL_MULTISAMPLE_ARB);
        glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);

        // detect current settings
        GLint iMultiSample = 0;
        GLint iNumSamples = 0;
        glGetIntegerv(GL_SAMPLE_BUFFERS, &iMultiSample);
        glGetIntegerv(GL_SAMPLES, &iNumSamples);
//        printf("MSAA on, GL_SAMPLE_BUFFERS = %d, GL_SAMPLES = %d\n", iMultiSample, iNumSamples);
      }
      else {
        glDisable(GL_MULTISAMPLE_ARB);
      }

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.0005f;

      Matrix4f world;

      world.m[0][0] = cosf(scale);
      world.m[0][1] = -sinf(scale);
      world.m[0][2] = 0.0f;
      world.m[0][3] = 0.0f;
      world.m[1][0] = sinf(scale);
      world.m[1][1] =  cosf(scale);
      world.m[1][2] = 0.0f;
      world.m[1][3] = 0.0f;
      world.m[2][0] = 0.0f;
      world.m[2][1] = 0.0f;
      world.m[2][2] = 1.0f;
      world.m[2][3] = 0.0f;
      world.m[3][0] = 0.0f;
      world.m[3][1] = 0.0f;
      world.m[3][2] = 0.0f;
      world.m[3][3] = 1.0f;

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldLocation, 1, GL_TRUE, &world.m[0][0]);

      /// Load the desired size into the shader.
      glUniform1f(_gScaleLocation, 0.5);

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

      glDrawArrays(GL_TRIANGLES, 0, 6);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 8:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.001f;

      Matrix4f world;

      world.m[0][0] = sinf(scale);
      world.m[0][1] = 0.0f;
      world.m[0][2] = 0.0f;
      world.m[0][3] = 0.0f;
      world.m[1][0] = 0.0f;
      world.m[1][1] = sinf(scale);
      world.m[1][2] = 0.0f;
      world.m[1][3] = 0.0f;
      world.m[2][0] = 0.0f;
      world.m[2][1] = 0.0f;
      world.m[2][2] = sinf(scale);
      world.m[2][3] = 0.0f;
      world.m[3][0] = 0.0f;
      world.m[3][1] = 0.0f;
      world.m[3][2] = 0.0f;
      world.m[3][3] = 1.0f;

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldLocation, 1, GL_TRUE, &world.m[0][0]);

      /// Load the desired size into the shader.
      glUniform1f(_gScaleLocation, 0.5);

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

      glDrawArrays(GL_TRIANGLES, 0, 3);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 9:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.001f;

      Matrix4f world;

      ///

      world.m[0][0] = sinf(scale);
      world.m[0][1] = 0.0f;
      world.m[0][2] = 0.0f;
      world.m[0][3] = 0.0f;
      world.m[1][0] = 0.0f;
      world.m[1][1] = sinf(scale);
      world.m[1][2] = 0.0f;
      world.m[1][3] = 0.0f;
      world.m[2][0] = 0.0f;
      world.m[2][1] = 0.0f;
      world.m[2][2] = sinf(scale);
      world.m[2][3] = 0.0f;
      world.m[3][0] = 0.0f;
      world.m[3][1] = 0.0f;
      world.m[3][2] = 0.0f;
      world.m[3][3] = 1.0f;

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldLocation, 1, GL_TRUE, &world.m[0][0]);

      /// Load the desired size into the shader.
      //  glUniform1f(_gScaleLocation, 0.5);

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

      glDrawArrays(GL_TRIANGLES, 0, 3);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 10:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.001f;

      Matrix4f world;

      ///

      world.m[0][0] = cosf(scale);
      world.m[0][1] = 0.0f;
      world.m[0][2] = -sinf(scale);
      world.m[0][3] = 0.0f;
      world.m[1][0] = 0.0f;
      world.m[1][1] = 1.0f;
      world.m[1][2] = 0.0f;
      world.m[1][3] = 0.0f;
      world.m[2][0] = sinf(scale);
      world.m[2][1] = 0.0f;
      world.m[2][2] = cosf(scale);
      world.m[2][3] = 0.0f;
      world.m[3][0] = 0.0f;
      world.m[3][1] = 0.0f;
      world.m[3][2] = 0.0f;
      world.m[3][3] = 1.0f;

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldLocation, 1, GL_TRUE, &world.m[0][0]);

      /// Load the desired size into the shader.
      //  glUniform1f(_gScaleLocation, 0.9);

      glEnableVertexAttribArray(0);

      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IBO);

      //  glDrawArrays(GL_TRIANGLES, 0, 3);
      glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 11:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.001f;

      Pipeline pipeLine;
      pipeLine.Scale(sinf(scale * 0.1f), sinf(scale * 0.1f), sinf(scale * 0.1f));
      pipeLine.WorldPos(sinf(scale), 0.0f, 0.0f);
      pipeLine.Rotate(sinf(scale) * 90.0f, sinf(scale) * 90.0f, sinf(scale) * 90.0f);

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldLocation, 1, GL_TRUE, (const GLfloat*)pipeLine.GetWorldTrans());

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IBO);

      glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
    };
  case 12:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.01f;

      Pipeline pipeLine;
      pipeLine.Rotate(0.0f, scale, 0.0f);
      pipeLine.WorldPos(0.0f, 0.0f, 5.0f);
      pipeLine.SetPerspectiveProj(_gPersProjInfo);

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldLocation, 1, GL_TRUE, (const GLfloat*)pipeLine.GetWPTrans());

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IBO);

      glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
      //  QThread::msleep(1);
    };
  case 13:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.01f;

      Pipeline pipeLine;
      pipeLine.Rotate(0.0f, scale, 0.0f);
      pipeLine.WorldPos(0.0f, 0.0f, 3.0f);

      Vector3f CameraPos(0.0f, 0.0f, -3.0f);
      Vector3f CameraTarget(0.0f, 0.0f, 2.0f);
      Vector3f CameraUp(0.0f, 1.0f, 0.0f);
      pipeLine.SetCamera(CameraPos, CameraTarget, CameraUp);
      pipeLine.SetPerspectiveProj(_gPersProjInfo);

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldViewProjectionLocation, 1, GL_TRUE, (const GLfloat*)pipeLine.GetWorldViewProjectionTrans());

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IBO);

      glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
      //  QThread::msleep(1);
    };
  case 14:
    return [ & ]() {
      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.01f;

      Pipeline pipeLine;
      pipeLine.Rotate(0.0f, scale, 0.0f);
      pipeLine.WorldPos(0.0f, 0.0f, 3.0f);
      pipeLine.SetCamera(*_pGameCamera);
      pipeLine.SetPerspectiveProj(_gPersProjInfo);

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldViewProjectionLocation, 1, GL_TRUE, (const GLfloat*)pipeLine.GetWorldViewProjectionTrans());

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IBO);

      glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
      //  QThread::msleep(1);};
    };
  case 15:
    return [ & ]() {
      _pGameCamera->OnRender();

      glClear(GL_COLOR_BUFFER_BIT);

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.01f;

      Pipeline pipeLine;
      pipeLine.Rotate(0.0f, scale, 0.0f);
      pipeLine.WorldPos(0.0f, 0.0f, 3.0f);
      pipeLine.SetCamera(*_pGameCamera);
      pipeLine.SetPerspectiveProj(_gPersProjInfo);

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldViewProjectionLocation, 1, GL_TRUE, (const GLfloat*)pipeLine.GetWorldViewProjectionTrans());

      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IBO);

      glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

      glDisableVertexAttribArray(0);

      glutSwapBuffers();
      //  QThread::msleep(1);};
    };
  case 16:
    return [ & ]() {
      _pGameCamera->OnRender();

      glClear(GL_COLOR_BUFFER_BIT);

      if (_msOnOff) {
        glEnable(GL_MULTISAMPLE_ARB);
      }
      else {
        glDisable(GL_MULTISAMPLE_ARB);
      }

      /// allocate a static variable scale
      static float scale = 0.0f;

      /// increment scale by 0.001.
      scale += 0.05f;

      Pipeline pipeLine;
      pipeLine.Rotate(0.0f, scale, 0.0f);
      pipeLine.WorldPos(0.0f, 0.0f, 3.0f);
      pipeLine.SetCamera(*_pGameCamera);
      pipeLine.SetPerspectiveProj(_gPersProjInfo);

      /// Load the matrix into the shader.
      glUniformMatrix4fv(_gWorldViewProjectionLocation, 1, GL_TRUE, (const GLfloat*)pipeLine.GetWorldViewProjectionTrans());

      glEnableVertexAttribArray(0);
      glEnableVertexAttribArray(1);
      glBindBuffer(GL_ARRAY_BUFFER, _VBO);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
      glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)12);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _IBO);
      _pTexture->Bind(GL_TEXTURE0);
      glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, 0);

      glDisableVertexAttribArray(0);
      glDisableVertexAttribArray(1);

      glutSwapBuffers();
      //  QThread::msleep(1);};
    };
  }
  return nullptr;
}