The following function draws a solid sphere in OpenGL without glut.
It creates a line loop at line 3. It crates a quadratic object after that (line 4) and sets drawing mode to fill the gaps (line 4). It draws a sphere using the previously created quadratic object passing the parameters to the function (line 7). Finally it deletes the quadratic object (line 9). The result is same as calling glutSolidSphere() with the same arguments.1: void solidSphere(GLdouble radius, GLint slices, GLint stacks)
2: {3: glBegin(GL_LINE_LOOP);4: GLUquadricObj* quadric = gluNewQuadric();5:6: gluQuadricDrawStyle(quadric, GLU_FILL);7: gluSphere(quadric, radius, slices, stacks);8:9: gluDeleteQuadric(quadric);10: glEnd();11:12: }
Nice, thanks!
ReplyDeleteActually, There is a problem here...
ReplyDeleteNot all operations are allowed inside of a glBegin/glEnd code.
When I was trying to run your code with opengl + python. I got this message:
invalid operation glEnd 1282
Take those begin,end tags out... and It works perfectly,
thanks for your code, I hope what I said can help anyone with this problem,
thanks