void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e) { var arg = new RenderEventArgs(RenderModes.Render, this.camera); mat4 projectionMatrix = camera.GetProjectionMat4(); mat4 viewMatrix = camera.GetViewMat4(); //mat4 modelMatrix = glm.rotate(rotateAngle, new vec3(0, 1, 0)); //modelRotationCamera.GetViewMat4(); //mat4.identity(); //rotateAngle += 0.03f; //mat4 modelMatrix = this.modelRotator.GetModelRotation();//glm.rotate(rotateAngle, new vec3(0, 1, 0)); //modelRotationCamera.GetViewMat4(); //mat4.identity(); mat4 modelMatrix = this.modelRotator.GetRotationMatrix(); this.renderer.projectionMatrix = projectionMatrix; this.renderer.viewMatrix = viewMatrix; this.renderer.modelMatrix = modelMatrix; GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); this.uiAxis.Render(arg); if (this.newRenderer != null) { this.renderer = newRenderer; this.frmController.Close(); this.frmController = new FormPhongPointLightController(this.renderer); this.frmController.Show(); this.frmDisplay.Close(); this.frmDisplay = new FormPhongPointLightDisplay(this.renderer); this.frmDisplay.Show(); this.newRenderer = null; } this.renderer.Render(arg); }
private void FormGLCanvas_Load(object sender, EventArgs e) { GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f); glCanvas1_Resize(this.glCanvas1, e); this.frmController = new FormPhongPointLightController(this.renderer); frmController.Show(); this.frmDisplay = new FormPhongPointLightDisplay(this.renderer); this.frmDisplay.Show(); StringBuilder builder = new StringBuilder(); builder.AppendLine("This is a diffuse reflection demo with point light and ambient light."); builder.AppendLine("Use 'm' to change model."); builder.AppendLine("Use 'c' to switch camera types between perspective and ortho."); builder.AppendLine("Use right mouse to rotate camera."); builder.AppendLine("Use left mouse to rotate model."); builder.AppendLine("Use 'j' to decrease vertex count."); builder.AppendLine("Use 'k' to increase vertex count."); MessageBox.Show(builder.ToString()); }