Created
August 17, 2014 01:00
-
-
Save djvs/507fbfc9ee03e6dc07c7 to your computer and use it in GitHub Desktop.
This file contains 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/glew.h> | |
#include <GL/glut.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <iostream> | |
using std::cout; | |
int test = 1; | |
bool* keyStates = new bool[256]; | |
void keydownOrdinary (unsigned char key, int x, int y) // pretty much useless, use glutSpecialFunc | |
{ | |
switch(key){ | |
case 27: | |
exit(0); | |
break; | |
case 'a': | |
printf("mhmaa"); | |
break; | |
default: | |
break; | |
} | |
} | |
void keyupOrdinary(unsigned char key, int x, int y){ | |
switch(key){ | |
default: | |
break; | |
} | |
} | |
void keydownSpecial(int key, int x, int y){ | |
switch(key){ | |
case GLUT_KEY_UP: | |
test++; | |
break; | |
case GLUT_KEY_DOWN: | |
test--; | |
printf("down pressed %i\n",test); | |
fflush(stdout); | |
break; | |
case GLUT_KEY_LEFT: | |
break; | |
case GLUT_KEY_RIGHT: | |
break; | |
default: | |
break; | |
} | |
glutPostRedisplay(); | |
} | |
void keyupSpecial(int key, int x, int y){ | |
switch(key){ | |
default: | |
break; | |
} | |
} | |
void reshape(int w, int h) | |
{ | |
glViewport(0,0, (GLsizei) w, (GLsizei) h); | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
} | |
void keyOperations(void){ | |
} | |
void display(void) | |
{ | |
keyOperations(); | |
glClearColor(1.0f,0.7f,0,0); | |
glClear(GL_COLOR_BUFFER_BIT); | |
glBegin(GL_TRIANGLES); | |
{ | |
glColor3f(1,0,0); | |
glVertex2f(0,0); | |
glColor3f(0,3,0); | |
glVertex2f(.5,0); | |
glColor3f(0,0,test); | |
glVertex2f(.2,.5); | |
} | |
glEnd(); | |
test++; | |
glutSwapBuffers(); | |
//fflush(stdout); // flush stdout buffer | |
} | |
int main(int argc, char** argv) { | |
glutInit(&argc, argv); | |
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); | |
glutInitWindowSize(512,512); | |
glutInitWindowPosition(30,30); | |
glutCreateWindow("hi :)"); | |
glutSetWindowTitle("hi :)"); | |
glutDisplayFunc(display); | |
glutReshapeFunc(reshape); | |
//keyboard funcs | |
glutKeyboardFunc(keydownOrdinary); | |
glutKeyboardUpFunc(keyupOrdinary); | |
glutSpecialFunc(keydownSpecial); | |
glutSpecialUpFunc(keyupSpecial); | |
glutMainLoop(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment