Created
March 5, 2013 15:40
-
-
Save thuandt/5091172 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GL/gl.h> | |
#include <GL/glut.h> | |
GLubyte rasters[24] = { 0x00, 0x00, | |
0x06, 0x00, | |
0x06, 0x00, | |
0x06, 0x00, | |
0x06, 0x00, | |
0x06, 0x00, | |
0x06, 0x00, | |
0x06, 0x00, | |
0x06, 0x00, | |
0x3f, 0xc0, | |
0x3f, 0xc0 }; | |
void init(void) | |
{ | |
glPixelStorei (GL_UNPACK_ALIGNMENT, 1); | |
glClearColor (0.0, 0.0, 0.0, 0.0); | |
} | |
void display(void) | |
{ | |
glClear(GL_COLOR_BUFFER_BIT); | |
glColor3f (0, 1.0, 0); | |
glRasterPos2i (20, 20); | |
glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); | |
glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); | |
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); | |
} | |
/* ARGSUSED1 */ | |
void keyboard(unsigned char key, int x, int y) | |
{ | |
switch (key) { | |
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(180, 50); | |
glutInitWindowPosition(100, 100); | |
glutCreateWindow(argv[0]); | |
init(); | |
glutReshapeFunc(reshape); | |
glutKeyboardFunc(keyboard); | |
glutDisplayFunc(display); | |
glutMainLoop(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment