码迷,mamicode.com
首页 > 其他好文 > 详细

CsGL着色的三角形

时间:2017-06-14 02:30:55      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:eset   ext   div   bit   ring   code   load   三角形   com   

转自NeHe教程

技术分享

 

public override void Draw() {                                                    // Here‘s Where We Do All The Drawing
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);                            // Clear Screen And Depth Buffer
            glLoadIdentity();                                                            // Reset The Current Modelview Matrix

            glTranslatef(0.0f, 0.0f, -6.0f);                                            // Move Into The Screen 6.0

            glRotatef(angle, 0.0f, 1.0f, 0.0f);                                            // Rotate The Triangle On The Y Axis By angle
            for(rot1 = 0; rot1 < 2; rot1++) {                                            // 2 Passes For Two Sets Of Triangles
                glRotatef( 90.0f, 0.0f, 1.0f, 0.0f);                                    // Rotate 90 Degrees On The Y-Axis
                glRotatef(180.0f, 1.0f, 0.0f, 0.0f);                                    // Rotate 180 Degress On The X-Axis
                for(rot2 = 0; rot2 < 2; rot2++) {                                        // 2 Passes For Each Of The Sets, Draw Two Triangles
                    glRotatef(180.0f, 0.0f, 1.0f, 0.0f);                                // Rotate 180 Degrees On The Y-Axis
                    glBegin(GL_TRIANGLES);                                                // Begin Drawing Triangles
                    glColor3f(1.0f, 0.0f, 0.0f);  glVertex3f( 0.0f,  1.0f, 0.0f);        // Draw The Red Vertex
                    glColor3f(0.0f, 1.0f, 0.0f);  glVertex3f(-1.0f, -1.0f, 1.0f);        // Draw The Green Vertex
                    glColor3f(0.0f, 0.0f, 1.0f);  glVertex3f( 1.0f, -1.0f, 1.0f);        // Draw The Blue Vertex
                    glEnd ();                                                            // Done Drawing Triangles
                }
            }

            angle += 0.2f;                                                                // Update angle
            glFlush();                                                                    // Flush The GL Rendering Pipeline
        }

 

CsGL着色的三角形

标签:eset   ext   div   bit   ring   code   load   三角形   com   

原文地址:http://www.cnblogs.com/arxive/p/7004500.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!