首页 > 其他 > 详细

CsGL着色的三角形

时间:2017-06-14 01:46:53      阅读:364      评论:0      收藏:0      [点我收藏+]

转自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着色的三角形

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!