drawing in another function
i have used glut for everything up until very recently and this has been bothering me. In carbon i do all of my drawing from the event loop function thing (sorry about not knowing the "correct terminology") and it works, but if i want to use that to call a bunch of things that do a lot of things its doesnt make sense to also draw form there. but if i call another function to do the drawing (from that event loop function thing) everything stops. i put a printf if the drawing function to make sure i was right and sure enough. it didn't do anything while the app was running. but when i quit it threw out everything.
so what i am wondering is: what is the agl equivilent to glutPostRedisplay() because that always did it for me. i did try aglPostRedisplay() but... yea.
also if anyone could throw a quick explanation of how to do double buffering in agl that would be cool
so what i am wondering is: what is the agl equivilent to glutPostRedisplay() because that always did it for me. i did try aglPostRedisplay() but... yea.
also if anyone could throw a quick explanation of how to do double buffering in agl that would be cool
laziness,impatience, and hubris
For your first problem: set up a timer, do your drawing in the timer callback.
To do double-buffering: add AGL_DOUBLEBUFFER to your pixel format attribute list, and remember to call aglSwapBuffers().
To do double-buffering: add AGL_DOUBLEBUFFER to your pixel format attribute list, and remember to call aglSwapBuffers().
i did setup a timer (i am using the neheX tutorials so they did)
InstallEventLoopTimer(GetMainEventLoop(), kEventDurationSecond * 0, kEventDurationSecond / kFramesPerSec, NewEventLoopTimerUPP(TheLoop), NULL, &theEventLoopTimerRef);
but then i created a class to handle each of my characters (its a game about seagulls its gonna be sweet)
void Gull::Draw_Bird(ModelType model)
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glTranslatef(0.0f,0.0f,-50.0f);
glRotatef(180.0f,1.0f,0.0f,0.0f);
model.Draw();
glPopMatrix();
}
i am using karl berg's obj loader for the actual drawing by the way
so then to call it i go
seagull.Draw_Bird(model);
from TheLoop() which was the event timer i installed above
but it never comes out so if i make a change which i did earlier it never gets updated i had a pretty good handle when i was doing c & glut but i really think c++ & agl is the way to go i just need a little help gettin there
sorry for the lack of organization hopefully you can understand that
InstallEventLoopTimer(GetMainEventLoop(), kEventDurationSecond * 0, kEventDurationSecond / kFramesPerSec, NewEventLoopTimerUPP(TheLoop), NULL, &theEventLoopTimerRef);
but then i created a class to handle each of my characters (its a game about seagulls its gonna be sweet)
void Gull::Draw_Bird(ModelType model)
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glTranslatef(0.0f,0.0f,-50.0f);
glRotatef(180.0f,1.0f,0.0f,0.0f);
model.Draw();
glPopMatrix();
}
i am using karl berg's obj loader for the actual drawing by the way
so then to call it i go
seagull.Draw_Bird(model);
from TheLoop() which was the event timer i installed above
but it never comes out so if i make a change which i did earlier it never gets updated i had a pretty good handle when i was doing c & glut but i really think c++ & agl is the way to go i just need a little help gettin there
sorry for the lack of organization hopefully you can understand that
laziness,impatience, and hubris
What you want to do here is do all your GL setup once. So your draw function should look more like this:
and then in your gull draw routine you would have
Also, what you are seeing with the printf is simply all your text going into a buffer.
Put:
fflush(stdout);
after every call to printf, and you should be ok... You'll actually find that your function was running as you wanted it to.
Code:
void Draw()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
seagull.Draw(model);
glPopMatrix();
glPushMatrix();
//Draw something else...
glPopMatrix();
aglSwapBuffers(); // or glFlush();, for not double buffered
}and then in your gull draw routine you would have
Code:
void Gull:: Draw_Bird(ModelType model)
{
glTranslatef(0.0f, 0.0f, -50.0f);
glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
model.Draw();
}Also, what you are seeing with the printf is simply all your text going into a buffer.
Put:
fflush(stdout);
after every call to printf, and you should be ok... You'll actually find that your function was running as you wanted it to.
its working now thanks to both of you.
laziness,impatience, and hubris

