102 lines
2.2 KiB
C
102 lines
2.2 KiB
C
|
|
#include <stdlib.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
#include <GLES2/gl2.h>
|
||
|
|
|
||
|
|
#include <glut.h>
|
||
|
|
#include <glut_extensions.h>
|
||
|
|
|
||
|
|
const int TARGET_FPS = 15;
|
||
|
|
static int ONE_TICK_MS = 1000 / TARGET_FPS;
|
||
|
|
|
||
|
|
float viewSize = 2.0f;
|
||
|
|
float aspect_ratio;
|
||
|
|
int steps = 60;
|
||
|
|
|
||
|
|
/* don't want to implement */
|
||
|
|
/* also removed
|
||
|
|
glEnable(GL_ALPHA_TEST);
|
||
|
|
glDisable(GL_ALPHA_TEST);
|
||
|
|
*/
|
||
|
|
GLuint GLUT_COMPATIBILITY_PROFILE = 0 ;
|
||
|
|
GLuint GLUT_SINGLE = 0 ;
|
||
|
|
GLuint GLUT_RGBA = 0 ;
|
||
|
|
const GLuint GLUT_SCREEN_WIDTH = 0;
|
||
|
|
const GLuint GLUT_SCREEN_HEIGHT = 1;
|
||
|
|
|
||
|
|
void glutInitContextVersion( int maj, int min){}
|
||
|
|
void glutInitContextProfile( GLuint profile){}
|
||
|
|
void glutInitDisplayMode( GLuint OR_ed_FLAGS){}
|
||
|
|
|
||
|
|
int glutGet(GLuint dimension){
|
||
|
|
switch( dimension) {
|
||
|
|
case 0 :
|
||
|
|
return 1920;
|
||
|
|
break;
|
||
|
|
case 1 :
|
||
|
|
return 1152;
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
exit(1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//funky stuff ahead
|
||
|
|
void renderLoop() {
|
||
|
|
|
||
|
|
glClearColor( 0.0f, 1.0f, 0.0f, 1.0f);
|
||
|
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||
|
|
|
||
|
|
glutSwapBuffers();
|
||
|
|
}
|
||
|
|
|
||
|
|
void timer(int value) {
|
||
|
|
printf("crashes here\n");
|
||
|
|
uint8_t touch_count;
|
||
|
|
touch_event **touch_buffer;
|
||
|
|
glutGetTouchProxy().get_tracked_events( &touch_buffer, &touch_count);
|
||
|
|
printf("%d touch_events\n", touch_count);
|
||
|
|
if( touch_count)
|
||
|
|
free_touch_events_array( touch_buffer, touch_count);
|
||
|
|
|
||
|
|
/*would have handled animations*/
|
||
|
|
glutTimerFunc(ONE_TICK_MS, timer, 0);
|
||
|
|
glutPostRedisplay();
|
||
|
|
}
|
||
|
|
|
||
|
|
void keypressed(unsigned char key, int x, int y) {
|
||
|
|
printf("pressed key %d\n", key);
|
||
|
|
}
|
||
|
|
|
||
|
|
void mousemoved(int x, int y) {
|
||
|
|
//camera.mouseMotion(x, y);
|
||
|
|
}
|
||
|
|
|
||
|
|
int main(int argc, char* argv[]) {
|
||
|
|
printf("i'm alive!\n");
|
||
|
|
glutInit(&argc, argv);
|
||
|
|
glutInitContextVersion(4, 0);
|
||
|
|
glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
|
||
|
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
|
||
|
|
|
||
|
|
int scrWidth = glutGet(GLUT_SCREEN_WIDTH) * 5 / 6;
|
||
|
|
int scrHeight = glutGet(GLUT_SCREEN_HEIGHT) * 5 / 6;
|
||
|
|
//scrWidth = 640;
|
||
|
|
//scrHeight = 480;
|
||
|
|
aspect_ratio = ( (float) scrWidth) / scrHeight;
|
||
|
|
glutInitWindowSize( scrWidth , scrHeight );
|
||
|
|
glutInitWindowPosition( 0, 0);
|
||
|
|
glutCreateWindow("TriDi");
|
||
|
|
|
||
|
|
glutTimerFunc(ONE_TICK_MS, timer, 0);
|
||
|
|
glutDisplayFunc(renderLoop);
|
||
|
|
glutKeyboardFunc(keypressed);
|
||
|
|
glutPassiveMotionFunc(mousemoved);
|
||
|
|
|
||
|
|
/*check what MESA has to offer*/
|
||
|
|
const GLubyte *extensions = glGetString(GL_EXTENSIONS);
|
||
|
|
printf("%s\n", extensions);
|
||
|
|
|
||
|
|
glutMainLoop();
|
||
|
|
}
|