lunes, 9 de abril de 2007

Previo Practica 5 glutBitmapCharacter Creacion del Nombre

#include GL/glut.h
#include stdlib.h
#include stdio.h
#include windows.h
#include math.h

void text(GLuint x, GLuint y, GLfloat scale, char* format);

GLint CrearFuente ();
void EscribirCadena (GLint fuente, char *cadena);
void aux(void);

void init(void)
{
glClearColor (0.0, 0.0, 1.0, 0.0);
glShadeModel (GL_FLAT);
}

void text(GLuint x, GLuint y, GLfloat scale, char* format) {
GLvoid *pix;
va_list args;
char buffer[255], *p;
GLfloat font_scale = 119.05f + 33.33f;
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
pix=NULL;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, glutGet(GLUT_WINDOW_WIDTH), 0,
glutGet(GLUT_WINDOW_HEIGHT));
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);

glRasterPos3f (90,180,0);
for(p = buffer; *p; p++){
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *p);
//

}

glRasterPos3f(500,0,0);
glReadPixels(85,165,150,50,GL_RGB,GL_BITMAP,pix);
glDrawPixels(150,50,GL_RGB,GL_BITMAP,pix);
//glColor3f(1.0,1.0,0.0);
//glBitmap (80,70,80, 180,10, 10,*p);
glPopAttrib();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
void aux(void){
GLvoid *pix;
pix=NULL;
glReadPixels(0,0,500,500,GL_RGB,GL_BITMAP,pix);
glRasterPos3f(0,250,0);
glColor3f(1.0,0.0,0.0);
glDrawPixels(500,500,GL_RGB,GL_BITMAP,pix);
}

void display(void)
{
GLint command = 1;
glClear (GL_COLOR_BUFFER_BIT);
//glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); /* clear the matrix */
/* viewing transformation */
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);


if (command) {
glColor3f(1.0,1.,0.0) ;
text(100,100, 80, "%s", "AIDE");
}
//aux();
glFlush ();
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
}

/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (0,0);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();

return 0;
}

No hay comentarios: