updated makefile for supporting different target architectures
use "ARCH=arch_name make" restructured project folder, implementations and headers together under sources/
This commit is contained in:
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
*.o
|
||||||
|
*.exe
|
||||||
|
# the order is important, an ignore definition overrides the preceding NOT_ignore
|
||||||
|
IA64_BUILD/**
|
||||||
|
!IA64_BUILD/variables.mk
|
||||||
|
AARCH64_BUILD/**
|
||||||
|
!AARCH64_BUILD/variables.mk
|
||||||
13
AARCH64_BUILD/variables.mk
Normal file
13
AARCH64_BUILD/variables.mk
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export CPP_COMPILER=aarch64-buildroot-linux-gnu-g++
|
||||||
|
|
||||||
|
export BD=${PWD}AARCH64_BUILD/
|
||||||
|
|
||||||
|
# headers are good even if from ARM
|
||||||
|
|
||||||
|
# libraries must point to the right one
|
||||||
|
|
||||||
|
RESOURCES_LOC=${PWD}../../resources/
|
||||||
|
export WAYLAND_LIBRARIES=${RESOURCES_LOC}libraries/
|
||||||
|
export EGL_LIBRARIES=${RESOURCES_LOC}libraries/
|
||||||
|
|
||||||
|
export GLUT_L_D=${GLUT_D}AARCH64_BUILD/
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#include <GLES2/gl2.h>
|
|
||||||
|
|
||||||
GLuint loadImg(const char* path);
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
include ../external.mk
|
|
||||||
|
|
||||||
S=${PWD}GL_STUFF/SOURCES/
|
|
||||||
H=${PWD}GL_STUFF/HEADERS/
|
|
||||||
O=${PWD}GL_STUFF/OBJECTS/
|
|
||||||
|
|
||||||
_U=UTILS/
|
|
||||||
_S=SCENE/
|
|
||||||
_E=EFFECTS/
|
|
||||||
_C=CURVES/
|
|
||||||
|
|
||||||
COMPATIBILITY_OBJECT=GLES_3_1_compatibility.o
|
|
||||||
|
|
||||||
UTILS_OBJECTS=${O}${_U}ClockIterator.o ${O}${_U}OnlyOnce.o ${O}${_U}ResourceCache.o ${O}${_U}ShaderMaker.o
|
|
||||||
|
|
||||||
SCENE_OBJECTS=${O}${_S}Camera.o ${O}${_S}Instance3D.o ${O}${_S}InstancesLoader.o ${O}${_S}Model3D.o ${O}${_S}ObjectInstance.o ${O}${_S}objloader.o ${O}${_S}ShadingHelper.o
|
|
||||||
|
|
||||||
# THE PLATFORM SUPPORTS UP TO GLES2 AND COMPUTE SHADERS COME WITH GLES3.1
|
|
||||||
# REMOVED
|
|
||||||
# ${O}${_E}CRT_shader.o
|
|
||||||
EFFECTS_OBJECTS=${O}${_E}PseudoContext.o ${O}${_E}ReelManager.o ${O}${_E}Scene.o ${O}${_E}Screen.o ${O}${_E}TexMerger.o
|
|
||||||
|
|
||||||
CURVES_OBJECTS=${O}${_C}Bezier.o ${O}${_C}Curve.o ${O}${_C}CurveIterator.o ${O}${_C}CurvesLoader.o ${O}${_C}Hermite.o ${O}${_C}NURBS.o
|
|
||||||
|
|
||||||
OBJECTS=${COMPATIBILITY_OBJECT} ${UTILS_OBJECTS} ${SCENE_OBJECTS} ${EFFECTS_OBJECTS} ${CURVES_OBJECTS}
|
|
||||||
|
|
||||||
CFLAGS=-ansi -Wpedantic -Winline -Werror -std=c++11 # c11
|
|
||||||
|
|
||||||
all:
|
|
||||||
make ${OBJECTS}
|
|
||||||
|
|
||||||
# COMPATIBILITY OBJECT
|
|
||||||
GLES_3_1_compatibility.o : GLES_3_1_compatibility.c GLES_3_1_compatibility.h ${HEADERS}GLES2/gl2.h ${HEADERS}GLES2/gl2ext.h
|
|
||||||
${C_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o GLES_3_1_compatibility.o \
|
|
||||||
-c -ansi -Wpedantic -Winline -Werror -std=c99 \
|
|
||||||
GLES_3_1_compatibility.c \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
# UTILS
|
|
||||||
|
|
||||||
${O}${_U}ClockIterator.o : ${S}${_U}ClockIterator.cpp ${H}${_U}ClockIterator.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
-o ${O}${_U}ClockIterator.o \
|
|
||||||
-c ${CFLAGS} ${S}${_U}ClockIterator.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
|
|
||||||
${O}${_U}OnlyOnce.o : ${S}${_U}OnlyOnce.cpp ${H}${_U}OnlyOnce.hpp ${H}${_U}stb_image.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_U}OnlyOnce.o \
|
|
||||||
-c ${CFLAGS} ${S}${_U}OnlyOnce.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_U}ResourceCache.o : ${S}${_U}ResourceCache.cpp ${H}${_U}ResourceCache.h ${H}${_U}ShaderMaker.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_U}ResourceCache.o \
|
|
||||||
-c ${CFLAGS} ${S}${_U}ResourceCache.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_U}ShaderMaker.o : ${S}${_U}ShaderMaker.cpp ${H}${_U}ShaderMaker.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_U}ShaderMaker.o \
|
|
||||||
-c ${CFLAGS} ${S}${_U}ShaderMaker.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
# SCENE
|
|
||||||
${O}${_S}Camera.o : ${S}${_S}Camera.cpp ${H}${_S}Camera.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
${I_MY_GLUT} \
|
|
||||||
-o ${O}${_S}Camera.o \
|
|
||||||
-c ${CFLAGS} ${S}${_S}Camera.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_S}Instance3D.o : ${S}${_S}Instance3D.cpp ${H}${_S}Instance3D.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_S}Instance3D.o \
|
|
||||||
-c ${CFLAGS} ${S}${_S}Instance3D.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_S}InstancesLoader.o : ${S}${_S}InstancesLoader.cpp ${H}${_S}InstancesLoader.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_S}InstancesLoader.o \
|
|
||||||
-c ${CFLAGS} ${S}${_S}InstancesLoader.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_S}ObjectInstance.o : ${S}${_S}ObjectInstance.cpp ${H}${_S}ObjectInstance.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_S}ObjectInstance.o \
|
|
||||||
-c ${CFLAGS} ${S}${_S}ObjectInstance.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_S}objloader.o : ${S}${_S}objloader.cpp ${H}${_S}objloader.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_S}objloader.o \
|
|
||||||
-c ${CFLAGS} ${S}${_S}objloader.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_S}Model3D.o : ${S}${_S}Model3D.cpp ${H}${_S}Model3D.hpp \
|
|
||||||
${H}${_U}OnlyOnce.hpp ${H}${_U}ShaderMaker.h ${H}${_S}objloader.hpp \
|
|
||||||
${H}${_U}ResourceCache.h \
|
|
||||||
./GLES_3_1_compatibility.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_S}Model3D.o \
|
|
||||||
-c ${CFLAGS} ${S}${_S}Model3D.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_S}ShadingHelper.o : ${S}${_S}ShadingHelper.cpp ${H}${_S}ShadingHelper.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_S}ShadingHelper.o \
|
|
||||||
-c ${CFLAGS} ${S}${_S}ShadingHelper.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
#EFFECTS
|
|
||||||
|
|
||||||
# THE PLATFORM SUPPORTS UP TO GLES2 AND COMPUTE SHADERS COME WITH GLES3.1
|
|
||||||
#
|
|
||||||
# ${O}${_E}CRT_shader.o : ${S}${_E}CRT_shader.cpp ${H}${_E}CRT_shader.h ${H}${_U}ShaderMaker.h
|
|
||||||
# ${COMPILER} \
|
|
||||||
# ${I_CGI_MATH} \
|
|
||||||
# ${I_GRAPHICS} \
|
|
||||||
# -o ${O}${_E}CRT_shader.o \
|
|
||||||
# -c ${CFLAGS} ${S}${_E}CRT_shader.cpp \
|
|
||||||
# ${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_E}PseudoContext.o : ${S}${_E}PseudoContext.cpp ${H}${_E}PseudoContext.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
-o ${O}${_E}PseudoContext.o \
|
|
||||||
-c ${CFLAGS} ${S}${_E}PseudoContext.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_E}ReelManager.o : ${S}${_E}ReelManager.cpp ${H}${_E}ReelManager.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
-o ${O}${_E}ReelManager.o \
|
|
||||||
-c ${CFLAGS} ${S}${_E}ReelManager.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_E}Scene.o : ${S}${_E}Scene.cpp ${H}${_E}Scene.h ./GLES_3_1_compatibility.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
${I_MY_GLUT} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_E}Scene.o \
|
|
||||||
-c ${CFLAGS} ${S}${_E}Scene.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_E}Screen.o : ${S}${_E}Screen.cpp ${H}${_E}Screen.h ${H}${_U}ShaderMaker.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
${I_MY_GLUT} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_E}Screen.o \
|
|
||||||
-c ${CFLAGS} ${S}${_E}Screen.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_E}TexMerger.o : ${S}${_E}TexMerger.cpp ${H}${_E}TexMerger.h ${H}${_U}ShaderMaker.h
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_GRAPHICS} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_E}TexMerger.o \
|
|
||||||
-c ${CFLAGS} ${S}${_E}TexMerger.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
#CURVES
|
|
||||||
${O}${_C}Bezier.o : ${S}${_C}Bezier.cpp ${H}${_C}Bezier.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_C}Bezier.o \
|
|
||||||
-c ${CFLAGS} ${S}${_C}Bezier.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_C}Curve.o : ${S}${_C}Curve.cpp ${H}${_C}Curve.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_C}Curve.o \
|
|
||||||
-c ${CFLAGS} ${S}${_C}Curve.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_C}CurveIterator.o : ${S}${_C}CurveIterator.cpp ${H}${_C}CurveIterator.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_C}CurveIterator.o \
|
|
||||||
-c ${CFLAGS} ${S}${_C}CurveIterator.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_C}CurvesLoader.o : ${S}${_C}CurvesLoader.cpp ${H}${_C}CurvesLoader.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_C}CurvesLoader.o \
|
|
||||||
-c ${CFLAGS} ${S}${_C}CurvesLoader.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_C}Hermite.o : ${S}${_C}Hermite.cpp ${H}${_C}Hermite.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_C}Hermite.o \
|
|
||||||
-c ${CFLAGS} ${S}${_C}Hermite.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
${O}${_C}NURBS.o : ${S}${_C}NURBS.cpp ${H}${_C}NURBS.hpp
|
|
||||||
${CPP_COMPILER} \
|
|
||||||
${I_CGI_MATH} \
|
|
||||||
-o ${O}${_C}NURBS.o \
|
|
||||||
-c ${CFLAGS} ${S}${_C}NURBS.cpp \
|
|
||||||
${GLOBAL_COMPILE_CONF}
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm ${OBJECTS} *~ core
|
|
||||||
11
IA64_BUILD/variables.mk
Normal file
11
IA64_BUILD/variables.mk
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export CPP_COMPILER=g++
|
||||||
|
|
||||||
|
export BD=${PWD}IA64_BUILD/
|
||||||
|
|
||||||
|
# headers are good even if from ARM
|
||||||
|
|
||||||
|
# libraries must point to the right one
|
||||||
|
export WAYLAND_LIBRARIES=/usr/lib/x86_64-linux-gnu/
|
||||||
|
export EGL_LIBRARIES=/usr/lib/x86_64-linux-gnu/
|
||||||
|
|
||||||
|
GLUT_L_D=${GLUT_D}IA64_BUILD/
|
||||||
45
Makefile
45
Makefile
@@ -1,25 +1,21 @@
|
|||||||
include external.mk
|
include external.mk
|
||||||
|
|
||||||
TARGET=Main.exe
|
include ${ARCH}_BUILD/variables.mk
|
||||||
|
|
||||||
OBJECTS=Main.o
|
TARGET=${BD}main.exe
|
||||||
|
|
||||||
GL_STUFF_D=${PWD}GL_STUFF/
|
OBJECTS=${BD}main.o
|
||||||
|
|
||||||
GOU=${GL_STUFF_D}OBJECTS/UTILS/
|
BG=${BD}GL_STUFF/
|
||||||
GOS=${GL_STUFF_D}OBJECTS/SCENE/
|
|
||||||
GOE=${GL_STUFF_D}OBJECTS/EFFECTS/
|
|
||||||
GOC=${GL_STUFF_D}OBJECTS/CURVES/
|
|
||||||
|
|
||||||
|
GL_STUFF_COMPATIBILITY_OBJECT=${BG}GLES_3_1_compatibility.o
|
||||||
GL_STUFF_COMPATIBILITY_OBJECT=${GL_STUFF_D}GLES_3_1_compatibility.o
|
GL_STUFF_UTILS_OBJECTS=${BG}UTILS/ClockIterator.o ${BG}UTILS/OnlyOnce.o ${BG}UTILS/ResourceCache.o ${BG}UTILS/ShaderMaker.o
|
||||||
GL_STUFF_UTILS_OBJECTS=${GOU}ClockIterator.o ${GOU}OnlyOnce.o ${GOU}ResourceCache.o ${GOU}ShaderMaker.o
|
GL_STUFF_SCENE_OBJECTS=${BG}SCENE/Camera.o ${BG}SCENE/Instance3D.o ${BG}SCENE/InstancesLoader.o ${BG}SCENE/Model3D.o ${BG}SCENE/ObjectInstance.o ${BG}SCENE/objloader.o ${BG}SCENE/ShadingHelper.o
|
||||||
GL_STUFF_SCENE_OBJECTS=${GOS}Camera.o ${GOS}Instance3D.o ${GOS}InstancesLoader.o ${GOS}Model3D.o ${GOS}ObjectInstance.o ${GOS}objloader.o ${GOS}ShadingHelper.o
|
|
||||||
# THE PLATFORM SUPPORTS UP TO GLES2 AND COMPUTE SHADERS COME WITH GLES3.1
|
# THE PLATFORM SUPPORTS UP TO GLES2 AND COMPUTE SHADERS COME WITH GLES3.1
|
||||||
# REMOVED
|
# REMOVED
|
||||||
# ${O}${_E}CRT_shader.o
|
# ${O}${_E}CRT_shader.o
|
||||||
GL_STUFF_EFFECTS_OBJECTS=${GOE}PseudoContext.o ${GOE}ReelManager.o ${GOE}Scene.o ${GOE}Screen.o ${GOE}TexMerger.o
|
GL_STUFF_EFFECTS_OBJECTS=${BG}EFFECTS/PseudoContext.o ${BG}EFFECTS/ReelManager.o ${BG}EFFECTS/Scene.o ${BG}EFFECTS/Screen.o ${BG}EFFECTS/TexMerger.o
|
||||||
GL_STUFF_CURVES_OBJECTS=${GOC}Bezier.o ${GOC}Curve.o ${GOC}CurveIterator.o ${GOC}CurvesLoader.o ${GOC}Hermite.o ${GOC}NURBS.o
|
GL_STUFF_CURVES_OBJECTS=${BG}CURVES/Bezier.o ${BG}CURVES/Curve.o ${BG}CURVES/CurveIterator.o ${BG}CURVES/CurvesLoader.o ${BG}CURVES/Hermite.o ${BG}CURVES/NURBS.o
|
||||||
|
|
||||||
GL_STUFF_OBJECTS=${GL_STUFF_UTILS_OBJECTS} ${GL_STUFF_SCENE_OBJECTS} \
|
GL_STUFF_OBJECTS=${GL_STUFF_UTILS_OBJECTS} ${GL_STUFF_SCENE_OBJECTS} \
|
||||||
${GL_STUFF_EFFECTS_OBJECTS} ${GL_STUFF_CURVES_OBJECTS} \
|
${GL_STUFF_EFFECTS_OBJECTS} ${GL_STUFF_CURVES_OBJECTS} \
|
||||||
@@ -31,34 +27,37 @@ FULL_BUILD_OBJECTS=${GL_STUFF_OBJECTS} ${OBJECTS}
|
|||||||
LINKS=-lmyGLUT -lGLESv2 -lEGL -lm -lstdc++ -lc
|
LINKS=-lmyGLUT -lGLESv2 -lEGL -lm -lstdc++ -lc
|
||||||
|
|
||||||
# same as the GL_STUFF MAKEFILE
|
# same as the GL_STUFF MAKEFILE
|
||||||
CFLAGS=-ansi -Wpedantic -Winline -Werror -std=c++11
|
|
||||||
|
|
||||||
all :
|
all :
|
||||||
make -C ${GL_STUFF_D}
|
make -C sources/GL_STUFF/
|
||||||
make ${TARGET}
|
make ${TARGET}
|
||||||
|
|
||||||
|
# ADD
|
||||||
|
# -Wl,--verbose \
|
||||||
|
# TO SEE LINKER ATTEMPTS AT RETRIEVING LIBRARIES
|
||||||
${TARGET} : ${OBJECTS}
|
${TARGET} : ${OBJECTS}
|
||||||
${CPP_COMPILER} \
|
${CPP_COMPILER} \
|
||||||
-o ${TARGET} \
|
-o ${TARGET} \
|
||||||
-Wl,-unresolved-symbols=ignore-in-shared-libs \
|
-Wl,-unresolved-symbols=ignore-in-shared-libs \
|
||||||
${FULL_BUILD_OBJECTS} \
|
${FULL_BUILD_OBJECTS} \
|
||||||
-L${GLUT_D} \
|
-L${GLUT_L_D} \
|
||||||
${L_SHLIBS} \
|
-L${EGL_LIBRARIES} \
|
||||||
|
-fno-exceptions \
|
||||||
${LINKS}
|
${LINKS}
|
||||||
|
|
||||||
|
|
||||||
# -I ./ è una porcata clamorosa
|
# -I ./ è una porcata clamorosa
|
||||||
Main.o : Main.cpp ${GLUT_D}glut.h ./GL_STUFF/GLES_3_1_compatibility.h
|
${BD}main.o : ${SD}main.cpp ${GLUT_I_D}glut.h ${SD}GL_STUFF/GLES_3_1_compatibility.h
|
||||||
${CPP_COMPILER} \
|
${CPP_COMPILER} \
|
||||||
${I_GRAPHICS} \
|
${I_EGL} \
|
||||||
${I_CGI_MATH} \
|
${I_CGI_MATH} \
|
||||||
${I_MY_GLUT} \
|
${I_MY_GLUT} \
|
||||||
-I ./ \
|
-I ${SD} \
|
||||||
-c ${CFLAGS} Main.cpp \
|
-o ${BD}main.o \
|
||||||
|
-c ${CFLAGS} ${SD}main.cpp \
|
||||||
${GLOBAL_COMPILE_CONF}
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
.PHONY: clean debug
|
.PHONY: clean debug
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
make clean -C ${GL_STUFF_D}
|
-rm ${TARGET} ${FULL_BUILD_OBJECTS} *~ core
|
||||||
-rm ${TARGET} ${OBJECTS} *~ core
|
|
||||||
|
|||||||
6
README
6
README
@@ -1,3 +1,9 @@
|
|||||||
|
THE EXECUTABLE MUST HAVE OWNER root AND "set user id" (chmod +s ) FLAG SET
|
||||||
|
( running as regular user has no rights for /dev/inputXXX , running as root breaks other stuff, so we go with owner root and setUID )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
special thanks to
|
special thanks to
|
||||||
|
|
||||||
https://gist.github.com/lmarz/1059f7c4101a15e2a04d6991d7b7b3d1
|
https://gist.github.com/lmarz/1059f7c4101a15e2a04d6991d7b7b3d1
|
||||||
|
|||||||
35
external.mk
35
external.mk
@@ -1,41 +1,24 @@
|
|||||||
# export for making the definitions available anywhere during the run
|
|
||||||
# instead of using imports in each makefile of the project (which would also break since PWD gets reevaluated at each import)
|
|
||||||
# export COMPILER=aarch64-linux-gnu-gcc
|
|
||||||
export CPP_COMPILER=aarch64-linux-gnu-g++
|
|
||||||
export C_COMPILER=aarch64-linux-gnu-gcc
|
|
||||||
|
|
||||||
export GLOBAL_COMPILE_CONF=-fno-stack-protector
|
export GLOBAL_COMPILE_CONF=-fno-stack-protector
|
||||||
export CFLAGS=-ansi -Wpedantic -Winline -Werror # -std=c99
|
export CFLAGS=-ansi -Wpedantic -Winline -Werror -std=c++11
|
||||||
|
|
||||||
|
|
||||||
|
export PWD=/home/beno/Desktop/rg552_minimal_dev_env/WAYLAND/demos/rez_demo/
|
||||||
export PWD=/home/beno/Desktop/BATO/WAYLAND/demo_3_scuola/
|
|
||||||
# export PWD:=$(shell pwd)/
|
|
||||||
|
|
||||||
|
|
||||||
# DIRECTORIES
|
# DIRECTORIES
|
||||||
|
|
||||||
|
export SD=${PWD}sources/
|
||||||
|
|
||||||
export GLUT_D=${PWD}../demo_3_2_link_GLUT/glut_mine/
|
export GLUT_D=${PWD}../my_glut/
|
||||||
export RESOURCES_LOC=${PWD}../resources/
|
export GLUT_I_D=${GLUT_D}headers/
|
||||||
|
|
||||||
|
RESOURCES_LOC=${PWD}../../resources/
|
||||||
|
|
||||||
# includes EGL GLES2 (KHR needed by both)
|
# includes EGL GLES2 (KHR needed by both)
|
||||||
export HEADERS=${RESOURCES_LOC}headers/
|
export HEADERS=${RESOURCES_LOC}headers/
|
||||||
export GLM_HEADERS=${PWD}../glm/
|
export GLM_HEADERS=${RESOURCES_LOC}sources/glm/
|
||||||
|
|
||||||
|
|
||||||
export LINKED_LIBRARIES=${PWD}../../LIBRARIES_FROM_BATO
|
|
||||||
|
|
||||||
|
|
||||||
# LINK
|
|
||||||
export L_SHLIBS=-L${LINKED_LIBRARIES}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# INCLUDE
|
# INCLUDE
|
||||||
export I_HEADERS=-I ${HEADERS} # GRAPHICS FOR NOW
|
export I_HEADERS=-I ${HEADERS} # GRAPHICS FOR NOW
|
||||||
export I_GRAPHICS=-I ${HEADERS}
|
export I_EGL=-I ${HEADERS}
|
||||||
export I_CGI_MATH=-I ${GLM_HEADERS}
|
export I_CGI_MATH=-I ${GLM_HEADERS}
|
||||||
export I_MY_GLUT=-I ${GLUT_D}
|
export I_MY_GLUT=-I ${GLUT_I_D}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "../../HEADERS/CURVES/Bezier.hpp"
|
#include "Bezier.hpp"
|
||||||
#include "iostream"
|
#include <iostream>
|
||||||
|
|
||||||
#define LERP(t,a,b) (1 - t) * a + t * b;
|
#define LERP(t,a,b) (1 - t) * a + t * b;
|
||||||
|
|
||||||
Bezier::Bezier(unsigned int order, vector<glm::vec3> *points, vector<float> *intervals) : Curve{ points, intervals } {
|
Bezier::Bezier(unsigned int order, vector<glm::vec3> *points, vector<float> *intervals) : Curve{ points, intervals } {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/CURVES/Curve.hpp"
|
#include "Curve.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/CURVES/CurveIterator.hpp"
|
#include "CurveIterator.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/CURVES/CurvesLoader.hpp"
|
#include "CurvesLoader.hpp"
|
||||||
|
|
||||||
|
|
||||||
string CurvesLoader::currentCurveType;
|
string CurvesLoader::currentCurveType;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/CURVES/Hermite.hpp"
|
#include "Hermite.hpp"
|
||||||
|
|
||||||
#define PHI0(t) (2.0f*t*t*t - 3.0f*t*t + 1)
|
#define PHI0(t) (2.0f*t*t*t - 3.0f*t*t + 1)
|
||||||
#define PHI1(t) (t*t*t - 2.0f*t*t + t)
|
#define PHI1(t) (t*t*t - 2.0f*t*t + t)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/CURVES/NURBS.hpp"
|
#include "NURBS.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "../../HEADERS/EFFECTS/CRT_shader.h"
|
#include "../../../headers/GL_STUFF/EFFECTS/CRT_shader.h"
|
||||||
#include "../../HEADERS/UTILS/ShaderMaker.h"
|
#include "../../../headers/GL_STUFF/UTILS/ShaderMaker.h"
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/EFFECTS/PseudoContext.h"
|
#include "PseudoContext.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
PseudoContext::PseudoContext(int left, int top, int width, int height) {
|
PseudoContext::PseudoContext(int left, int top, int width, int height) {
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
*/
|
*/
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#include "../../HEADERS/EFFECTS/ReelManager.h"
|
#include "ReelManager.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
/* equals stdlib.h from C */
|
/* equals stdlib.h from C */
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "../../HEADERS/EFFECTS/Scene.h"
|
#include "Scene.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../../GLES_3_1_compatibility.h"
|
#include "../GLES_3_1_compatibility.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
/* REPLACED
|
/* REPLACED
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "../../HEADERS/EFFECTS/Screen.h"
|
#include "Screen.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../../GLES_3_1_compatibility.h"
|
#include "../GLES_3_1_compatibility.h"
|
||||||
#include <glut.h>
|
#include <glut.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../../HEADERS/UTILS/ShaderMaker.h"
|
#include "../UTILS/ShaderMaker.h"
|
||||||
|
|
||||||
Screen::Screen(int left, int top, int width, int height)
|
Screen::Screen(int left, int top, int width, int height)
|
||||||
: PseudoContext{ left, top, width, height }
|
: PseudoContext{ left, top, width, height }
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "../../HEADERS/EFFECTS/TexMerger.h"
|
#include "TexMerger.h"
|
||||||
#include "../../HEADERS/UTILS/ShaderMaker.h"
|
#include "../UTILS/ShaderMaker.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../../GLES_3_1_compatibility.h"
|
#include "../GLES_3_1_compatibility.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
TexMerger::TexMerger(GLuint texCount, unsigned int texWidth, unsigned int texHeight) {
|
TexMerger::TexMerger(GLuint texCount, unsigned int texWidth, unsigned int texHeight) {
|
||||||
@@ -26,7 +26,7 @@ void glDrawBuffers( GLsizei n,GLenum *buffers_ptr) {
|
|||||||
glDrawBuffersEXT( n, buffers_ptr);
|
glDrawBuffersEXT( n, buffers_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLES_3_1_compatibility_init(){
|
void GLES_3_1_comp_init(){
|
||||||
glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
|
glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
|
||||||
glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
|
glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
|
||||||
glDrawBuffersEXT = (PFNGLDRAWBUFFERSEXTPROC)eglGetProcAddress("glDrawBuffersEXT");
|
glDrawBuffersEXT = (PFNGLDRAWBUFFERSEXTPROC)eglGetProcAddress("glDrawBuffersEXT");
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
|
|
||||||
/* fails at link time,
|
/* fails at link time,
|
||||||
@@ -33,4 +37,8 @@ void glBindVertexArray( GLuint array_ptr);
|
|||||||
|
|
||||||
void glDrawBuffers( GLsizei n,GLenum *buffers_ptr);
|
void glDrawBuffers( GLsizei n,GLenum *buffers_ptr);
|
||||||
|
|
||||||
void GLES_3_1_compatibility_init();
|
void GLES_3_1_comp_init();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
228
sources/GL_STUFF/Makefile
Normal file
228
sources/GL_STUFF/Makefile
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
include ../../external.mk
|
||||||
|
|
||||||
|
include ../../${ARCH}_BUILD/variables.mk
|
||||||
|
|
||||||
|
|
||||||
|
LBD=${BD}GL_STUFF/
|
||||||
|
LSD=${SD}GL_STUFF/
|
||||||
|
|
||||||
|
_U=UTILS/
|
||||||
|
_S=SCENE/
|
||||||
|
_E=EFFECTS/
|
||||||
|
_C=CURVES/
|
||||||
|
|
||||||
|
COMPATIBILITY_OBJECT=${LBD}GLES_3_1_compatibility.o
|
||||||
|
|
||||||
|
UTILS_OBJECTS=${LBD}${_U}ClockIterator.o ${LBD}${_U}OnlyOnce.o ${LBD}${_U}ResourceCache.o ${LBD}${_U}ShaderMaker.o
|
||||||
|
|
||||||
|
SCENE_OBJECTS=${LBD}${_S}Camera.o ${LBD}${_S}Instance3D.o ${LBD}${_S}InstancesLoader.o ${LBD}${_S}Model3D.o ${LBD}${_S}ObjectInstance.o ${LBD}${_S}objloader.o ${LBD}${_S}ShadingHelper.o
|
||||||
|
|
||||||
|
# THE PLATFORM SUPPORTS UP TO GLES2 AND COMPUTE SHADERS COME WITH GLES3.1
|
||||||
|
# REMOVED
|
||||||
|
# ${LBD}${_E}CRT_shader.o
|
||||||
|
EFFECTS_OBJECTS=${LBD}${_E}PseudoContext.o ${LBD}${_E}ReelManager.o ${LBD}${_E}Scene.o ${LBD}${_E}Screen.o ${LBD}${_E}TexMerger.o
|
||||||
|
|
||||||
|
CURVES_OBJECTS=${LBD}${_C}Bezier.o ${LBD}${_C}Curve.o ${LBD}${_C}CurveIterator.o ${LBD}${_C}CurvesLoader.o ${LBD}${_C}Hermite.o ${LBD}${_C}NURBS.o
|
||||||
|
|
||||||
|
OBJECTS=${COMPATIBILITY_OBJECT} ${UTILS_OBJECTS} ${SCENE_OBJECTS} ${EFFECTS_OBJECTS} ${CURVES_OBJECTS}
|
||||||
|
|
||||||
|
CFLAGS=-ansi -Wpedantic -Winline -Werror -std=c++11 # c11
|
||||||
|
|
||||||
|
all:
|
||||||
|
mkdir -p ${LBD} ${LBD}${_U} ${LBD}${_S} ${LBD}${_E} ${LBD}${_C}
|
||||||
|
make ${OBJECTS}
|
||||||
|
|
||||||
|
# COMPATIBILITY OBJECT
|
||||||
|
${LBD}GLES_3_1_compatibility.o : ${LSD}GLES_3_1_compatibility.c ${LSD}GLES_3_1_compatibility.h ${HEADERS}GLES2/gl2.h ${HEADERS}GLES2/gl2ext.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}GLES_3_1_compatibility.o \
|
||||||
|
-c -${CFLAGS} \
|
||||||
|
${LSD}GLES_3_1_compatibility.c \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
# UTILS
|
||||||
|
|
||||||
|
${LBD}${_U}ClockIterator.o : ${LSD}${_U}ClockIterator.cpp ${LSD}${_U}ClockIterator.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
-o ${LBD}${_U}ClockIterator.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_U}ClockIterator.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
|
||||||
|
${LBD}${_U}OnlyOnce.o : ${LSD}${_U}OnlyOnce.cpp ${LSD}${_U}OnlyOnce.hpp ${LSD}${_U}stb_image.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_U}OnlyOnce.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_U}OnlyOnce.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_U}ResourceCache.o : ${LSD}${_U}ResourceCache.cpp ${LSD}${_U}ResourceCache.h ${LSD}${_U}ShaderMaker.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_U}ResourceCache.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_U}ResourceCache.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_U}ShaderMaker.o : ${LSD}${_U}ShaderMaker.cpp ${LSD}${_U}ShaderMaker.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_U}ShaderMaker.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_U}ShaderMaker.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
# SCENE
|
||||||
|
${LBD}${_S}Camera.o : ${LSD}${_S}Camera.cpp ${LSD}${_S}Camera.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
${I_MY_GLUT} \
|
||||||
|
-o ${LBD}${_S}Camera.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_S}Camera.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_S}Instance3D.o : ${LSD}${_S}Instance3D.cpp ${LSD}${_S}Instance3D.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_S}Instance3D.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_S}Instance3D.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_S}InstancesLoader.o : ${LSD}${_S}InstancesLoader.cpp ${LSD}${_S}InstancesLoader.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_S}InstancesLoader.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_S}InstancesLoader.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_S}ObjectInstance.o : ${LSD}${_S}ObjectInstance.cpp ${LSD}${_S}ObjectInstance.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_S}ObjectInstance.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_S}ObjectInstance.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_S}objloader.o : ${LSD}${_S}objloader.cpp ${LSD}${_S}objloader.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_S}objloader.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_S}objloader.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_S}Model3D.o : ${LSD}${_S}Model3D.cpp ${LSD}${_S}Model3D.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_S}Model3D.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_S}Model3D.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_S}ShadingHelper.o : ${LSD}${_S}ShadingHelper.cpp ${LSD}${_S}ShadingHelper.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_S}ShadingHelper.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_S}ShadingHelper.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
#EFFECTS
|
||||||
|
|
||||||
|
# THE PLATFORM SUPPORTS UP TO GLES2 AND COMPUTE SHADERS COME WITH GLES3.1
|
||||||
|
#
|
||||||
|
# ${LBD}${_E}CRT_shader.o : ${LSD}${_E}CRT_shader.cpp ${LSD}${_E}CRT_shader.h ${LSD}${_U}ShaderMaker.h
|
||||||
|
# ${COMPILER} \
|
||||||
|
# ${I_CGI_MATH} \
|
||||||
|
# ${I_GRAPHICS} \
|
||||||
|
# -o ${LBD}${_E}CRT_shader.o \
|
||||||
|
# -c ${CFLAGS} ${LSD}${_E}CRT_shader.cpp \
|
||||||
|
# ${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_E}PseudoContext.o : ${LSD}${_E}PseudoContext.cpp ${LSD}${_E}PseudoContext.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
-o ${LBD}${_E}PseudoContext.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_E}PseudoContext.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_E}ReelManager.o : ${LSD}${_E}ReelManager.cpp ${LSD}${_E}ReelManager.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
-o ${LBD}${_E}ReelManager.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_E}ReelManager.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_E}Scene.o : ${LSD}${_E}Scene.cpp ${LSD}${_E}Scene.h ${LSD}GLES_3_1_compatibility.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
${I_MY_GLUT} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_E}Scene.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_E}Scene.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_E}Screen.o : ${LSD}${_E}Screen.cpp ${LSD}${_E}Screen.h ${LSD}${_U}ShaderMaker.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
${I_MY_GLUT} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_E}Screen.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_E}Screen.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_E}TexMerger.o : ${LSD}${_E}TexMerger.cpp ${LSD}${_E}TexMerger.h ${LSD}${_U}ShaderMaker.h
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_EGL} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_E}TexMerger.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_E}TexMerger.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
#CURVES
|
||||||
|
${LBD}${_C}Bezier.o : ${LSD}${_C}Bezier.cpp ${LSD}${_C}Bezier.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_C}Bezier.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_C}Bezier.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_C}Curve.o : ${LSD}${_C}Curve.cpp ${LSD}${_C}Curve.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_C}Curve.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_C}Curve.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_C}CurveIterator.o : ${LSD}${_C}CurveIterator.cpp ${LSD}${_C}CurveIterator.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_C}CurveIterator.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_C}CurveIterator.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_C}CurvesLoader.o : ${LSD}${_C}CurvesLoader.cpp ${LSD}${_C}CurvesLoader.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_C}CurvesLoader.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_C}CurvesLoader.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_C}Hermite.o : ${LSD}${_C}Hermite.cpp ${LSD}${_C}Hermite.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_C}Hermite.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_C}Hermite.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
${LBD}${_C}NURBS.o : ${LSD}${_C}NURBS.cpp ${LSD}${_C}NURBS.hpp
|
||||||
|
${CPP_COMPILER} \
|
||||||
|
${I_CGI_MATH} \
|
||||||
|
-o ${LBD}${_C}NURBS.o \
|
||||||
|
-c ${CFLAGS} ${LSD}${_C}NURBS.cpp \
|
||||||
|
${GLOBAL_COMPILE_CONF}
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm ${OBJECTS} *~ core
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#define GLM_ENABLE_EXPERIMENTAL
|
#define GLM_ENABLE_EXPERIMENTAL
|
||||||
|
|
||||||
#include "../../HEADERS/SCENE/Camera.hpp"
|
#include "Camera.hpp"
|
||||||
/* REPLACED
|
/* REPLACED
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
*/
|
*/
|
||||||
@@ -87,6 +87,47 @@ Camera* CameraController::getCamera() {
|
|||||||
return camera;
|
return camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CameraController::panX( float deltaX){
|
||||||
|
/*
|
||||||
|
deltaX *= M_PI / 180;
|
||||||
|
*/
|
||||||
|
|
||||||
|
printf("deltaX of %f\n", deltaX);
|
||||||
|
|
||||||
|
/*
|
||||||
|
mat4 global_y_rotation = glm::rotate(glm::mat4(), -deltaX, glm::vec3( 0.0, 1.0, 0.0) );
|
||||||
|
|
||||||
|
getCamera()->cameraUp = ( global_y_rotation * vec4( getCamera()->cameraUp, 1.0) );
|
||||||
|
|
||||||
|
getCamera()->cameraFront = ( global_y_rotation * vec4( getCamera()->cameraFront, 1.0) );
|
||||||
|
|
||||||
|
//vec3.rotateY(this.focalPoint,this.focalPoint, this.position, -deltaX);
|
||||||
|
*/
|
||||||
|
|
||||||
|
PHI += 0;
|
||||||
|
THETA += deltaX;
|
||||||
|
|
||||||
|
vec3 direction;
|
||||||
|
direction.x = cos(radians(PHI)) * cos(radians(THETA));
|
||||||
|
direction.y = sin(radians(PHI));
|
||||||
|
direction.z = cos(radians(PHI)) * sin(radians(THETA));
|
||||||
|
getCamera()->cameraFront = normalize(direction);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CameraController::panY( float deltaY){
|
||||||
|
|
||||||
|
PHI += deltaY;
|
||||||
|
THETA += 0;
|
||||||
|
|
||||||
|
vec3 direction;
|
||||||
|
direction.x = cos(radians(PHI)) * cos(radians(THETA));
|
||||||
|
direction.y = sin(radians(PHI));
|
||||||
|
direction.z = cos(radians(PHI)) * sin(radians(THETA));
|
||||||
|
getCamera()->cameraFront = normalize(direction);
|
||||||
|
}
|
||||||
|
|
||||||
void CameraController::setWindowData(int left, int width, int top, int height) {
|
void CameraController::setWindowData(int left, int width, int top, int height) {
|
||||||
|
|
||||||
windowLeft = left;
|
windowLeft = left;
|
||||||
42
sources/GL_STUFF/SCENE/Camera.hpp
Executable file
42
sources/GL_STUFF/SCENE/Camera.hpp
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
class Camera {
|
||||||
|
|
||||||
|
public:
|
||||||
|
glm::vec3 cameraPos;
|
||||||
|
glm::vec3 cameraFront;
|
||||||
|
glm::vec3 cameraUp;
|
||||||
|
|
||||||
|
Camera();
|
||||||
|
Camera( glm::vec3 position, glm::vec3 front, glm::vec3 up);
|
||||||
|
glm::mat4 getViewMat();
|
||||||
|
glm::vec3 getPosition();
|
||||||
|
//exp
|
||||||
|
void alignTo( glm::vec3 direction);
|
||||||
|
void setPosition( glm::vec3 pos);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CameraController {
|
||||||
|
|
||||||
|
private:
|
||||||
|
Camera *camera;
|
||||||
|
float cameraSpeed = 0.5f;
|
||||||
|
bool mouseUnlocked = true;
|
||||||
|
float lastX;
|
||||||
|
float lastY;
|
||||||
|
float PHI = 0.0;
|
||||||
|
float THETA = 270.0;
|
||||||
|
unsigned int windowLeft;
|
||||||
|
unsigned int windowTop;
|
||||||
|
unsigned int windowWidth;
|
||||||
|
unsigned int windowHeight;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CameraController(Camera *cam);
|
||||||
|
Camera* getCamera();
|
||||||
|
void setWindowData(int left, int width, int top, int height);
|
||||||
|
void mouseMotion(int cursorX, int cursorY);
|
||||||
|
void keyPress(unsigned char key);
|
||||||
|
void panX( float deltaX);
|
||||||
|
void panY( float deltaY);
|
||||||
|
};
|
||||||
203
sources/GL_STUFF/SCENE/Camera_OG.cpp
Normal file
203
sources/GL_STUFF/SCENE/Camera_OG.cpp
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
#define GLM_ENABLE_EXPERIMENTAL
|
||||||
|
|
||||||
|
#include "../../../headers/GL_STUFF/SCENE/Camera.hpp"
|
||||||
|
/* REPLACED
|
||||||
|
#include <GL/freeglut.h>
|
||||||
|
*/
|
||||||
|
extern "C" {
|
||||||
|
#include <glut.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
#include <glm/gtx/transform.hpp>
|
||||||
|
#include <glm/gtx/norm.hpp>
|
||||||
|
|
||||||
|
/* don't know how it worked before */
|
||||||
|
#include <glm/gtx/quaternion.hpp>
|
||||||
|
|
||||||
|
/* aarch64-linux-gnu/include/math.h already defines it */
|
||||||
|
#ifndef M_PI
|
||||||
|
#define M_PI 3.14159265358979323846264338327950288
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace glm;
|
||||||
|
|
||||||
|
Camera::Camera() {
|
||||||
|
this->cameraPos = vec3();
|
||||||
|
this->cameraFront = vec3(0.0f, 0.0f, -1.0f);
|
||||||
|
this->cameraUp = vec3(0.0f, 1.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera::Camera(vec3 position, vec3 front, vec3 up) {
|
||||||
|
if (! glm::length(front))
|
||||||
|
throw std::invalid_argument("Camera : front vector has no length");
|
||||||
|
if (! glm::length(up))
|
||||||
|
throw std::invalid_argument("Camera : up vector has no length");
|
||||||
|
this->cameraPos = position;
|
||||||
|
this->cameraFront = front;
|
||||||
|
this->cameraUp = up;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::mat4 Camera::getViewMat() {
|
||||||
|
return lookAt(cameraPos, cameraPos + cameraFront, cameraUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec3 Camera::getPosition() {
|
||||||
|
return cameraPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::setPosition(glm::vec3 pos) {
|
||||||
|
cameraPos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::alignTo(glm::vec3 direction) {
|
||||||
|
glm::vec3 localZ;
|
||||||
|
|
||||||
|
direction = glm::normalize(direction);
|
||||||
|
localZ = cameraFront;
|
||||||
|
|
||||||
|
glm::quat a = glm::rotation(localZ, direction);
|
||||||
|
|
||||||
|
cameraFront = glm::toMat4(a) * glm::vec4(cameraFront, 0.0f);
|
||||||
|
cameraUp = glm::toMat4(a) * glm::vec4(cameraUp, 0.0f); //temp
|
||||||
|
|
||||||
|
// ++++++++++++++++++++++++++ //
|
||||||
|
glm::vec3 right = glm::normalize(cross(cameraFront, cameraUp));
|
||||||
|
right.y = 0;
|
||||||
|
glm::vec3 stabilizedR = glm::normalize(right);
|
||||||
|
|
||||||
|
cameraUp = glm::cross(stabilizedR, cameraFront);
|
||||||
|
}
|
||||||
|
|
||||||
|
CameraController::CameraController(Camera *cam) {
|
||||||
|
lastX = 0;
|
||||||
|
lastY = 0;
|
||||||
|
windowHeight = 0;
|
||||||
|
windowWidth = 0;
|
||||||
|
windowTop = 0;
|
||||||
|
windowLeft = 0;
|
||||||
|
this->camera = cam;
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera* CameraController::getCamera() {
|
||||||
|
return camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CameraController::setWindowData(int left, int width, int top, int height) {
|
||||||
|
|
||||||
|
windowLeft = left;
|
||||||
|
windowWidth = width;
|
||||||
|
windowTop = top;
|
||||||
|
windowHeight = height;
|
||||||
|
lastX = left + width / 2;
|
||||||
|
lastY = top + height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CameraController::mouseMotion(int cursorX, int cursorY) {
|
||||||
|
//return;
|
||||||
|
float alfa = 0.05; //serve ridimensionare l'offset tra due posizioni successive del mouse
|
||||||
|
//il mouse è appena entrato nella finestra
|
||||||
|
if (mouseUnlocked)
|
||||||
|
{
|
||||||
|
lastX = windowLeft + windowWidth / 2;
|
||||||
|
lastY = windowTop + windowHeight / 2;
|
||||||
|
mouseUnlocked = false;
|
||||||
|
}
|
||||||
|
//di quanto ci siamo mossi
|
||||||
|
float xoffset = (cursorX - lastX);
|
||||||
|
float yoffset = (lastY - cursorY);
|
||||||
|
|
||||||
|
glutWarpPointer(windowLeft + windowWidth / 2, windowTop + windowHeight / 2);
|
||||||
|
|
||||||
|
lastX = windowLeft + windowWidth / 2;
|
||||||
|
lastY = windowTop + windowHeight / 2;
|
||||||
|
|
||||||
|
xoffset *= alfa;
|
||||||
|
yoffset *= alfa;
|
||||||
|
|
||||||
|
PHI += yoffset;
|
||||||
|
THETA += xoffset;
|
||||||
|
|
||||||
|
//if (PHI >= 179.0)
|
||||||
|
// PHI = 179;
|
||||||
|
|
||||||
|
vec3 direction;
|
||||||
|
direction.x = cos(radians(PHI)) * cos(radians(THETA));
|
||||||
|
direction.y = sin(radians(PHI));
|
||||||
|
direction.z = cos(radians(PHI)) * sin(radians(THETA));
|
||||||
|
getCamera()->cameraFront = normalize(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CameraController::keyPress(unsigned char key) {
|
||||||
|
Camera *c = getCamera();
|
||||||
|
|
||||||
|
vec3 dir;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
|
||||||
|
case 'a':
|
||||||
|
//Calcolo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
dir = normalize(cross(getCamera()->cameraFront, getCamera()->cameraUp));
|
||||||
|
//Mi sposto a sinistra lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos - dir * cameraSpeed;
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
//Calcolo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
dir = normalize(cross(c->cameraFront, c->cameraUp));
|
||||||
|
//Mi sposto a sinistra lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos - dir * (cameraSpeed * 10);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
//Calcolo la irezione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
dir = normalize(cross(c->cameraFront, c->cameraUp));//Mi sposto a destra lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos + dir * cameraSpeed;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
//Calcolo la irezione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
dir = normalize(cross(c->cameraFront, c->cameraUp));//Mi sposto a destra lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos + dir * (cameraSpeed * 10);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
//Mi sposto indietro lungo la direzione della camera
|
||||||
|
c->cameraPos = c->cameraPos - cameraSpeed * c->cameraFront;
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
//Mi sposto indietro lungo la direzione della camera
|
||||||
|
c->cameraPos = c->cameraPos - (cameraSpeed * 10) * c->cameraFront;
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
//Mi sposto avanti lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos + cameraSpeed * c->cameraFront;
|
||||||
|
break;
|
||||||
|
case 'W':
|
||||||
|
//Mi sposto avanti lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos + (cameraSpeed * 10) * c->cameraFront;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
//Mi sposto avanti lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos + cameraSpeed * c->cameraUp;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
//Mi sposto avanti lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos + (cameraSpeed * 10) * c->cameraUp;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
//Mi sposto avanti lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos - cameraSpeed * c->cameraUp;
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
//Mi sposto avanti lungo la direzione perpendicolare alla direzione della camera e l'alto della camera
|
||||||
|
c->cameraPos = c->cameraPos - (cameraSpeed * 10) * c->cameraUp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/SCENE/Instance3D.h"
|
#include "Instance3D.h"
|
||||||
|
|
||||||
Instance3D::Instance3D(Model3D* mesh, vec3 position) : WorldInstanceable{ position } {
|
Instance3D::Instance3D(Model3D* mesh, vec3 position) : WorldInstanceable{ position } {
|
||||||
this->mesh = mesh;
|
this->mesh = mesh;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "../../HEADERS/SCENE/InstancesLoader.h"
|
#include "InstancesLoader.h"
|
||||||
|
|
||||||
char lineHeader[128];
|
char lineHeader[128];
|
||||||
char* res;
|
char* res;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "../../HEADERS/SCENE/Model3D.hpp"
|
#include "Model3D.hpp"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../../GLES_3_1_compatibility.h"
|
#include "../GLES_3_1_compatibility.h"
|
||||||
}
|
}
|
||||||
#include "../../HEADERS/UTILS/OnlyOnce.hpp"
|
#include "../UTILS/OnlyOnce.hpp"
|
||||||
#include "../../HEADERS/UTILS/ShaderMaker.h"
|
#include "../UTILS/ShaderMaker.h"
|
||||||
#include "../../HEADERS/SCENE/objloader.hpp"
|
#include "objloader.hpp"
|
||||||
#include "../../HEADERS/UTILS/ResourceCache.h"
|
#include "../UTILS/ResourceCache.h"
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/SCENE/ObjectInstance.hpp"
|
#include "ObjectInstance.hpp"
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
#define GLM_ENABLE_EXPERIMENTAL
|
#define GLM_ENABLE_EXPERIMENTAL
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/SCENE/ShadingHelper.h"
|
#include "ShadingHelper.h"
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
ShadingHelper::ShadingHelper(GLuint program) {
|
ShadingHelper::ShadingHelper(GLuint program) {
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
#include <vector>
|
extern "C" {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
}
|
||||||
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include "../../HEADERS/SCENE/objloader.hpp"
|
#include "objloader.hpp"
|
||||||
|
|
||||||
// Very, VERY simple OBJ loader.
|
// Very, VERY simple OBJ loader.
|
||||||
// Here is a short list of features a real function would provide :
|
// Here is a short list of features a real function would provide :
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/UTILS/ClockIterator.hpp"
|
#include "ClockIterator.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
ClockIterator::ClockIterator(unsigned int loopMillis) {
|
ClockIterator::ClockIterator(unsigned int loopMillis) {
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class ClockIterator {
|
class ClockIterator {
|
||||||
private:
|
private:
|
||||||
unsigned int max;
|
unsigned int max;
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
#include "../../HEADERS/UTILS/OnlyOnce.hpp"
|
#include "OnlyOnce.hpp"
|
||||||
/*
|
/*
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#ifndef STB_IMAGE_IMPLEMENTATION
|
#ifndef STB_IMAGE_IMPLEMENTATION
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#endif // !STB_IMAGE_IMPLEMENTATION
|
#endif // !STB_IMAGE_IMPLEMENTATION
|
||||||
#include "../../HEADERS/UTILS/stb_image.h"
|
#include "stb_image.h"
|
||||||
|
}
|
||||||
|
|
||||||
GLuint loadImg(const char* path) {
|
GLuint loadImg(const char* path) {
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
5
sources/GL_STUFF/UTILS/OnlyOnce.hpp
Executable file
5
sources/GL_STUFF/UTILS/OnlyOnce.hpp
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
|
||||||
|
GLuint loadImg(const char* path);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "../../HEADERS/UTILS/ResourceCache.h"
|
#include "ResourceCache.h"
|
||||||
#include "../../HEADERS/UTILS/ShaderMaker.h"
|
#include "ShaderMaker.h"
|
||||||
|
|
||||||
ResourceCache::ResourceCache() {
|
ResourceCache::ResourceCache() {
|
||||||
images = map<string, GLuint>();
|
images = map<string, GLuint>();
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "../UTILS/OnlyOnce.hpp"
|
#include "OnlyOnce.hpp"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class ResourceCache {
|
class ResourceCache {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../../HEADERS/UTILS/ShaderMaker.h"
|
#include "ShaderMaker.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@@ -5,6 +5,7 @@ https://stackoverflow.com/questions/38761620/undefined-reference-to-error-while-
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include <GL_STUFF/GLES_3_1_compatibility.h>
|
#include <GL_STUFF/GLES_3_1_compatibility.h>
|
||||||
#include <glut.h>
|
#include <glut.h>
|
||||||
|
#include <glut_extensions.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
@@ -14,31 +15,39 @@ extern "C" {
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <GL_STUFF/HEADERS/CURVES/CurvesLoader.hpp>
|
#include <GL_STUFF/CURVES/CurvesLoader.hpp>
|
||||||
#include <GL_STUFF/HEADERS/SCENE/InstancesLoader.h>
|
#include <GL_STUFF/SCENE/InstancesLoader.h>
|
||||||
#include <GL_STUFF/HEADERS/CURVES/CurveIterator.hpp>
|
#include <GL_STUFF/CURVES/CurveIterator.hpp>
|
||||||
#include <GL_STUFF/HEADERS/SCENE/Camera.hpp>
|
#include <GL_STUFF/SCENE/Camera.hpp>
|
||||||
#include <GL_STUFF/HEADERS/SCENE/Instance3D.h>
|
#include <GL_STUFF/SCENE/Instance3D.h>
|
||||||
#include <GL_STUFF/HEADERS/SCENE/ShadingHelper.h>
|
#include <GL_STUFF/SCENE/ShadingHelper.h>
|
||||||
#include <GL_STUFF/HEADERS/UTILS/ResourceCache.h>
|
#include <GL_STUFF/UTILS/ResourceCache.h>
|
||||||
#include <GL_STUFF/HEADERS/UTILS/ShaderMaker.h>
|
#include <GL_STUFF/UTILS/ShaderMaker.h>
|
||||||
#include <GL_STUFF/HEADERS/UTILS/ClockIterator.hpp>
|
#include <GL_STUFF/UTILS/ClockIterator.hpp>
|
||||||
/* EXCLUDED BC NO COMPUTE SHADERS IN GLES2
|
/* EXCLUDED BC NO COMPUTE SHADERS IN GLES2
|
||||||
#include <GL_STUFF/HEADERS/EFFECTS/CRT_shader.h>
|
#include <GL_STUFF/EFFECTS/CRT_shader.h>
|
||||||
*/
|
*/
|
||||||
#include <GL_STUFF/HEADERS/EFFECTS/ReelManager.h>
|
#include <GL_STUFF/EFFECTS/ReelManager.h>
|
||||||
#include <GL_STUFF/HEADERS/EFFECTS/TexMerger.h>
|
#include <GL_STUFF/EFFECTS/TexMerger.h>
|
||||||
#include <GL_STUFF/HEADERS/EFFECTS/Scene.h>
|
#include <GL_STUFF/EFFECTS/Scene.h>
|
||||||
#include <GL_STUFF/HEADERS/EFFECTS/Screen.h>
|
#include <GL_STUFF/EFFECTS/Screen.h>
|
||||||
|
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const char *RES_FOLDER = "/CGI_DEMO/RESOURCES/";
|
const char *RES_FOLDER = "/home/beno/Desktop/rg552_minimal_dev_env/WAYLAND/demos/rez_demo/resources/"; // "/CGI_DEMO/RESOURCES/";
|
||||||
|
|
||||||
const int TARGET_FPS = 15;
|
const char *devPaths[2] = {
|
||||||
|
"/dev/input/event4",
|
||||||
|
"/dev/input/event5"
|
||||||
|
};
|
||||||
|
|
||||||
|
const int TARGET_FPS = 60;
|
||||||
static int ONE_TICK_MS = 1000 / TARGET_FPS;
|
static int ONE_TICK_MS = 1000 / TARGET_FPS;
|
||||||
|
|
||||||
|
int scrWidth;
|
||||||
|
int scrHeight;
|
||||||
|
|
||||||
float viewSize = 2.0f;
|
float viewSize = 2.0f;
|
||||||
float aspect_ratio;
|
float aspect_ratio;
|
||||||
int steps = 60;
|
int steps = 60;
|
||||||
@@ -78,8 +87,13 @@ bool runIterator = true;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t previous_touches_count = 0;
|
||||||
|
uint8_t current_touches_count = 0;
|
||||||
|
|
||||||
|
touch_event **previous_touches = NULL;
|
||||||
|
touch_event **current_touches = NULL;
|
||||||
|
|
||||||
|
uint8_t touch_rotation = 3; /* it is not always possible to use a calibration matrix for rotating the touchscreen events, 0..3 rotations of 0, 90, 180, 270 */
|
||||||
|
|
||||||
|
|
||||||
/* don't want to implement */
|
/* don't want to implement */
|
||||||
@@ -287,6 +301,14 @@ void renderLoop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void timer(int value) {
|
void timer(int value) {
|
||||||
|
//printf("begin timer buffers are old[%d] %p new[%d] %p\n", previous_touches_count, ( void*) previous_touches, current_touches_count, ( void*) current_touches);
|
||||||
|
//touch_events_array_copy( &previous_touches, current_touches, current_touches_count);
|
||||||
|
previous_touches = current_touches;
|
||||||
|
previous_touches_count = current_touches_count;
|
||||||
|
//printf("after copy buffers are old[%d] %p new[%d] %p\n", previous_touches_count, ( void*) previous_touches, current_touches_count, ( void*) current_touches);
|
||||||
|
glutGetTouchProxy().get_tracked_events( ¤t_touches, ¤t_touches_count);
|
||||||
|
//printf("after updating current buffers are old[%d] %p new[%d] %p\n", previous_touches_count, ( void*) previous_touches, current_touches_count, ( void*) current_touches);
|
||||||
|
|
||||||
cubesClock.step(ONE_TICK_MS);
|
cubesClock.step(ONE_TICK_MS);
|
||||||
cube->rotate(vec3(0, 1, 0), 1);
|
cube->rotate(vec3(0, 1, 0), 1);
|
||||||
if (runIterator) {
|
if (runIterator) {
|
||||||
@@ -300,8 +322,72 @@ void timer(int value) {
|
|||||||
std::cout << "eval at" << iterators[0]->getStep() << "\n";
|
std::cout << "eval at" << iterators[0]->getStep() << "\n";
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
if( previous_touches_count && current_touches_count){
|
||||||
|
/*
|
||||||
|
printf("previous\n");
|
||||||
|
for( uint8_t i = 0; i < previous_touches_count; i++){
|
||||||
|
printf( "%ld\n", previous_touches[i]->tracking_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("current\n");
|
||||||
|
for( uint8_t i = 0; i < current_touches_count; i++){
|
||||||
|
printf( "%ld\n", previous_touches[i]->tracking_id);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
touch_coordinates *touch_pos_deltas;
|
||||||
|
uint8_t touch_pos_deltas_count;
|
||||||
|
//printf( "getting deltas\n");
|
||||||
|
glutGetTouchProxy().get_position_deltas(
|
||||||
|
previous_touches, previous_touches_count,
|
||||||
|
current_touches, current_touches_count,
|
||||||
|
&touch_pos_deltas, &touch_pos_deltas_count
|
||||||
|
);
|
||||||
|
//printf("got deltas\n");
|
||||||
|
if( touch_pos_deltas_count){
|
||||||
|
int64_t x_offset = touch_pos_deltas[0].x;
|
||||||
|
int64_t y_offset = touch_pos_deltas[0].y;
|
||||||
|
int64_t buff_offset;
|
||||||
|
|
||||||
|
switch( touch_rotation % 4){
|
||||||
|
case 0 :
|
||||||
|
break;
|
||||||
|
case 1 :
|
||||||
|
buff_offset = x_offset;
|
||||||
|
x_offset = -y_offset;
|
||||||
|
y_offset = buff_offset;
|
||||||
|
break;
|
||||||
|
case 2 :
|
||||||
|
x_offset = -x_offset;
|
||||||
|
y_offset = -y_offset;
|
||||||
|
break;
|
||||||
|
case 3 :
|
||||||
|
// was x_offset = y_offset, now it is negated and invalidates all the previous remappings
|
||||||
|
buff_offset = x_offset;
|
||||||
|
x_offset = -y_offset;
|
||||||
|
y_offset = -buff_offset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf( "this ass moved X of %ld\n", x_offset);
|
||||||
|
printf( "this ass moved relX of %f\n", (float) x_offset / scrWidth);
|
||||||
|
camera->panX( 100 * ( (float) x_offset / scrWidth) );
|
||||||
|
camera->panY( 100 * ( (float) y_offset / scrHeight) );
|
||||||
|
free_touch_coordinates_buffer( touch_pos_deltas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( previous_touches_count){
|
||||||
|
free_touch_events_array( previous_touches, previous_touches_count);
|
||||||
|
previous_touches = NULL;
|
||||||
|
previous_touches_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
glutTimerFunc(ONE_TICK_MS, timer, 0);
|
glutTimerFunc(ONE_TICK_MS, timer, 0);
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
|
|
||||||
|
// printf("end of timer\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void keypressed(unsigned char key, int x, int y) {
|
void keypressed(unsigned char key, int x, int y) {
|
||||||
@@ -432,13 +518,13 @@ void curveSetup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
glutInit(&argc, argv);
|
glutInit( (char**) devPaths, 2);
|
||||||
glutInitContextVersion(4, 0);
|
glutInitContextVersion(4, 0);
|
||||||
glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
|
glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
|
||||||
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
|
||||||
|
|
||||||
int scrWidth = glutGet(GLUT_SCREEN_WIDTH); //* 5 / 6;
|
scrWidth = glutGet(GLUT_SCREEN_WIDTH); //* 5 / 6;
|
||||||
int scrHeight = glutGet(GLUT_SCREEN_HEIGHT); //* 5 / 6;
|
scrHeight = glutGet(GLUT_SCREEN_HEIGHT); //* 5 / 6;
|
||||||
//scrWidth = 640;
|
//scrWidth = 640;
|
||||||
//scrHeight = 480;
|
//scrHeight = 480;
|
||||||
aspect_ratio = ( (float) scrWidth) / scrHeight;
|
aspect_ratio = ( (float) scrWidth) / scrHeight;
|
||||||
@@ -460,7 +546,7 @@ int main(int argc, char* argv[]) {
|
|||||||
glutPassiveMotionFunc(mousemoved);
|
glutPassiveMotionFunc(mousemoved);
|
||||||
|
|
||||||
/*get the pointers to the missing functions*/
|
/*get the pointers to the missing functions*/
|
||||||
GLES_3_1_compatibility_init();
|
GLES_3_1_comp_init();
|
||||||
|
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
Reference in New Issue
Block a user