...
void GLWidget :: initializeGL (void)
{
qDebug () << __FUNCTION__;
glClearColor (1.0, 1.0, 1.0, 0.0);
}
void GLWidget :: paintGL (void)
{
qDebug () << __FUNCTION__ << cyl_radius << cyl_height;
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (fabs (cyl_radius) < 0.1e-15 || fabs (cyl_height) < 0.1e-15)
return;
glBegin (GL_POLYGON);
glColor3d (1, 0, 0);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
GLUquadricObj* q = gluNewQuadric ();
gluCylinder (q, (GLdouble)cyl_radius, (GLdouble)cyl_radius, (GLdouble)cyl_height, 320, 320);
glEnd ();
glMatrixMode (GL_MODELVIEW);
gluDeleteQuadric (q);
}
void GLWidget :: resizeGL (int width, int height)
{
qDebug () << __FUNCTION__;
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glViewport ((GLsizei)width/2, (GLsizei)height/2, (GLsizei)width, (GLsizei)height);
glOrtho (0, this->QGLWidget::width (), 0, this->QGLWidget::height (), -1,1);
glMatrixMode (GL_MODELVIEW);
}
...
void GLWidget :: initializeGL (void)
{
qDebug () << __FUNCTION__;
glClearColor (1.0, 1.0, 1.0, 0.0);
}
void GLWidget :: paintGL (void)
{
qDebug () << __FUNCTION__ << cyl_radius << cyl_height;
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (fabs (cyl_radius) < 0.1e-15 || fabs (cyl_height) < 0.1e-15)
return;
glBegin (GL_POLYGON);
glColor3d (1, 0, 0);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
GLUquadricObj* q = gluNewQuadric ();
gluCylinder (q, (GLdouble)cyl_radius, (GLdouble)cyl_radius, (GLdouble)cyl_height, 320, 320);
glEnd ();
glMatrixMode (GL_MODELVIEW);
gluDeleteQuadric (q);
}
void GLWidget :: resizeGL (int width, int height)
{
qDebug () << __FUNCTION__;
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glViewport ((GLsizei)width/2, (GLsizei)height/2, (GLsizei)width, (GLsizei)height);
glOrtho (0, this->QGLWidget::width (), 0, this->QGLWidget::height (), -1,1);
glMatrixMode (GL_MODELVIEW);
}
To copy to clipboard, switch view to plain text mode
But except cylinder I receive sector of circle as presented in attachment.
Bookmarks