Documente Academic
Documente Profesional
Documente Cultură
Figura 1. Scena deformata in urma redimensionarii (stanga), si rezolvarea acestei probleme (dreapta)
Solutia la aceasta problema consta in reapelarea functiei gluPerspective ori de cate ori se
doreste redimensionarea ferestrei de afisare.
Figura 2 ilustreaza spatiul vizual creat de catre functia gluPerspective.
Elaborat de: Conf. Dr. D.M.Popovici
Masterand M.Polceanu
http://www.cerva.ro
http://www.cerva.ro
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height,
2.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
static void
display(void)
{
static int frame,timebase=0;
int time;
char s[100];
frame++;
time=glutGet(GLUT_ELAPSED_TIME);
if (time - timebase > 1000)
{
sprintf(s,"[FPS:%4.2f]
Lab
3:
Calitatea
utilizatorului",frame*1000.0/(time-timebase));
glutSetWindowTitle(s);
Elaborat de: Conf. Dr. D.M.Popovici
Masterand M.Polceanu
experientei
http://www.cerva.ro
timebase = time;
frame = 0;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
static
static
static
static
float
float
float
float
axisRot = 0.0f;
globRotR = 0.0f;
globRotG = 120.0f;
globRotB = 240.0f;
glutSwapBuffers();
static void
idle(void)
{
glutPostRedisplay();
}
Elaborat de: Conf. Dr. D.M.Popovici
Masterand M.Polceanu
http://www.cerva.ro
return EXIT_SUCCESS;
http://www.cerva.ro
m->x += m->vx;
m->y += m->vy;
m->z += m->vz;
char
http://www.cerva.ro
glRasterPos2f(x,y);
char *c;
for (c=string; *c != '\0'; c++)
{
glutBitmapCharacter(font, *c);
}
glEnable(GL_LIGHTING);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
Obs: pentru ca textul sa fie vizibil in cadrul ferestrei, parametrii x si y trebuie sa fie in
intervalul [-1, 1].
In functia main, facem apel la procedura de redare a textului astfel:
char text[100];
sprintf(text,"axisRot: %4.2f",axisRot);
renderBitmapString(-0.99f, -0.91f, GLUT_BITMAP_9_BY_15, text);
sprintf(text,"globRotR: %4.2f",globRotR);
renderBitmapString(-0.99f, -0.98f, GLUT_BITMAP_9_BY_15, text);
http://www.cerva.ro
la
apasarea
unei
taste
sa
http://www.cerva.ro