freeglut ERROR: Function <glutBitmapCharacter> called without first
calling 'glutInit'.
the thing of concern is that the same code runs fine on one system
with RHEL4 and on the other with RHEL4 the same error comes...
on ubuntu at home i too get the same error...
the much more amazing thing is that when this code runs fine on a
system,
the output at terminal is::
HIHIHIHIHIHI
pID zero 0
pID not zero 15640
which means the control goes in both parts,the if part and the else
part....How can this be possible???
Secondly,on systems on which this code doesnt run,if i comment out all
the lines that use the glutBitmapCharacter function....the code runs
fine on them aswell but this isnt a solution at all...because the
"glutinit not called first" error should come here aswell as other
glut functions are being still used(if the compiler is fair
enough)...and as one can see the glutInit function is being called at
the right place in the main function..
Does anyone have any clue about this??
Help is appreciated.
Thanks,
Regards.
here is the main() code:::
##########################################
int main (int argc, char** argv)
{
cout<<"\n\nHIHIHIHIHIHI\n\n";
int stat=0;
int b;
pid_t pID;
pID = fork();
if(pID==0){
printf("pID zero %d\n",pID);
execl("/bin/sh","/bin/sh","-c","./noutput",0);
#ifdef __abc__
execl("/usr/bin/bash","/usr/bin/bash","-c","./noutput",0);
#else
execl("/bin/bash","/bin/bash","-c","./noutput",0);
#endif
}
else if(pID>0){
printf("pID not zero %d\n",pID);
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(1600,1200);
glutInitWindowPosition(0,0);
glutCreateWindow();
init();
createMenu();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(display);
glutKeyboardFunc(sampleKeyFunc);
glutMouseFunc(mouseClick);
glutMotionFunc(mouseMoveActive);
glutPassiveMotionFunc(mouseMovePassive);
glutMainLoop();
}
else
printf("error in child process");
return 0;
}
##########################################
Well, you did call "fork()".
http://www.opengroup.org/onlinepubs/000095399/functions/fork.html
Note "The child process shall have a unique process ID".
--
Dave Eberly
http://www.geometrictools.com
Are you sure you know what this does...?
--
<\___/>
/ O O \
\_____/ FTB. Remove my socks for email address.
yes...rightly said it has to go in both the if and the else part...
but any clue about the error thats coming when executable is run.....
and when run....no printfs are shown only runtime error as:
freeglut ERROR: Function <glutBitmapCharacter> called without first
So dows this mean that the control isnt going to main() even??
then how come at runtime it comes to know that glutBitmapCharacter is
being called without glutInit()..which is not actually right as it is
being called.. and all the rendering is done only after the glutInit
and glut modes..etc are set....
from where is this error coming...
every other program in opengl is running fine though..
thanks.
Somewhere deep in the system.
What happens if you swap the sense of the fork around
(ie. do the GLUT stuff in the pid==0 branch).
Have you tried running through a debugger and setting breakpoints at
the call to glutInit and at the call to glutBitmapCharacter? Given that
you are forking the process, there might be a sequencing issue.
Why are you doing that? If the user wants the program to not to
block the shell, he will start it in background (append a '&')
after the command line.
If you're anxious that the user might kill the shell or close the
terminal, but you want the program not to be terminated, supply
a signal handler for SIGHUP. Or start the programm
through "nohup".
Wolfgang Draxinger
--
E-Mail address works, Jabber: hexa...@jabber.org, ICQ: 134682867
Well....I have sorted the problem that I posted here.....
In my program,I was creating a global object whose constructor was
calling a function that was calling in turn the glutBitmapCharacter
function.
when i commented out that function call from the constructor...all
went well and fine...
Maybe this solution can prove helpful to others...
Thanks to all,for giving inputs..
Bye.