void renderState_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { switch (e.PropertyName) { case "ProjectionMatrix": GL.MatrixMode(MatrixMode.Projection); Matrix4 projectionMatrix = renderState.ProjectionMatrix; GL.LoadMatrix(ref projectionMatrix); GL.UseProgram(pointShader.ShaderProgramHandle); pointShader.SetProjectionMatrix(projectionMatrix); pointShader.SetModelviewMatrix(Matrix4.Identity); GL.UseProgram(imageShader.ShaderProgramHandle); imageShader.SetProjectionMatrix(projectionMatrix); imageShader.SetModelviewMatrix(Matrix4.Identity); GL.UseProgram(lineShader.ShaderProgramHandle); lineShader.SetProjectionMatrix(projectionMatrix); lineShader.SetModelviewMatrix(Matrix4.Identity); GL.UseProgram(endPointShader.ShaderProgramHandle); endPointShader.SetProjectionMatrix(projectionMatrix); endPointShader.SetModelviewMatrix(Matrix4.Identity); break; case "ViewSize": SetViewport(renderState.ViewSize); break; default: break; } }
/// <summary> /// Event for setting several constants when OpenGL finishes loading /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void glControl_Load(object sender, EventArgs e) { loaded = true; GL.ClearColor(OpenTK.Graphics.Color4.Gray); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Texture2D); pointShader.CreateProgram(); imageShader.CreateProgram(); lineShader.CreateProgram(); endPointShader.CreateProgram(); diffuseShader.CreateProgram(); GL.UseProgram(diffuseShader.ShaderProgramHandle); diffuseShader.SetProjectionMatrix(Matrix4.Identity); diffuseShader.SetModelviewMatrix(Matrix4.Identity); GenerateFrameBuffer(); if (imageToLoad != null) { SetBitmap(imageToLoad); } imageToLoad = null; }