OpenGL问题
#include <windows.h>
#include <gl/glut.h>
#include <gl/gl.h>
#include <gl/glu.h>
void RenderSence1(void) //第一个三角形
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 0.0f, 1.0f);
glLineWidth(6.0);
glBegin(GL_TRIANGLES);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(50.0, 0.0, 0.0);
glVertex3f(0.0, 50.0, 0.0);
glEnd();
glFlush();
}
void RenderSence2(void) //第二个三角形
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 0.0f);
glLineWidth(6.0);
glBegin(GL_TRIANGLES);
glVertex3f(100.0f, 100.0f, 0.0f);
glVertex3f(150.0f, 100.0f, 0.0f);
glVertex3f(100.0f, 150.0f, 0.0f);
glEnd();
glFlush();
}
void ChangeSize(GLsizei w,GLsizei h)
{
if(h==0) h=1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(0.0f,250.0f,0.0f,250.0f*h/w,1.0f,-1.0f);
else
glOrtho(0.0f,250.0f*w/w,0.0f,250.0f,1.0f,-1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void main(void)
{
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutCreateWindow("GLRect");
glutDisplayFunc(RenderSence1); //第一个三角形
glutDisplayFunc(RenderSence2); //第二个三角形 问题:为什么只显示第二个三角形,我想保留第一次画的?
glutReshapeFunc(ChangeSize);
glutMainLoop();
}
我想保留第一次画的,同时显示两次画的三角形,该怎么做?
补充:.NET技术 , C#