博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在此记录一下SharpGL最初创建的程序
阅读量:4486 次
发布时间:2019-06-08

本文共 4090 字,大约阅读时间需要 13 分钟。

在此记录一下SharpGL最初创建的程序。。

 

1 ///   2     /// The main form class.  3     ///   4     public partial class SharpGLForm : Form  5     {  6         ///   7         /// Initializes a new instance of the 
class. 8 ///
9 public SharpGLForm() 10 { 11 InitializeComponent(); 12 } 13 14 /// 15 /// Handles the OpenGLDraw event of the openGLControl control. 16 /// 17 /// The source of the event. 18 /// The
instance containing the event data. 19 private void openGLControl_OpenGLDraw(object sender, PaintEventArgs e) 20 { 21 // Get the OpenGL object. 22 OpenGL gl = openGLControl.OpenGL; 23 24 // Clear the color and depth buffer. 25 gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); 26 27 // Load the identity matrix. 28 gl.LoadIdentity(); 29 30 // Rotate around the Y axis. 31 gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); 32 33 // Draw a coloured pyramid. 34 gl.Begin(OpenGL.GL_TRIANGLES); 35 gl.Color(1.0f, 0.0f, 0.0f); 36 gl.Vertex(0.0f, 1.0f, 0.0f); 37 gl.Color(0.0f, 1.0f, 0.0f); 38 gl.Vertex(-1.0f, -1.0f, 1.0f); 39 gl.Color(0.0f, 0.0f, 1.0f); 40 gl.Vertex(1.0f, -1.0f, 1.0f); 41 gl.Color(1.0f, 0.0f, 0.0f); 42 gl.Vertex(0.0f, 1.0f, 0.0f); 43 gl.Color(0.0f, 0.0f, 1.0f); 44 gl.Vertex(1.0f, -1.0f, 1.0f); 45 gl.Color(0.0f, 1.0f, 0.0f); 46 gl.Vertex(1.0f, -1.0f, -1.0f); 47 gl.Color(1.0f, 0.0f, 0.0f); 48 gl.Vertex(0.0f, 1.0f, 0.0f); 49 gl.Color(0.0f, 1.0f, 0.0f); 50 gl.Vertex(1.0f, -1.0f, -1.0f); 51 gl.Color(0.0f, 0.0f, 1.0f); 52 gl.Vertex(-1.0f, -1.0f, -1.0f); 53 gl.Color(1.0f, 0.0f, 0.0f); 54 gl.Vertex(0.0f, 1.0f, 0.0f); 55 gl.Color(0.0f, 0.0f, 1.0f); 56 gl.Vertex(-1.0f, -1.0f, -1.0f); 57 gl.Color(0.0f, 1.0f, 0.0f); 58 gl.Vertex(-1.0f, -1.0f, 1.0f); 59 gl.End(); 60 61 // Nudge the rotation. 62 rotation += 3.0f; 63 } 64 65 66 67 /// 68 /// Handles the OpenGLInitialized event of the openGLControl control. 69 /// 70 /// The source of the event. 71 /// The
instance containing the event data. 72 private void openGLControl_OpenGLInitialized(object sender, EventArgs e) 73 { 74 // TODO: Initialise OpenGL here. 75 76 // Get the OpenGL object. 77 OpenGL gl = openGLControl.OpenGL; 78 79 // Set the clear color. 80 gl.ClearColor(0, 0, 0, 0); 81 } 82 83 /// 84 /// Handles the Resized event of the openGLControl control. 85 /// 86 /// The source of the event. 87 /// The
instance containing the event data. 88 private void openGLControl_Resized(object sender, EventArgs e) 89 { 90 // TODO: Set the projection matrix here. 91 92 // Get the OpenGL object. 93 OpenGL gl = openGLControl.OpenGL; 94 95 // Set the projection matrix. 96 gl.MatrixMode(OpenGL.GL_PROJECTION); 97 98 // Load the identity. 99 gl.LoadIdentity();100 101 // Create a perspective transformation.102 gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 100.0);103 104 // Use the 'look at' helper function to position and aim the camera.105 gl.LookAt(-5, 5, -5, 0, 0, 0, 0, 1, 0);106 107 // Set the modelview matrix.108 gl.MatrixMode(OpenGL.GL_MODELVIEW);109 }110 111 /// 112 /// The current rotation.113 /// 114 private float rotation = 0.0f;115 }

 

转载于:https://www.cnblogs.com/bitzhuwei/p/SharpGLCreateNewApp.html

你可能感兴趣的文章
模拟竖式除法
查看>>
java调用dll
查看>>
图形界面组件实验的一点总结
查看>>
django 1.11.16之环境搭建
查看>>
15.SpringMVC和Spring上下文关系(为什么SpringMVC可以调用到Spring)
查看>>
Syncfusion的社区许可及免费电子书和白皮书
查看>>
JAVA自学作业02
查看>>
蛇形矩阵
查看>>
活动选择
查看>>
7832:最接近的分数
查看>>
初识window phone 7程序
查看>>
思维导图
查看>>
XE6 c++builder Edit垂直居中
查看>>
leetCode 1. Two Sum
查看>>
CSAcademy Beta Round #5 Long Journey
查看>>
关于Java中volatile关键字笔记
查看>>
第四次作业
查看>>
Linux netstat常用命令
查看>>
实用的Portraiture滤镜磨皮教程
查看>>
关于minigui的皮肤控件无法显示问题
查看>>