UID:183430
TargetChartView3D::TargetChartView3D(QWidget* parent) : QGLWidget(parent){ QVector3D pos(0.0, 0.0, 12.0); QVector3D target(0.0, 0.0, 0.0); QVector3D up(0.0, 1.0, 0.0); setCamera(pos, target, up);}//TargetChartView3D::~TargetChartView3D()//{//}void TargetChartView3D::initializeGL(){ glShadeModel(GL_SMOOTH);//设置阴影平滑模式 glClearColor(1.0, 1.0, 1.0, 1.0);//改变窗口的背景颜色 glClearDepth(1.0);//设置深度缓存 glEnable(GL_DEPTH_TEST);//允许深度测试 glDepthFunc(GL_LEQUAL);//设置深度测试类型 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); slide(-0.50, 1.40, 0.50);}void TargetChartView3D::paintGL(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); setModelViewMatrix(); GLDrawCubeCoordinates(); GLDrawSpaceAxes(); updateGL();}void TargetChartView3D::paintEvent(QPaintEvent *event){ update();}void TargetChartView3D::resizeGL(int width, int height){ if (height == 0) { height = 1; } glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, (GLfloat)width / (GLfloat)height, 0.1, 100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); updateGL();}
UID:129101