/ / previo6 write my name on the screen bitmap, and when you press the left button increases the font size and the right button decreases it / / Christian Durán Jorge Lara
# include <=0){
<-1){
# include void name (int x, int y, char * myname); void init (void); void display (void);
void reshape (int w, int h); void mouse ( int button, int state, int x, int y);
float zoom =- 3.5; void init (void) {
glClearColor (0.0, 0.0, 1.0, 0.0); glShadeModel (GL_FLAT);}
void display (void) {
glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 1.0, 0.0);
glLoadIdentity (); gluLookAt (0.0,0.0,5.0,0.0, 0.0, 0.0, 0.0, 1.0, 0.0 )
name (zoom, 3, 'Jorge Christian Duran Lara"); glFlush ();
}
void reshape (int w, int h) {
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION); glLoadIdentity (); <-1){ glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW); }
void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON)
{ if(state == GLUT_DOWN) {
zoom=zoom+1; display(); }
//else if (state == GLUT_UP) {} } else if (button == GLUT_RIGHT_BUTTON)
{ if(state == GLUT_DOWN) {
zoom=zoom-1; display(); }
//else if (state == GLUT_UP) {} } }
int main(int argc, char** argv)
{ glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE
/ / glutKeyboardFunc (keyboard); / / glutSpecialFunc (arrow_keys) glutMainLoop ();
return 0;}
void name (int x, int y, char * myname) glColor3f (1,1,0);
glRasterPos2f (x, y);
for (i = 0; myname [i]; i + +)
glutBitmapCharacter (GLUT_BITMAP_TIMES_ROMAN_24, myname [i]);}
/ / previo6_ 2 write my name on the screen with stroke, and when you press the left button increases the font size and the right button decreases it
/ / Christian Durán Jorge Lara
#include
#include
void mouse(int button, int state, int x, int y);
void *font = GLUT_STROKE_ROMAN;
void *fonts[] = {GLUT_STROKE_ROMAN, GLUT_STROKE_MONO_ROMAN};
char defaultMessage[] = "Jorge Christian Duran Lara";
char *message = defaultMessage;
int zoom=1000;
void display(void)
{
int len, i;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 0.0);
glLoadIdentity ();
//gluLookAt (0.0,0.0,1.0,0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glTranslatef(zoom, 1000, 0);
glPushMatrix();
glTranslatef(-750, 0, 0);
len = (int) strlen(message);
for (i = 0; i
{
glutStrokeCharacter(font, message[i]);
}
glPopMatrix();
glutSwapBuffers();
}
void mouse(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON)
{
if(state == GLUT_DOWN)
{
zoom=zoom+10;
display();
}
//else if (state == GLUT_UP) {}
}
else if (button == GLUT_RIGHT_BUTTON)
{
if (state == GLUT_DOWN)
{zoom = zoom-10;
display ();
} / / else if (state == GLUT_UP) {}}
} int main (int argc, char ** argv) {
glutInit (& argc, argv);
glutInitDisplayMode (GLUT_DOUBLE
stroke glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) / / for stroke
glLineWidth (2.0), / / \u200b\u200bfor glClearColor
stroke (0.0, 0.0, 1.0, 1.0), / / \u200b\u200bbackground color
glutDisplayFunc (display);
glutMouseFunc (mouse )
glutMainLoop ();
return 0;}
/ / previo6_ 3 is a timer, and when you press the left button is for the clock and with the right button is initialized
/ / Christian Durán Jorge Lara
# include # include
void timer (int value);
void name (int x, int y, char * myname);
void init (void);
void display(void);
void reshape (int w, int h);
void mouse(int button, int state, int x, int y);
#define TRUE 1
char reloj[9];
void init(void)
{
glClearColor (0.0, 0.0, 1.0, 0.0);
glShadeModel (GL_FLAT);
}
void display(void)
{
int i;
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 0.0);
glLoadIdentity ();
gluLookAt (0.0,0.0,5.0,0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
if (seconds
{if (minutes
{if (hours
< len; i++)
{sprintf (clock, "0% d: 0% d: 0% d", hours, minutes, seconds);
} else {
sprintf (clock, "% d: 0% d: 0% d", hours, minutes, seconds);
}} {
else if (hours
{sprintf (clock, "0% d:% d : 0% d ", hours, minutes, seconds);
} else {
sprintf (clock,"% d:% d: 0% d ", hours, minutes, seconds);
}}}
{
else if (minutes
{if (hours
{sprintf (clock, "0% d: 0% d:% d", hours, minutes, seconds);}
else {sprintf (clock, "% d: 0% d:% d", hours, minutes, seconds);
}} {
else if (hours
{sprintf (clock, "0% d :% d:% d ", hours, minutes, seconds);
} {else
sprintf (clock, "% d:% d:% d", hours, minutes, seconds);
}}}
name (-3.5,3, clock);
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);
} void mouse (int button, int state, int x, int y) {
if (button == GLUT_LEFT_BUTTON)
{if ( state == GLUT_DOWN)
{
//zoom=zoom+1;
segundos=0;
minutos=0;
horas=0;
display();
}
//else if (state == GLUT_UP) {}
}
else if (button == GLUT_RIGHT_BUTTON)
{
if(state == GLUT_DOWN)
{
//zoom=zoom-1;
if (reloj_activado==TRUE)
reloj_activado=FALSE;
else if (reloj_activado==FALSE)
reloj_activado=TRUE;
glutTimerFunc(1000,timer,1);
//timer(1);
} / / else if (state == GLUT_UP) {}}
} void timer (int value) {<10)
/ / printf ("% d", value); <10)
seconds + +;
if (seconds == 60) <10)
{
minutes + +;
seconds = 0;
if (minutes == 60)
{
hours + +;
minutes = 0;
if (hours == 24)
{
hours = 0;
} <10)
}
} display ();
if (reloj_activado == TRUE)
glutTimerFunc (1000, timer, 1);}
int main (int argc, char ** argv) {
glutInit (& argc, argv);
glutInitDisplayMode (GLUT_SINGLE
<10)
{int i;
<10)
glColor3f (1,1,0);
glRasterPos2f (x, y);
for (i = 0; myname [i]; i + +)
glutBitmapCharacter (GLUT_BITMAP_TIMES_ROMAN_24, myname [i]);
}
0 comments:
Post a Comment