Ricardo Daniel González Gómez
Para poder ejecutar la rotación de las palabras, es necesario presionar la tecla
'm' : move
'r' : reset
Codigo
#include </usr/include/GL/glut.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define WIDTH 600
#define HEIGHT 600
#define PI 3.141592653
float r, g, b, ang = 0;
int px, py, alto = 600;
/*
*
*
*
*/
void drawText(char *str,float x,float y){
int i;
int len = strlen(str);
glColor3f(r, g, b);
glRasterPos2f( x, y);
for(i = 0; i < len; i++){
glutStrokeCharacter(GLUT_STROKE_ROMAN,str[i]);
}
}
void drawText1(char *str,float x,float y){
int i;
int len = strlen(str);
glColor3f(r, g, b);
glRasterPos2f( x, y);
for(i = 0; i < len; i++){
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, str[i]);
}
}
void init(){
glClearColor(1, 1, 1, 1.0);
gluOrtho2D(-10, 10, -10, 10);
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(0.001, 0.001, 1);
glRotatef(ang + 10, 0, 0, 1);
drawText1("Ricardo", 350, 0);
glRotatef(ang, 0, 0, 1);
drawText("Daniel", 100, 0);
glutSwapBuffers();
//glutPostRedisplay();
glFlush();
}
void key(unsigned char c, int x, int y)
{
switch(c){
case 27: //ESC
exit(0);
break;
case 'm'://Arriba
ang += 5;
break;
case 'r'://reset
ang = 0;
break;
}
display();
}
int main( int argc, char ** argv){
glutInit( &argc, argv);
glutInitDisplayMode( GLUT_DOUBLE| GLUT_RGB);
glutInitWindowPosition( 100, 100);
glutInitWindowSize(WIDTH, HEIGHT);
glutCreateWindow( "LetraS RotacionaleS.");
init();
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutMainLoop();
return 0;
}
Descargar fuente
No hay comentarios:
Publicar un comentario