16,211
社区成员
发帖
与我相关
我的任务
分享
void WidgetCylinder::initializeGL()
{
//初始化相机
Vector3d pos(0.0, 0.0, 12.0);
Vector3d target(0.0, 0.0, 0.0);
Vector3d up(0.0, 1.0, 0.0);
camera = new GLCamera(pos, target, up);
}
void WidgetCylinder::resizeGL(int width, int height)
{
//防止窗口大小为0
if(height == 0)
{
height = 1;
}
glViewport(0,0,(GLint)width,(GLint)height);
camera->setShape(40.0, (GLfloat)width/(GLfloat)height, 0.1, 100.0);
//选择模型观察矩阵
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void WidgetCylinder::paintGL()
{
//清除屏幕和深度缓存
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
camera->setModelViewMatrix();
//移动到屏幕背后足够距离以便能看到全部场景
glTranslatef(0.0f, 0.0f, -10.0f-40);
DrawSolidCylinder(cylinderTissuecenterPos[0],cylinderTissuecenterPos[1],cylinderTissuecenterPos[2],cylinderTissueAxisLength[0],cylinderTissueAxisLength[1],cylinderTissueAxisLength[2],
26);
}