View Full Version : problems with a custom function
10-06-2008, 03:39 PM
I want to draw a sphere using a custom sphere() fn.When Im using the function in display() function.Its working.When i use it in the main() its not working??Please some one help me.Even though when im using glutPostRedisplay().The function sphere() is not working when written in main().
10-06-2008, 05:47 PM
When you call the sphere function, you must have a valid GL context otherwise drawing call have no effect. Your problem remind me that I had experienced the same kind of trouble. I was using Qt for a project and drawing call was only effective inside the paintGL function. So drawing call made inside mouse and keyboard function had no effect at all even if I called updateGL. So I used a singleton class that permit me to add new drawing object (singleton->addPrimitive(...)) in user input function. Inside my paintGL function I simply call singleton->draw().
So my advice here is to make only OpenGL drawing call inside the function defined by glutDisplayFunc(). I don't know if glut documentation forbid explicitly drawing call outside the function defined by glutDisplayFunc() but it seem wise to do so.
10-06-2008, 05:55 PM
Thank you Now its working.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.