#include "stdafx.h" GLubyte rastersF[24] = { 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0xc0, 0xff, 0xc0}; GLubyte rastersI[24] = { 0x3f, 0x00, 0x1e, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x1e, 0x00, 0x3f, 0x00}; GLdouble color_de_F[3]={.0, .75, .75}, color_de_I[3]={1.0, 0.0, 0.0}, *col=NULL; GLint xrp0, yrp0, width=700, height=300; GLubyte *rasters; void init(void) { glClear(GL_COLOR_BUFFER_BIT); rasters=NULL; xrp0=20; yrp0=height-30; glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glClearColor (0.0, 0.0, 0.0, 0.0); } void display(void) { if(col!=NULL) glColor3dv (col); //<-- el orden en que aparecen estas dos glRasterPos2i (xrp0, yrp0); // llamadas es importante if(rasters!=NULL) glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); glFlush(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho (0, w, 0, h, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 'f': case 'F':{ col=color_de_F; if(xrp030){ xrp0=20; yrp0-=20; //<-- cambiar fila } else{//<-- limpiar pantalla y empezar desde inicio xrp0=20; yrp0=height-30; glClear(GL_COLOR_BUFFER_BIT); } } rasters=rastersF; glutPostRedisplay(); break; } case 'i': case 'I':{ col=color_de_I; if(xrp030){ xrp0=20; yrp0-=20; //<-- cambiar fila } else{//<-- limpiar pantalla y empezar desde inicio xrp0=20; yrp0=height-30; glClear(GL_COLOR_BUFFER_BIT); } } rasters=rastersI; glutPostRedisplay(); break; } case 27: exit(0); } } /* Main Loop * Open window with initial window size, title bar, * RGBA display mode, and handle input events. */ int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(width, 300); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutDisplayFunc(display); glutMainLoop(); return 0; }