project for a (works on my devices) demo
This commit is contained in:
46
demo/Makefile
Normal file
46
demo/Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
include ../external.mk
|
||||
|
||||
TARGET=main.exe
|
||||
|
||||
OBJECTS=main.o
|
||||
|
||||
FULL_BUILD_OBJECTS=${OBJECTS}
|
||||
|
||||
|
||||
GLUT_D=${PWD}
|
||||
|
||||
LINKS=-lGLESv2 -lmyGLUT
|
||||
|
||||
# same as the GL_STUFF MAKEFILE
|
||||
CFLAGS=-ansi -Wpedantic -Winline -Werror -std=c11
|
||||
|
||||
all :
|
||||
make -C ${GLUT_D}
|
||||
make ${TARGET}
|
||||
|
||||
|
||||
# -L GLUT_D MUST GO AFTER THE L_SHLIBS, OTHERWISE ASSUMES THAT THE myGLUT DEPENDENCIES ARE SIMPLY UNMET
|
||||
# removed the space between -L and GLUT_D
|
||||
${TARGET} : ${OBJECTS}
|
||||
${COMPILER} \
|
||||
-o ${TARGET} \
|
||||
${FULL_BUILD_OBJECTS} \
|
||||
-Wl,-unresolved-symbols=ignore-in-shared-libs \
|
||||
${L_SHLIBS} \
|
||||
-L${GLUT_D} \
|
||||
${LINKS}
|
||||
|
||||
|
||||
# -I ./ è una porcata clamorosa
|
||||
main.o : main.c ${GLUT_D}glut.h ${GLUT_D}glut_extensions.h
|
||||
${COMPILER} \
|
||||
${I_MY_GLUT} \
|
||||
${I_GRAPHICS} \
|
||||
-c ${CFLAGS} main.c \
|
||||
${GLOBAL_COMPILE_CONF}
|
||||
|
||||
.PHONY: clean debug
|
||||
|
||||
clean:
|
||||
make clean -C ${GLUT_D}
|
||||
-rm ${TARGET} ${OBJECTS} *~ core
|
||||
101
demo/main.c
Executable file
101
demo/main.c
Executable file
@@ -0,0 +1,101 @@
|
||||
#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();
|
||||
}
|
||||
Reference in New Issue
Block a user