public override void reshape() { MatrixStack persMatrix = new MatrixStack(); persMatrix.Perspective(45.0f, (width / (float)height), g_fzNear, g_fzFar); projData.cameraToClipMatrix = persMatrix.Top(); MatrixStack camMatrix = new MatrixStack(); camMatrix.SetMatrix(Camera.GetLookAtMatrix()); GL.Viewport(0, 0, width, height); }
public override void reshape() { MatrixStack persMatrix = new MatrixStack(); persMatrix.Perspective(perspectiveAngle, (width / (float) height), g_fzNear, g_fzFar); cameraToClipMatrix = persMatrix.Top(); SetGlobalMatrices(); GL.Viewport(0, 0, width, height); }
//Called whenever the window is resized. The new window size is given, in pixels. //This is an opportunity to call glViewport or glScissor to keep up with the change in size. public override void reshape() { MatrixStack camMatrix = new MatrixStack(); camMatrix.SetMatrix(Camera.GetLookAtMatrix()); cm = camMatrix.Top(); MatrixStack persMatrix = new MatrixStack(); persMatrix.Perspective(perspectiveAngle, (width / (float)height), g_fzNear, g_fzFar); pm = persMatrix.Top(); SetGlobalMatrices(currentProgram); GL.Viewport(0, 0, width, height); }
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 reshape() { MatrixStack persMatrix = new MatrixStack(); persMatrix.Perspective(45.0f, (width / (float)height), g_fzNear, g_fzFar); ProjectionBlock projData = new ProjectionBlock(); projData.cameraToClipMatrix = persMatrix.Top(); Matrix4 cm = projData.cameraToClipMatrix; GL.UseProgram(g_litShaderProg.theProgram); GL.UniformMatrix4(g_litShaderProg.cameraToClipMatrixUnif, false, ref cm); GL.UseProgram(0); GL.UseProgram(g_litTextureProg.theProgram); GL.UniformMatrix4(g_litTextureProg.cameraToClipMatrixUnif, false, ref cm); GL.UseProgram(0); GL.UseProgram(g_Unlit.theProgram); GL.UniformMatrix4(g_Unlit.cameraToClipMatrixUnif, false, ref cm); GL.UseProgram(0); GL.Viewport(0, 0, width, height); }
public override void reshape() { MatrixStack persMatrix = new MatrixStack(); persMatrix.Perspective(45.0f, (width / (float)height), g_fzNear, g_fzFar); // added persMatrix.Translate(-0.5f, 0.0f, -3f); persMatrix.Scale(0.01f); // end added ProjectionBlock projData = new ProjectionBlock(); projData.cameraToClipMatrix = persMatrix.Top(); foreach(SceneProgramData spd in g_Programs) { GL.UseProgram(spd.theProgram); GL.UniformMatrix4(spd.cameraToClipMatrixUnif, false, ref projData.cameraToClipMatrix); GL.UseProgram(0); } GL.UseProgram(g_Unlit.theProgram); GL.UniformMatrix4(g_Unlit.cameraToClipMatrixUnif, false, ref projData.cameraToClipMatrix); GL.UseProgram(0); GL.Viewport(0, 0, width, height); }
public override void reshape() { MatrixStack persMatrix = new MatrixStack(); persMatrix.Perspective(90.0f, (width / (float)height), g_fzNear, g_fzFar); ProjectionBlock projData = new ProjectionBlock(); projData.cameraToClipMatrix = persMatrix.Top(); GL.UseProgram(Programs.GetProgram(manyImageProgram)); GL.UniformMatrix4(Programs.GetCameraToClipMatrixUniform(manyImageProgram), false, ref projData.cameraToClipMatrix); GL.UseProgram(0); GL.Viewport(0, 0, width, height); }
//Called whenever the window is resized. The new window size is given, in pixels. //This is an opportunity to call glViewport or glScissor to keep up with the change in size. public override void reshape() { MatrixStack camMatrix = new MatrixStack(); camMatrix.SetMatrix(Camera.GetLookAtMatrix()); cm = camMatrix.Top(); MatrixStack persMatrix = new MatrixStack(); persMatrix.Perspective(45.0f, (width / (float)height), g_fzNear, g_fzFar); pm = persMatrix.Top(); SetGlobalMatrices(UniformColor); SetGlobalMatrices(ObjectColor); SetGlobalMatrices(UniformColorTint); GL.Viewport(0, 0, width, height); }