public override void display()
        {
            g_lightTimer.Update();

            GL.ClearColor(0.75f, 0.75f, 1.0f, 1.0f);
            GL.ClearDepth(1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            if((g_pObjectMesh != null) && (g_pCubeMesh != null))
            {
                MatrixStack modelMatrix = new MatrixStack();
                modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
                Matrix4 worldToCamMat = modelMatrix.Top();

                LightBlock lightData = new LightBlock(NUMBER_OF_LIGHTS);

                lightData.ambientIntensity = new Vector4(0.2f, 0.2f, 0.2f, 1.0f);
                lightData.lightAttenuation = g_fLightAttenuation;

                Vector3 globalLightDirection = new Vector3(0.707f, 0.707f, 0.0f);

                lightData.lights[0].cameraSpaceLightPos =
                    Vector4.Transform(new Vector4(globalLightDirection, 0.0f), worldToCamMat);
                lightData.lights[0].lightIntensity = new Vector4(0.6f, 0.6f, 0.6f, 1.0f);

                lightData.lights[1].cameraSpaceLightPos = Vector4.Transform(CalcLightPosition(), worldToCamMat);
                lightData.lights[1].lightIntensity = new Vector4(0.4f, 0.4f, 0.4f, 1.0f);

                g_litShaderProg.lightBlock.Update(lightData);
                g_litTextureProg.lightBlock.Update(lightData);

                using ( PushStack pushstack = new PushStack(modelMatrix))
                {
                    modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
                    modelMatrix.Scale(2.0f);

                    Matrix3 normMatrix = new Matrix3(modelMatrix.Top());
                    normMatrix.Transpose();
                    //TEST
                    normMatrix = Matrix3.Identity;
                    //normMatrix = glm::transpose(glm::inverse(normMatrix));

                    ProgramData prog = g_bUseTexture ? g_litTextureProg : g_litShaderProg;

                    GL.UseProgram(prog.theProgram);
                    Matrix4 mm = modelMatrix.Top();
                    GL.UniformMatrix4(prog.modelToCameraMatrixUnif, false, ref mm);
                    GL.UniformMatrix3(prog.normalModelToCameraMatrixUnif, false, ref normMatrix);

                    GL.ActiveTexture(TextureUnit.Texture0 + g_gaussTexUnit);
                    GL.BindTexture(TextureTarget.Texture1D, g_gaussTextures[g_currTexture]);
                    GL.BindSampler(g_gaussTexUnit, g_gaussSampler);

                    g_pObjectMesh.Render("lit");

                    GL.BindSampler(g_gaussTexUnit, 0);
                    GL.BindTexture(TextureTarget.Texture1D, 0);

                    GL.UseProgram(0);
                }

                if(g_bDrawLights)
                {
                    using (PushStack pushstack = new PushStack(modelMatrix))
                    {
                        modelMatrix.Translate(new Vector3(CalcLightPosition()));
                        modelMatrix.Scale(0.25f);

                        GL.UseProgram(g_Unlit.theProgram);
                        Matrix4 mm = modelMatrix.Top();
                        GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm);

                        Vector4 lightColor = new Vector4(1f, 1f, 1f, 1f);
                        GL.Uniform4(g_Unlit.objectColorUnif, ref lightColor);
                        g_pCubeMesh.Render("flat");
                    }

                    modelMatrix.Translate(globalLightDirection * 100.0f);
                    modelMatrix.Scale(5.0f);

                    Matrix4 mm2 = modelMatrix.Top();
                    GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm2);
                    g_pCubeMesh.Render("flat");

                    GL.UseProgram(0);
                }

                if(g_bDrawCameraPos)
                {
                    using (PushStack pushstack = new PushStack(modelMatrix))
                    {
                        modelMatrix.SetIdentity();
                        modelMatrix.Translate(new Vector3(0.0f, 0.0f, -g_viewPole.GetView().radius));
                        modelMatrix.Scale(0.25f);

                        GL.Disable(EnableCap.DepthTest);
                        GL.DepthMask(false);
                        GL.UseProgram(g_Unlit.theProgram);
                        Matrix4 mm = modelMatrix.Top();
                        GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm);
                        GL.Uniform4(g_Unlit.objectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f);
                        g_pCubeMesh.Render("flat");
                        GL.DepthMask(true);
                        GL.Enable(EnableCap.DepthTest);
                        GL.Uniform4(g_Unlit.objectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f);
                        g_pCubeMesh.Render("flat");
                    }
                }
            }
        }
        public override void display()
        {
            if(g_pScene == null)
                return;

            g_timer.Update();

            GL.ClearColor(0.8f, 0.8f, 0.8f, 1.0f);
            GL.ClearDepth(1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit |ClearBufferMask.DepthBufferBit);

            MatrixStack modelMatrix = new MatrixStack();
            modelMatrix.ApplyMatrix(g_viewPole.CalcMatrix());

            BuildLights(modelMatrix.Top());

            if (rightMultiply)
            {
                g_nodes[0].NodeSetOrient(Quaternion.FromAxisAngle(new Vector3(0.0f, 1.0f, 0.0f),
                    360.0f *  g_timer.GetAlpha()/reduceSpeed));
                g_nodes[3].NodeSetOrient(Quaternion.Multiply(g_spinBarOrient,
                    Quaternion.FromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), 360.0f * g_timer.GetAlpha()/reduceSpeed)));
            }
            else
            {
                g_nodes[0].NodeSetOrient(Quaternion.FromAxisAngle(new Vector3(0.0f, 1.0f, 0.0f),
                    360.0f *  g_timer.GetAlpha()/reduceSpeed));
                g_nodes[3].NodeSetOrient(Quaternion.Multiply(
                    Quaternion.FromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), 360.0f * g_timer.GetAlpha()/reduceSpeed),
                    g_spinBarOrient));
            }

            {
                MatrixStack persMatrix = new MatrixStack();
                persMatrix.Perspective(60.0f, (width/2f / height), g_fzNear, g_fzFar);

                // added
                //persMatrix.Translate(translateVector);
                //persMatrix.Scale(scaleFactor);
                // end added

                ProjectionBlock projData = new ProjectionBlock();
                projData.cameraToClipMatrix = persMatrix.Top();

                GL.UseProgram(g_unlitProg);
                GL.UniformMatrix4(g_unlitCameraToClipMatrixUnif, false, ref projData.cameraToClipMatrix);
                GL.UseProgram(0);

                GL.UseProgram(g_pScene.FindProgram("p_lit"));
                GL.UniformMatrix4(g_litCameraToClipMatrixUnif, false, ref projData.cameraToClipMatrix);
                GL.UseProgram(0);
            }

            GL.Viewport(0, 0, width/2, height);
            g_pScene.Render(modelMatrix.Top());

            if(g_bDrawCameraPos)
            {
                using (PushStack pushstack = new PushStack(modelMatrix))//Draw lookat point.
                {
                    modelMatrix.SetIdentity();
                    modelMatrix.Translate(new Vector3(0.0f, 0.0f, -g_viewPole.GetView().radius));
                    modelMatrix.Scale(0.5f);

                    GL.Disable(EnableCap.DepthTest);
                    GL.DepthMask(false);
                    GL.UseProgram(g_unlitProg);
                    Matrix4 mm = modelMatrix.Top();
                    GL.UniformMatrix4(g_unlitModelToCameraMatrixUnif, false, ref mm);
                    GL.Uniform4(g_unlitObjectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f);
                    g_pSphereMesh.Render("flat");
                    GL.DepthMask(true);
                    GL.Enable(EnableCap.DepthTest);
                    GL.Uniform4(g_unlitObjectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f);
                    g_pSphereMesh.Render("flat");
                }
            }

            {
                MatrixStack persMatrix = new MatrixStack();
                Matrix4 applyMatrix = g_persViewPole.CalcMatrix();
                applyMatrix.Row3 = Vector4.Zero;
                applyMatrix.Column3 = Vector4.Zero;
                applyMatrix.M44 = 1f;
                persMatrix.ApplyMatrix(applyMatrix);
                persMatrix.Perspective(60.0f, (width/2f / height), g_fzNear, g_fzFar);

                // added
                persMatrix.Translate(translateVector);
                persMatrix.Scale(scaleFactor);
                // end added

                ProjectionBlock projData = new ProjectionBlock();
                projData.cameraToClipMatrix = persMatrix.Top();

                GL.UseProgram(g_unlitProg);
                GL.UniformMatrix4(g_unlitCameraToClipMatrixUnif, false, ref projData.cameraToClipMatrix);
                GL.UseProgram(0);

                GL.UseProgram(g_pScene.FindProgram("p_lit"));
                GL.UniformMatrix4(g_litCameraToClipMatrixUnif, false, ref projData.cameraToClipMatrix);
                GL.UseProgram(0);

            }

            if(!g_bDepthClampProj)
                GL.Disable(EnableCap.DepthClamp);
            GL.Viewport(width/2, 0, width/2, height);
            g_pScene.Render(modelMatrix.Top());
            GL.Enable(EnableCap.DepthClamp);
        }
        public override void display()
        {
            if(g_pScene == null)
                return;

            g_lights.UpdateTime();

            float gamma = g_isGammaCorrect ? g_gammaValue : 1.0f;

            Vector4 bkg = g_lights.GetBackgroundColor();
            GL.ClearColor(bkg[0], bkg[1], bkg[2], bkg[3]);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            MatrixStack modelMatrix = new MatrixStack();
            modelMatrix.SetMatrix(g_viewPole.CalcMatrix());

            Matrix4 worldToCamMat = modelMatrix.Top();
            LightBlock lightData = g_lights.GetLightInformationGamma(worldToCamMat);

            lightData.gamma = gamma;

            foreach (SceneProgramData spd in g_Programs)
            {
                spd.lightBlock.Update(lightData);
            }

            if(g_pScene != null)
            {
                using ( PushStack pushstack = new PushStack(modelMatrix))
                {
                    g_pScene.Draw(modelMatrix, g_materialBlockIndex, g_lights.GetTimerValue("tetra"));
                }
            }

            //Render the sun
            if (renderSun)
            {
                using ( PushStack pushstack = new PushStack(modelMatrix))
                {
                    Vector3 sunlightDir = new Vector3(g_lights.GetSunlightDirection());
                    modelMatrix.Translate(sunlightDir * 500.0f);
                    modelMatrix.Scale(30.0f, 30.0f, 30.0f);

                    GL.UseProgram(g_Unlit.theProgram);
                    Matrix4 mm = modelMatrix.Top();
                    GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm);

                    Vector4 lightColor = GammaCorrect(g_lights.GetSunlightIntensity(), gamma);
                    GL.Uniform4(g_Unlit.objectColorUnif, lightColor);
                    g_pScene.GetSphereMesh().Render("flat");
                }
            }

            //Render the lights
            if(g_bDrawLights)
            {
                for(int light = 0; light < g_lights.GetNumberOfPointLights(); light++)
                {
                    using (PushStack pushstack = new PushStack(modelMatrix))
                    {
                        modelMatrix.Translate(g_lights.GetWorldLightPosition(light));

                        GL.UseProgram(g_Unlit.theProgram);
                        Matrix4 mm = modelMatrix.Top();
                        GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm);

                        Vector4 lightColor = GammaCorrect(g_lights.GetPointLightIntensity(light), gamma);
                        GL.Uniform4(g_Unlit.objectColorUnif, lightColor);
                        g_pScene.GetCubeMesh().Render("flat");
                    }
                }
            }

            if(g_bDrawCameraPos)
            {
                using ( PushStack pushstack = new PushStack(modelMatrix))
                {
                    modelMatrix.SetIdentity();
                    modelMatrix.Translate(new Vector3(0.0f, 0.0f, -g_viewPole.GetView().radius));

                    GL.Disable(EnableCap.DepthTest);
                    GL.DepthMask(false);
                    GL.UseProgram(g_Unlit.theProgram);
                    Matrix4 mm = modelMatrix.Top();
                    GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm);
                    GL.Uniform4(g_Unlit.objectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f);
                    g_pScene.GetCubeMesh().Render("flat");
                    GL.DepthMask(true);
                    GL.Enable(EnableCap.DepthTest);
                    GL.Uniform4(g_Unlit.objectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f);
                    g_pScene.GetCubeMesh().Render("flat");
                }
            }
        }