├── .clang_complete ├── .gitattributes ├── .gitignore ├── CMakeLists.txt ├── CMakeModules ├── FindAntTweakBar.cmake ├── FindAssimp.cmake ├── FindFreeImage.cmake ├── FindFreeImagePlus.cmake ├── FindGLEW.cmake ├── FindGPUEngine.cmake ├── FindOpenGL.cmake ├── FindOpenThreads.cmake ├── FindQt5.cmake ├── FindSDL2.cmake ├── FindX11.cmake ├── FindgeCore.cmake ├── FindgeGL.cmake ├── FindgeSG.cmake ├── FindgeUtil.cmake ├── Findglfw3.cmake ├── Findglm.cmake ├── Findosg.cmake ├── FindosgDB.cmake └── GEMacros.cmake ├── Doxyfile ├── GPUEngineConfig.cmake.in ├── Readme.md ├── examples ├── CMakeLists.txt ├── Simple_Animation │ └── CMakeLists.txt ├── Simple_QtgeGL │ ├── CMakeLists.txt │ ├── resources │ │ └── shaders │ │ │ ├── red_fs.glsl │ │ │ └── triag_vs.glsl │ └── src │ │ ├── BasicQuickRenderer.cpp │ │ ├── BasicQuickRenderer.h │ │ ├── QuickRendererBase.cpp │ │ ├── QuickRendererBase.h │ │ └── main.cpp └── Simple_QtgeSG │ ├── CMakeLists.txt │ ├── resources │ ├── models │ │ └── texCube │ │ │ ├── black.png │ │ │ ├── texCube.mb │ │ │ ├── texCube.mtl │ │ │ ├── texCube.obj │ │ │ └── white.png │ └── shaders │ │ ├── red_fs.glsl │ │ ├── simple_fs.glsl │ │ └── simple_vs.glsl │ └── src │ ├── GLScene.h │ ├── GLSceneProcessor.cpp │ ├── QuickRendererBase.cpp │ ├── QuickRendererBase.h │ ├── SimpleVT.cpp │ ├── SimpleVT.h │ ├── SimplegeSGRenderer.cpp │ ├── SimplegeSGRenderer.h │ ├── VisualizationTechnique.h │ ├── glsg │ ├── BasicVisualizationTechnique.cpp │ ├── BasicVisualizationTechnique.h │ ├── EnumToGL.cpp │ ├── EnumToGL.h │ ├── GLAttribute.h │ ├── GLScene.h │ ├── GLSceneProcessor.cpp │ ├── GLSceneProcessor.h │ └── MatrixUniformCommands.h │ └── main.cpp ├── geAd ├── AssimpModelLoader │ ├── CMakeLists.txt │ └── src │ │ ├── AssimpModelLoader.cpp │ │ ├── AssimpModelLoader.h │ │ ├── UnicodeIOStream.cpp │ │ ├── UnicodeIOStream.h │ │ ├── UnicodeIOSystem.h │ │ ├── UnicodeIOSystem_other.cpp │ │ └── UnicodeIOSystem_win32.cpp ├── CMakeLists.txt ├── FreeImageImageLoader │ ├── cmake │ │ └── FreeImageImageLoaderConfig.cmake │ └── src │ │ ├── FreeImageImageLoader.cpp │ │ └── FreeImageImageLoader.h ├── QtImageLoader │ ├── CMakeLists.txt │ ├── QtImageLoader.cmake.in │ └── src │ │ ├── QtImageLoader.cpp │ │ └── QtImageLoader.h └── geAd.cmake.in ├── geCore ├── CMakeLists.txt └── src │ └── geCore │ ├── CallStackPrinter.h │ ├── Command.cpp │ ├── Command.h │ ├── Defines.h │ ├── DisjointSet.h │ ├── Dtemplates.cpp │ ├── Dtemplates.h │ ├── ErrorPrinter.h │ ├── Functor.h │ ├── InitAndFinalize.cpp │ ├── InitAndFinalize.h │ ├── Interval.h │ ├── KeyPoint.h │ ├── StandardSemanticsNames.cpp │ ├── StandardSemanticsNames.h │ ├── TypeTraits.h │ ├── Updatable.h │ ├── ValuePrinter.h │ ├── enum_definition.h │ ├── fsa │ ├── Fsa.cpp │ ├── Fsa.h │ ├── FusedCallbackData.cpp │ ├── FusedCallbackData.h │ ├── MapTransitionChooser.h │ ├── MealyMachine.cpp │ ├── MealyMachine.h │ ├── State.cpp │ ├── State.h │ ├── Transition.cpp │ ├── Transition.h │ └── TransitionChooser.h │ └── idlist.h ├── geGL ├── .gitignore ├── .gitrepo ├── CMakeLists.txt ├── README.md ├── scripts │ ├── main.py │ └── subscripts │ │ ├── decomment.py │ │ ├── decorateHeader.py │ │ ├── depreprocess.py │ │ ├── extensionBucketer.py │ │ ├── extractConstants.py │ │ ├── extractTypes.py │ │ ├── generateAllFunction.sh │ │ ├── generateCheckOpenFunctions.py │ │ ├── generateContextCalls.py │ │ ├── generateContextDeclarations.py │ │ ├── generateCoreFunction.py │ │ ├── generateFunctionTableCalls.py │ │ ├── generateFunctions.py │ │ ├── generateLoadFunctions.py │ │ ├── generateLoaderImplementation.py │ │ ├── generateLoaderLoadingCalls.py │ │ ├── generateMemberFunctions.py │ │ ├── generateMemberPFN.py │ │ ├── generateNumberOfFunctions.py │ │ ├── generateOpenGLFunctionCalls.py │ │ ├── generatePFN.py │ │ ├── generateStaticCalls.py │ │ ├── generateStaticDeclarations.py │ │ ├── generateTrapCalls.py │ │ ├── generateTrapImplementation.py │ │ ├── getFunctions.py │ │ ├── glCommand.py │ │ ├── glExtensionFilter.py │ │ ├── glFuncFormater.py │ │ ├── glextractor.py │ │ ├── glwrapper.py │ │ ├── matchbrackes.py │ │ ├── printHEADER.py │ │ ├── skript.sh │ │ └── trapGenerator.py ├── src │ └── geGL │ │ ├── AsynchronousQuery.cpp │ │ ├── AsynchronousQuery.h │ │ ├── Buffer.cpp │ │ ├── Buffer.h │ │ ├── CapabilitiesTableDecorator.h │ │ ├── DSATableDecorator.h │ │ ├── DebugMessage.cpp │ │ ├── DebugMessage.h │ │ ├── DefaultLoader.h │ │ ├── Definitions.h │ │ ├── Framebuffer.cpp │ │ ├── Framebuffer.h │ │ ├── FunctionLoaderInterface.h │ │ ├── Fwd.h │ │ ├── GLSLNoise.cpp │ │ ├── GLSLNoise.h │ │ ├── Generated │ │ ├── ContextCalls.h │ │ ├── ContextDeclarations.h │ │ ├── FunctionTableCalls.h │ │ ├── LoaderImplementation.h │ │ ├── LoaderLoadingCalls.h │ │ ├── MemberOpenGLFunctions.h │ │ ├── MemberOpenGLPFN.h │ │ ├── NumberOfFunctions.h │ │ ├── OpenGLConstants.h │ │ ├── OpenGLFunctions.h │ │ ├── OpenGLPFN.h │ │ ├── OpenGLTypes.h │ │ ├── TrapCalls.h │ │ └── TrapImplementation.h │ │ ├── LoaderTableDecorator.h │ │ ├── OpenGL.cpp │ │ ├── OpenGL.h │ │ ├── OpenGLCapabilities.h │ │ ├── OpenGLContext.cpp │ │ ├── OpenGLContext.h │ │ ├── OpenGLFunctionTable.h │ │ ├── OpenGLObject.cpp │ │ ├── OpenGLObject.h │ │ ├── OpenGLUtil.cpp │ │ ├── OpenGLUtil.h │ │ ├── Program.cpp │ │ ├── Program.h │ │ ├── ProgramInfo.h │ │ ├── ProgramPipeline.cpp │ │ ├── ProgramPipeline.h │ │ ├── Renderbuffer.cpp │ │ ├── Renderbuffer.h │ │ ├── Sampler.cpp │ │ ├── Sampler.h │ │ ├── Shader.cpp │ │ ├── Shader.h │ │ ├── StaticCalls.cpp │ │ ├── StaticCalls.h │ │ ├── Texture.cpp │ │ ├── Texture.h │ │ ├── TrapTableDecorator.h │ │ ├── VertexArray.cpp │ │ ├── VertexArray.h │ │ ├── geGL.cpp │ │ ├── geGL.h │ │ └── private │ │ ├── BufferImpl.cpp │ │ ├── BufferImpl.h │ │ ├── ProgramImpl.h │ │ ├── ShaderImpl.h │ │ ├── VertexArrayImpl.cpp │ │ ├── VertexArrayImpl.h │ │ ├── global.cpp │ │ ├── global.h │ │ ├── linux_OpenGLFunctionLoader.cpp │ │ ├── linux_OpenGLFunctionLoader.h │ │ ├── mac_OpenGLFunctionLoader.cpp │ │ ├── mac_OpenGLFunctionLoader.h │ │ ├── windows_OpenGLFunctionLoader.cpp │ │ └── windows_OpenGLFunctionLoader.h └── tests │ ├── BufferTests.cpp │ ├── CMakeLists.txt │ ├── ComputeShaderTests.cpp │ ├── ProgramTests.cpp │ ├── SDLWin.cpp │ ├── SDLWin.h │ ├── TestsMain.cpp │ ├── blitTests.cpp │ └── catch.hpp ├── geSG ├── CMakeLists.txt ├── geSGConfig.cmake.in └── src │ └── geSG │ ├── AABB.cpp │ ├── AABB.h │ ├── Animation.cpp │ ├── Animation.h │ ├── AnimationChannel.cpp │ ├── AnimationChannel.h │ ├── AnimationKeyFrame.h │ ├── AnimationManager.cpp │ ├── AnimationManager.h │ ├── AttributeDescriptor.h │ ├── BoundingSphere.cpp │ ├── BoundingSphere.h │ ├── BoundingVolume.h │ ├── DefaultImage.cpp │ ├── DefaultImage.h │ ├── EnumToGL.cpp │ ├── EnumToGL.h │ ├── Image.h │ ├── Intersector.h │ ├── KeyframeInterpolator.h │ ├── Light.h │ ├── LightMatrixTransform.cpp │ ├── LightMatrixTransform.h │ ├── Material.h │ ├── MatrixTransform.cpp │ ├── MatrixTransform.h │ ├── MatrixTransformBase.cpp │ ├── MatrixTransformBase.h │ ├── MatrixUniformCommands.h │ ├── Mesh.h │ ├── MeshPrimitiveIterator.h │ ├── MeshTriangleIterators.h │ ├── Model.h │ ├── Node.h │ ├── Ray.h │ ├── RayAABBIntersector.cpp │ ├── RayAABBIntersector.h │ ├── RayMeshIntersector.cpp │ ├── RayMeshIntersector.h │ ├── RaySphereIntersector.cpp │ ├── RaySphereIntersector.h │ ├── RayTriangleIntersector.cpp │ ├── RayTriangleIntersector.h │ ├── Sampler.h │ ├── Scene.h │ ├── TextureObjectCommands.cpp │ ├── TextureObjectCommands.h │ └── Transform.h ├── geUtil ├── CMakeLists.txt ├── geUtilConfig.cmake.in └── src │ └── geUtil │ ├── BasicCamera.cpp │ ├── BasicCamera.h │ ├── CameraInterfaces.h │ ├── FPSPrinter.cpp │ ├── FPSPrinter.h │ ├── ManipulatorInterfaces.h │ ├── MatrixStack.h │ ├── OrbitManipulator.cpp │ ├── OrbitManipulator.h │ ├── Progress.cpp │ ├── Progress.h │ ├── Text.cpp │ ├── Text.h │ └── Timer.h ├── tests ├── CMakeLists.txt ├── animationTest.cpp ├── catch.hpp ├── fsaTest.cpp ├── geRG_test.cpp ├── idlistTest.cpp └── mealyMachineTest.cpp └── version.h.in /.clang_complete: -------------------------------------------------------------------------------- 1 | -I. 2 | -Iinclude/ 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.h text 7 | *.cpp text 8 | *.c text 9 | 10 | # Declare files that will always have CRLF line endings on checkout. 11 | *.sln text eol=crlf 12 | 13 | # Denote all files that are truly binary and should not be modified. 14 | *.png binary 15 | *.jpg binary 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # hidden files 16 | .* 17 | 18 | # binaries 19 | *.exe 20 | *.bin 21 | 22 | # cmake and other build files 23 | CMakeCache.txt 24 | CMakeFiles 25 | Makefile 26 | cmake_install.cmake 27 | install_manifest.txt 28 | *.kdev4 29 | /doc/ 30 | /build*/ 31 | include/geCore/Export.h 32 | include/geGL/Export.h 33 | include/geRG/Export.h 34 | include/geSG/Export.h 35 | include/geUtil/Export.h 36 | include/geDE/Export.h 37 | include/geParser/Export.h 38 | geAd/SDLWindow/Export.h 39 | geAd/Export.h 40 | -------------------------------------------------------------------------------- /CMakeModules/FindAntTweakBar.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Module for finding AntTweakBar 3 | # 4 | # The module will define: 5 | # AntTweakBar_FOUND - True if AntTweakBar development files were found 6 | # ANTTWEAKBAR_INCLUDE_DIR - AntTweakBar include directories 7 | # ANTTWEAKBAR_LIBRARY - AntTweakBar libraries to link 8 | # 9 | # AntTweakBar target will be created for cmake 3.0.0 and newer 10 | # 11 | 12 | 13 | # try config-based find first 14 | find_package(${CMAKE_FIND_PACKAGE_NAME} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG QUIET) 15 | 16 | # use regular old-style approach 17 | if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND) 18 | 19 | find_path(ANTTWEAKBAR_INCLUDE_DIR AntTweakBar.h 20 | DOC "Path to AntTweakBar include directory." 21 | HINTS $ENV{ANTTWEAKBAR_ROOT} 22 | PATH_SUFFIX include # For finding the include file under the root of the glfw expanded archive, typically on Windows. 23 | PATHS /usr/include/ 24 | /usr/local/include/ 25 | ${ANTTWEAKBAR_ROOT_DIR}/include/ 26 | ${CMAKE_SOURCE_DIR}/extlibs/headers 27 | ) 28 | 29 | find_library(ANTTWEAKBAR_LIBRARY 30 | DOC "Absolute path to AntTweakBar library." 31 | NAMES AntTweakBar 32 | HINTS $ENV{ANTTWEAKBAR_ROOT} 33 | PATH_SUFFIXES lib/win32 # For finding the library file under the root of the glfw expanded archive, typically on Windows. 34 | PATHS /usr/local/lib 35 | /usr/lib 36 | ${ANTTWEAKBAR_ROOT_DIR}/lib-msvc100/release 37 | ) 38 | 39 | # set *_FOUND flag 40 | if(ANTTWEAKBAR_INCLUDE_DIR AND ANTTWEAKBAR_LIBRARY) 41 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND True) 42 | endif() 43 | 44 | # target for cmake 3.0.0 and newer 45 | if(${CMAKE_FIND_PACKAGE_NAME}_FOUND) 46 | if(NOT ${CMAKE_MAJOR_VERSION} LESS 3) 47 | if(NOT TARGET ${CMAKE_FIND_PACKAGE_NAME}) 48 | add_library(${CMAKE_FIND_PACKAGE_NAME} INTERFACE IMPORTED) 49 | set_target_properties(${CMAKE_FIND_PACKAGE_NAME} PROPERTIES 50 | INTERFACE_INCLUDE_DIRECTORIES "${ANTTWEAKBAR_INCLUDE_DIR}" 51 | INTERFACE_LINK_LIBRARIES "${ANTTWEAKBAR_LIBRARY}" 52 | ) 53 | endif() 54 | endif() 55 | endif() 56 | 57 | endif() 58 | 59 | # message 60 | include(GEMacros OPTIONAL RESULT_VARIABLE ge_macros_file) 61 | if(ge_macros_file) 62 | ge_report_find_status() 63 | endif() -------------------------------------------------------------------------------- /CMakeModules/FindFreeImage.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Module for finding FreeImage 3 | # 4 | # The module will define: 5 | # FreeImage_FOUND - True if FreeImage development files were found 6 | # FREEIMAGE_INCLUDE_DIR - FreeImage include directories 7 | # FREEIMAGE_LIBRARY - FreeImage libraries to link 8 | # 9 | # FreeImage target will be created for cmake 3.0.0 and newer 10 | # 11 | 12 | 13 | # try config-based find first 14 | find_package(${CMAKE_FIND_PACKAGE_NAME} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG QUIET) 15 | 16 | # use regular old-style approach 17 | if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND) 18 | 19 | if(WIN32) 20 | 21 | find_path(FREEIMAGE_INCLUDE_DIR FreeImage.h 22 | ${FREEIMAGE_ROOT_DIR}/include 23 | ${FREEIMAGE_ROOT_DIR} 24 | DOC "The directory where FreeImage.h resides") 25 | 26 | find_library(FREEIMAGE_LIBRARY 27 | NAMES FreeImage freeimage 28 | PATHS 29 | ${FREEIMAGE_ROOT_DIR}/lib 30 | ${FREEIMAGE_ROOT_DIR} 31 | DOC "The FreeImage library") 32 | 33 | else() 34 | 35 | find_path(FREEIMAGE_INCLUDE_DIR FreeImage.h 36 | /usr/include 37 | /usr/local/include 38 | /sw/include 39 | /opt/local/include 40 | DOC "The directory where FreeImage.h resides") 41 | 42 | find_library(FREEIMAGE_LIBRARY 43 | NAMES FreeImage freeimage 44 | PATHS 45 | /usr/lib64 46 | /usr/lib 47 | /usr/local/lib64 48 | /usr/local/lib 49 | /sw/lib 50 | /opt/local/lib 51 | DOC "The FreeImage library") 52 | 53 | endif() 54 | 55 | # set *_FOUND flag 56 | if(FREEIMAGE_INCLUDE_DIR AND FREEIMAGE_LIBRARY) 57 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND True) 58 | endif() 59 | 60 | # target for cmake 3.0.0 and newer 61 | if(${CMAKE_FIND_PACKAGE_NAME}_FOUND) 62 | if(NOT ${CMAKE_MAJOR_VERSION} LESS 3) 63 | if(NOT TARGET ${CMAKE_FIND_PACKAGE_NAME}) 64 | add_library(${CMAKE_FIND_PACKAGE_NAME} INTERFACE IMPORTED) 65 | set_target_properties(${CMAKE_FIND_PACKAGE_NAME} PROPERTIES 66 | INTERFACE_INCLUDE_DIRECTORIES "${FREEIMAGE_INCLUDE_DIR}" 67 | INTERFACE_LINK_LIBRARIES "${FREEIMAGE_LIBRARY}" 68 | ) 69 | endif() 70 | endif() 71 | endif() 72 | 73 | endif() 74 | 75 | # message 76 | include(GEMacros OPTIONAL RESULT_VARIABLE ge_macros_file) 77 | if(ge_macros_file) 78 | ge_report_find_status() 79 | endif() -------------------------------------------------------------------------------- /CMakeModules/FindFreeImagePlus.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Module for finding FreeImagePlus 3 | # 4 | # The module will define: 5 | # FreeImagePlus_FOUND - True if FreeImagePlus development files were found 6 | # FREEIMAGEPLUS_INCLUDE_DIR - FreeImagePlus include directories 7 | # FREEIMAGEPLUS_LIBRARY - FreeImagePlus libraries to link 8 | # 9 | # FreeImagePlus target will be created for cmake 3.0.0 and newer 10 | # 11 | 12 | 13 | # try config-based find first 14 | find_package(${CMAKE_FIND_PACKAGE_NAME} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG QUIET) 15 | 16 | # use regular old-style approach 17 | if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND) 18 | 19 | if(WIN32) 20 | 21 | find_path(FREEIMAGEPLUS_INCLUDE_DIR FreeImagePlus.h 22 | ${FREEIMAGEPLUS_ROOT_DIR}/include 23 | ${FREEIMAGEPLUS_ROOT_DIR} 24 | DOC "The directory where FreeImagePlus.h resides") 25 | 26 | find_library(FREEIMAGEPLUS_LIBRARY 27 | NAMES FreeImagePlus freeimageplus 28 | PATHS 29 | ${FREEIMAGEPLUS_ROOT_DIR}/lib 30 | ${FREEIMAGEPLUS_ROOT_DIR} 31 | DOC "The FreeImagePlus library") 32 | 33 | else() 34 | 35 | find_path(FREEIMAGEPLUS_INCLUDE_DIR FreeImagePlus.h 36 | /usr/include 37 | /usr/local/include 38 | /sw/include 39 | /opt/local/include 40 | DOC "The directory where FreeImagePlus.h resides") 41 | 42 | find_library(FREEIMAGEPLUS_LIBRARY 43 | NAMES FreeImagePlus freeimageplus 44 | PATHS 45 | /usr/lib64 46 | /usr/lib 47 | /usr/local/lib64 48 | /usr/local/lib 49 | /sw/lib 50 | /opt/local/lib 51 | DOC "The FreeImagePlus library") 52 | 53 | endif() 54 | 55 | # set *_FOUND flag 56 | if(FREEIMAGEPLUS_INCLUDE_DIR AND FREEIMAGEPLUS_LIBRARY) 57 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND True) 58 | endif() 59 | 60 | # target for cmake 3.0.0 and newer 61 | if(${CMAKE_FIND_PACKAGE_NAME}_FOUND) 62 | if(NOT ${CMAKE_MAJOR_VERSION} LESS 3) 63 | if(NOT TARGET ${CMAKE_FIND_PACKAGE_NAME}) 64 | add_library(${CMAKE_FIND_PACKAGE_NAME} INTERFACE IMPORTED) 65 | set_target_properties(${CMAKE_FIND_PACKAGE_NAME} PROPERTIES 66 | INTERFACE_INCLUDE_DIRECTORIES "${FREEIMAGEPLUS_INCLUDE_DIR}" 67 | INTERFACE_LINK_LIBRARIES "${FREEIMAGEPLUS_LIBRARY}" 68 | ) 69 | endif() 70 | endif() 71 | endif() 72 | 73 | endif() 74 | 75 | # message 76 | include(GEMacros OPTIONAL RESULT_VARIABLE ge_macros_file) 77 | if(ge_macros_file) 78 | ge_report_find_status() 79 | endif() -------------------------------------------------------------------------------- /CMakeModules/FindGPUEngine.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # General GPUEngine find module used by internal cross package dependencies (eg. for geRG to find geGL which is standalone module) 3 | # 4 | 5 | foreach(module ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS}) 6 | find_package(${module} ${FIND_QUIETLY} MODULE) 7 | endforeach() -------------------------------------------------------------------------------- /CMakeModules/FindQt5.cmake: -------------------------------------------------------------------------------- 1 | # GPUEngine Qt5 find wrapper 2 | 3 | find_package(${CMAKE_FIND_PACKAGE_NAME} COMPONENTS ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} CONFIG QUIET) 4 | 5 | if(${${CMAKE_FIND_PACKAGE_NAME}_FOUND} AND NOT TARGET ${CMAKE_FIND_PACKAGE_NAME}) 6 | add_library(${CMAKE_FIND_PACKAGE_NAME} INTERFACE) 7 | foreach(_mod ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS}) 8 | list(APPEND qt5Targets "Qt5::${_mod}") 9 | endforeach() 10 | target_link_libraries(${CMAKE_FIND_PACKAGE_NAME} INTERFACE ${qt5Targets}) 11 | endif() 12 | 13 | # message 14 | include(GEMacros OPTIONAL RESULT_VARIABLE ge_macros_file) 15 | if(ge_macros_file) 16 | ge_report_find_status() 17 | endif() -------------------------------------------------------------------------------- /CMakeModules/FindgeCore.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Internal Find geCore module 3 | # 4 | 5 | if(TARGET ${CMAKE_FIND_PACKAGE_NAME}) 6 | set(${${CMAKE_FIND_PACKAGE_NAME}_FOUND} true) 7 | else() 8 | message("Cannot find ${CMAKE_FIND_PACKAGE_NAME} package") 9 | endif() 10 | -------------------------------------------------------------------------------- /CMakeModules/FindgeGL.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Internal Find for GPUE module 3 | # 4 | 5 | if(TARGET ${CMAKE_FIND_PACKAGE_NAME}) 6 | set(${${CMAKE_FIND_PACKAGE_NAME}_FOUND} true) 7 | else() 8 | message("Cannot find ${CMAKE_FIND_PACKAGE_NAME} package. Configure Cmake to build it.") 9 | endif() 10 | -------------------------------------------------------------------------------- /CMakeModules/FindgeSG.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Internal Find for GPUE module 3 | # 4 | 5 | if(TARGET ${CMAKE_FIND_PACKAGE_NAME}) 6 | set(${${CMAKE_FIND_PACKAGE_NAME}_FOUND} true) 7 | else() 8 | message("Cannot find ${CMAKE_FIND_PACKAGE_NAME} package. Configure Cmake to build it.") 9 | endif() 10 | -------------------------------------------------------------------------------- /CMakeModules/FindgeUtil.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Internal Find geUtil module 3 | # 4 | 5 | if(TARGET ${CMAKE_FIND_PACKAGE_NAME}) 6 | set(${${CMAKE_FIND_PACKAGE_NAME}_FOUND} true) 7 | else() 8 | message("Cannot find ${CMAKE_FIND_PACKAGE_NAME} package. Configure Cmake to build it by checking the GPUENGINE_BUILD_GEUTIL option.") 9 | endif() 10 | -------------------------------------------------------------------------------- /CMakeModules/Findglm.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Module for finding GLM 3 | # 4 | # The module will define: 5 | # glm_FOUND - True if GLM development files were found 6 | # GLM_INCLUDE_DIR - GLM include directories 7 | # GLM_LIBRARY - GLM libraries to link 8 | # 9 | # glm target will be created for cmake 3.0.0 and newer 10 | # 11 | 12 | 13 | # try config-based find first 14 | # (this provides target glm (tested on GLM version 0.9.7.0)) 15 | find_package(${CMAKE_FIND_PACKAGE_NAME} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG QUIET) 16 | 17 | if(${CMAKE_FIND_PACKAGE_NAME}_FOUND) 18 | if(TARGET glm::glm) 19 | add_library(glm ALIAS glm::glm) 20 | set(TARGET_NAME glm::glm) 21 | endif() 22 | endif() 23 | 24 | # use regular old-style approach 25 | if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND) 26 | 27 | find_path(GLM_INCLUDE_DIR glm/glm.hpp 28 | /usr/include 29 | /usr/local/include 30 | /opt/local/include 31 | ) 32 | 33 | # set *_FOUND flag 34 | if(GLM_INCLUDE_DIR) 35 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND True) 36 | endif() 37 | 38 | # target for cmake 3.0.0 and newer 39 | if(${CMAKE_FIND_PACKAGE_NAME}_FOUND) 40 | if(NOT ${CMAKE_MAJOR_VERSION} LESS 3) 41 | if(NOT TARGET ${CMAKE_FIND_PACKAGE_NAME}) 42 | set(TARGET_NAME glm) 43 | add_library(${CMAKE_FIND_PACKAGE_NAME} INTERFACE IMPORTED) 44 | set_target_properties(${CMAKE_FIND_PACKAGE_NAME} PROPERTIES 45 | INTERFACE_INCLUDE_DIRECTORIES "${GLM_INCLUDE_DIR}" 46 | ) 47 | endif() 48 | endif() 49 | endif() 50 | 51 | endif() 52 | 53 | if(TARGET ${TARGET_NAME}) 54 | set_property(TARGET ${TARGET_NAME} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "GLM_ENABLE_EXPERIMENTAL") 55 | endif() 56 | 57 | # message 58 | include(GEMacros OPTIONAL RESULT_VARIABLE ge_macros_file) 59 | if(ge_macros_file) 60 | ge_report_find_status() 61 | endif() 62 | -------------------------------------------------------------------------------- /GPUEngineConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for the GPUEngine package 2 | # Additional variables: 3 | # GPUEngine_modules - list of all found GPUEngine modules including the dependencies 4 | @INIT_PACKAGE@ 5 | include(CMakeFindDependencyMacro) 6 | 7 | list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/CMakeModules") 8 | 9 | foreach(module ${GPUEngine_FIND_COMPONENTS}) 10 | find_dependency(${module} 11 | HINTS 12 | "${CMAKE_CURRENT_LIST_DIR}/../" 13 | "${CMAKE_CURRENT_LIST_DIR}/../geAd" 14 | NO_DEFAULT_PATH 15 | ) 16 | endforeach() 17 | 18 | list(REMOVE_AT CMAKE_MODULE_PATH 0) -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(examples_folder_name "examples") 2 | 3 | set(examplesList Simple_QtgeGL 4 | Simple_QtgeSG 5 | Simple_Animation 6 | ) 7 | 8 | foreach(example IN LISTS examplesList) 9 | add_subdirectory(${example}) 10 | endforeach() 11 | 12 | message(STATUS "Examples configured:") 13 | 14 | foreach(example IN LISTS examplesList) 15 | if(TARGET ${example}) 16 | message(STATUS " ${example}") 17 | endif() 18 | endforeach() 19 | -------------------------------------------------------------------------------- /examples/Simple_Animation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | set(PROJECT_NAME "Simple_Animation") 4 | set(APP_NAME "Simple_Animation") 5 | 6 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 7 | 8 | SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows") 9 | SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows") 10 | SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows") 11 | SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows") 12 | 13 | if(NOT TARGET geSG) 14 | find_package(GPUEngine COMPONENTS geSG) 15 | endif() 16 | 17 | if(NOT TARGET geSG) 18 | return() 19 | endif() 20 | 21 | set(HEADER_PATH src) 22 | set(SOURCE_PATH src) 23 | get_filename_component(src_abs ${SOURCE_PATH} ABSOLUTE) 24 | 25 | set(SOURCE_FILES 26 | ${GPUEngine_SOURCE_DIR}/tests/animationTest.cpp 27 | ) 28 | 29 | 30 | add_executable(${APP_NAME} ${SOURCE_FILES}) 31 | target_link_libraries(${APP_NAME} geSG) 32 | set_property(TARGET ${APP_NAME} PROPERTY FOLDER "${examples_folder_name}") -------------------------------------------------------------------------------- /examples/Simple_QtgeGL/resources/shaders/red_fs.glsl: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | out vec4 fragColor; 4 | 5 | void main() 6 | { 7 | fragColor = vec4(0.8, 0, 0, 1); 8 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeGL/resources/shaders/triag_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | void main() 4 | { 5 | if(gl_VertexID == 0) 6 | { 7 | gl_Position = vec4(-0.5, 0.5, 0, 1); 8 | } 9 | else if(gl_VertexID == 1) 10 | { 11 | gl_Position = vec4(0.5, 0.5, 0, 1); 12 | } 13 | else 14 | { 15 | gl_Position = vec4(0.5, -0.5, 0, 1); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeGL/src/BasicQuickRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace ge 8 | { 9 | namespace gl 10 | { 11 | class Program; 12 | class VertexArray; 13 | class Context; 14 | } 15 | } 16 | 17 | namespace fsg 18 | { 19 | /** 20 | * Basic example of renderer class. It loads external shaders and draw simple triangle. 21 | */ 22 | class BasicQuickRenderer : public QuickRendererBase 23 | { 24 | Q_OBJECT 25 | public: 26 | BasicQuickRenderer(QObject * parent = 0); 27 | 28 | protected: 29 | void update(); 30 | void setupGLstate(); 31 | void draw(); 32 | 33 | std::shared_ptr gl; 34 | std::shared_ptr triagProgram; 35 | std::shared_ptr dummyVAO; 36 | 37 | 38 | public slots: 39 | virtual void beforeRendering() override; 40 | virtual void onOGLContextCreated(QOpenGLContext * context) override; 41 | }; 42 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeGL/src/QuickRendererBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | /** 8 | * This class provides basic setup for rendering in Qt Quick. It is intended to use with QQuickWindow. 9 | * For rendering just subclass from this and reimplement virtual functions you need. You should set 10 | * parent to window you want to render to. The connections are automaticaly made when calling setParentWindow. 11 | * Old connections are disconected and new ones are created when the argument is not null. 12 | */ 13 | class QuickRendererBase : public QObject 14 | { 15 | Q_OBJECT 16 | public: 17 | 18 | QuickRendererBase(QObject * parent = 0); 19 | 20 | void setParentWindow(QQuickWindow * qqw); 21 | inline QQuickWindow *parentWindow() { return _qqw; } 22 | public slots: 23 | virtual void beforeRendering(); 24 | virtual void onOGLContextCreated(QOpenGLContext * context); 25 | virtual void onSceneGraphInvalidated(); 26 | virtual void onFrameSwapped(); 27 | protected: 28 | QQuickWindow *_qqw; 29 | }; -------------------------------------------------------------------------------- /examples/Simple_QtgeGL/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int main(int argc, char** argv) 6 | { 7 | QGuiApplication app(argc, argv); 8 | 9 | QQuickWindow qw; 10 | qw.resize(800, 600); 11 | 12 | /* The ownership is transfered to QQuickWindow in the constructor 13 | * and to Qt's are responsible for deleting it. 14 | * http://doc.qt.io/qt-5/qobject.html#dtor.QObject 15 | */ 16 | new fsg::BasicQuickRenderer(&qw); 17 | 18 | 19 | qw.show(); 20 | 21 | return app.exec(); 22 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/models/texCube/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rendering-FIT/GPUEngine/b1ed2d51be39e6d1c409c530e9e0c834b26d9d9c/examples/Simple_QtgeSG/resources/models/texCube/black.png -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/models/texCube/texCube.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rendering-FIT/GPUEngine/b1ed2d51be39e6d1c409c530e9e0c834b26d9d9c/examples/Simple_QtgeSG/resources/models/texCube/texCube.mb -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/models/texCube/texCube.mtl: -------------------------------------------------------------------------------- 1 | newmtl phong1SG 2 | illum 4 3 | Kd 1.0 1.00 1.00 4 | Ka 0.0 0.00 0.00 5 | Tf 1.00 1.00 1.00 6 | map_Kd black.png 7 | Ni 1.00 8 | Ks 0.50 0.50 0.50 9 | Ns 18.00 10 | newmtl phong2SG 11 | illum 4 12 | Kd 0.00 1.00 1.00 13 | Ka 0.00 0.00 0.00 14 | Tf 1.00 1.00 1.00 15 | map_Kd white.png 16 | Ni 1.00 17 | Ks 0.50 0.50 0.50 18 | Ns 18.00 19 | -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/models/texCube/texCube.obj: -------------------------------------------------------------------------------- 1 | # This file uses centimeters as units for non-parametric coordinates. 2 | 3 | mtllib texCube.mtl 4 | g default 5 | v -1.000000 0.000000 1.000000 6 | v 1.000000 0.000000 1.000000 7 | v -1.000000 2.000000 1.000000 8 | v 1.000000 2.000000 1.000000 9 | v -1.000000 2.000000 -1.000000 10 | v 1.000000 2.000000 -1.000000 11 | v -1.000000 0.000000 -1.000000 12 | v 1.000000 0.000000 -1.000000 13 | vt 0.000000 0.000000 14 | vt 1.000000 0.000000 15 | vt 0.000000 -0.000000 16 | vt 1.000000 -0.000000 17 | vt 1.000000 1.000000 18 | vt 0.000000 1.000000 19 | vt 0.000000 1.000000 20 | vt 1.000000 1.000000 21 | vt 1.000000 0.000000 22 | vt 0.000000 0.000000 23 | vt 0.000000 0.000000 24 | vt 1.000000 0.000000 25 | vt 1.000000 1.000000 26 | vt 0.000000 1.000000 27 | vt 1.000000 0.000000 28 | vt 0.000000 0.000000 29 | vt 0.000000 1.000000 30 | vt 1.000000 1.000000 31 | vt 1.000000 1.000000 32 | vt 0.000000 1.000000 33 | vt 0.000000 1.000000 34 | vt 1.000000 1.000000 35 | vt 1.000000 0.000000 36 | vt 0.000000 0.000000 37 | vn 0.000000 0.000000 1.000000 38 | vn 0.000000 0.000000 1.000000 39 | vn 0.000000 0.000000 1.000000 40 | vn 0.000000 0.000000 1.000000 41 | vn 0.000000 1.000000 0.000000 42 | vn 0.000000 1.000000 0.000000 43 | vn 0.000000 1.000000 0.000000 44 | vn 0.000000 1.000000 0.000000 45 | vn 0.000000 0.000000 -1.000000 46 | vn 0.000000 0.000000 -1.000000 47 | vn 0.000000 0.000000 -1.000000 48 | vn 0.000000 0.000000 -1.000000 49 | vn 0.000000 -1.000000 0.000000 50 | vn 0.000000 -1.000000 0.000000 51 | vn 0.000000 -1.000000 0.000000 52 | vn 0.000000 -1.000000 0.000000 53 | vn 1.000000 0.000000 0.000000 54 | vn 1.000000 0.000000 0.000000 55 | vn 1.000000 0.000000 0.000000 56 | vn 1.000000 0.000000 0.000000 57 | vn -1.000000 0.000000 0.000000 58 | vn -1.000000 0.000000 0.000000 59 | vn -1.000000 0.000000 0.000000 60 | vn -1.000000 0.000000 0.000000 61 | s off 62 | g pCube1 63 | usemtl phong2SG 64 | f 1/1/1 2/2/2 4/19/3 3/20/4 65 | usemtl phong1SG 66 | f 3/3/5 4/4/6 6/5/7 5/6/8 67 | f 5/21/9 6/22/10 8/23/11 7/24/12 68 | f 7/7/13 8/8/14 2/9/15 1/10/16 69 | usemtl phong2SG 70 | f 2/11/17 8/12/18 6/13/19 4/14/20 71 | f 7/15/21 1/16/22 3/17/23 5/18/24 72 | -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/models/texCube/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rendering-FIT/GPUEngine/b1ed2d51be39e6d1c409c530e9e0c834b26d9d9c/examples/Simple_QtgeSG/resources/models/texCube/white.png -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/shaders/red_fs.glsl: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | out vec4 fragColor; 4 | 5 | void main() 6 | { 7 | fragColor = vec4(0.8, 0, 0, 1); 8 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/shaders/simple_fs.glsl: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | layout(location=0)out vec4 fragColor; 4 | 5 | uniform layout(binding = 0) sampler2D diffTex; 6 | 7 | uniform vec4 color; 8 | 9 | in vec2 uv; 10 | 11 | void main() 12 | { 13 | fragColor = texture(diffTex,uv) * color; 14 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/resources/shaders/simple_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | layout(location=0) in vec3 pos; 4 | layout(location = 2) in vec2 texcoords; 5 | 6 | uniform mat4 projection; 7 | uniform mat4 model; 8 | 9 | out vec2 uv; 10 | 11 | void main(){ 12 | uv = texcoords; 13 | gl_Position = projection * model * vec4(pos,1.0); 14 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/GLScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | namespace ge 9 | { 10 | namespace gl{ 11 | class TextureObject; 12 | } 13 | 14 | namespace sg 15 | { 16 | class MaterialImageComponent; 17 | class Mesh; 18 | class Scene; 19 | } 20 | 21 | namespace glsg 22 | { 23 | /** 24 | * Maps geSG Scene Meshes and Images to geGL provided structures. 25 | * This class provides the link between implementation independent scene graph 26 | * and OpenGL. 27 | * Meshes are mapped to a collection of GLAttributes and MaterialImageComponents 28 | * are mapped to ge::gl::TextureObjects 29 | * This class is just a data conatiner. Management needs to be provided elsewhere. 30 | */ 31 | class GLScene 32 | { 33 | public: 34 | typedef std::vector GLAttribArray; 35 | 36 | GLScene() : scene(nullptr){} 37 | 38 | std::shared_ptr scene; 39 | std::unordered_map GLMeshes; 40 | std::unordered_map> textures; 41 | }; 42 | } 43 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/QuickRendererBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | /** 8 | * This class provides basic setup for rendering in Qt Quick. It is intended to use with QQuickWindow. 9 | * For rendering just subclass from this and reimplement virtual functions you need. You should set 10 | * parent to window you want to render to. The connections are automaticaly made when calling setParentWindow. 11 | * Old connections are disconected and new ones are created when the argument is not null. 12 | */ 13 | class QuickRendererBase : public QObject 14 | { 15 | Q_OBJECT 16 | public: 17 | 18 | QuickRendererBase(QObject * parent = 0); 19 | 20 | void setParentWindow(QQuickWindow * qqw); 21 | inline QQuickWindow *parentWindow() { return _qqw; } 22 | public slots: 23 | virtual void beforeRendering(); 24 | virtual void onOGLContextCreated(QOpenGLContext * context); 25 | virtual void onSceneGraphInvalidated(); 26 | virtual void onFrameSwapped(); 27 | protected: 28 | QQuickWindow *_qqw; 29 | }; -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/SimpleVT.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | 11 | namespace ge 12 | { 13 | namespace gl 14 | { 15 | class Texture; 16 | class Context; 17 | class VertexArray; 18 | class Program; 19 | } 20 | namespace sg { 21 | class Scene; 22 | class Mesh; 23 | class Material; 24 | } 25 | namespace glsg 26 | { 27 | class GLScene; 28 | } 29 | } 30 | 31 | namespace fsg 32 | { 33 | /** 34 | * This VT is used to simply draw a textured object. It only uses positions and normals. 35 | * The shaders needs vertices vec3 on 0 and texcoords vec2 on 2 position. You can inspect 36 | * the shaders in resource directory of this example. 37 | * The usage of the VT is to supply the GLScene, then call the processScene. Once this is done 38 | * you can call drawSetup and draw each frame. You need to have OpenGL context active. 39 | */ 40 | class SimpleVT : public VisualizationTechnique 41 | { 42 | public: 43 | virtual void setScene(std::shared_ptr& scene); 44 | virtual void processScene(); 45 | void drawSetup() override; 46 | void draw() override; 47 | 48 | static int semantic2Attribute(ge::sg::AttributeDescriptor::Semantic semantic); 49 | 50 | std::shared_ptr gl; 51 | std::shared_ptr program; 52 | 53 | protected: 54 | std::shared_ptr glscene; 55 | std::unordered_map> VAOContainer; 56 | std::unordered_map> colorContainer; 57 | std::unordered_map> diffuseTextureConatiner; 58 | 59 | }; 60 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/SimplegeSGRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | 8 | namespace ge{ 9 | namespace glsg{ 10 | class GLScene; 11 | } 12 | 13 | namespace gl{ 14 | class Context; 15 | } 16 | namespace sg 17 | { 18 | class Scene; 19 | } 20 | } 21 | 22 | namespace fsg 23 | { 24 | class SimpleVT; 25 | 26 | class SimplegeSGRenderer : public QuickRendererBase 27 | { 28 | Q_OBJECT 29 | public: 30 | SimplegeSGRenderer(QObject * parent = 0); 31 | void setupGLState(); 32 | public slots: 33 | virtual void beforeRendering() override; 34 | virtual void onOGLContextCreated(QOpenGLContext * context) override; 35 | virtual void setScene(std::shared_ptr& loadedScene); 36 | 37 | protected: 38 | virtual void update(); 39 | 40 | 41 | std::shared_ptr gl; 42 | std::shared_ptr scene; 43 | std::shared_ptr glscene; 44 | std::shared_ptr VT; 45 | bool _needToProcessScene; 46 | }; 47 | 48 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/VisualizationTechnique.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ge{ 4 | namespace sg{ 5 | class MatrixTransform; 6 | class Material; 7 | class Mesh; 8 | } 9 | } 10 | 11 | namespace fsg 12 | { 13 | /** 14 | * Base class for Visualization techniques (VT). VTs are used to visualize something, mainly 15 | * the scene graph or some part of scene in some user pre defined way. VT could stand for visualizing 16 | * the ge::sg::Scene (or some processed variation such as ge::glsg::GLScene) via phong shading. It could 17 | * be use to render skybox without even knowing the scene etc. 18 | * The VTs are the corner stones of visualization. The rendering part of frame should be a sequence of 19 | * VT::draw() calls. 20 | */ 21 | class VisualizationTechnique 22 | { 23 | public: 24 | virtual void drawSetup() = 0; 25 | virtual void draw() = 0; 26 | 27 | virtual ~VisualizationTechnique() 28 | { 29 | } 30 | }; 31 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/glsg/EnumToGL.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace ge 9 | { 10 | namespace glsg 11 | { 12 | GLuint semnatic2Attribute(unsigned semantic); 13 | GLenum translateEnum(ge::sg::AttributeDescriptor::DataType type); 14 | GLenum translateEnum(ge::sg::Image::DataType type); 15 | GLenum translateEnum(ge::sg::Image::Format type); 16 | GLenum translateEnum(ge::sg::Mesh::PrimitiveType type); 17 | } 18 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/glsg/GLAttribute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | namespace ge 7 | { 8 | namespace gl 9 | { 10 | class Buffer; 11 | } 12 | 13 | namespace sg{ 14 | struct AttributeDescriptor; 15 | } 16 | } 17 | 18 | namespace ge 19 | { 20 | namespace glsg 21 | { 22 | /** 23 | * Class pairing ge::sg::AttributeDescriptor with its ge::gl::Buffer representation. 24 | * Used by GLScene class. 25 | */ 26 | class GLAttribute 27 | { 28 | public: 29 | GLAttribute() : attributeDescriptor(nullptr), BO(nullptr){} 30 | GLAttribute(std::shared_ptr ad, std::shared_ptr buff) : attributeDescriptor(ad), BO(buff){} 31 | 32 | std::shared_ptr attributeDescriptor; 33 | std::shared_ptr BO; 34 | }; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/glsg/GLScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | namespace ge 9 | { 10 | namespace gl{ 11 | class Texture; 12 | } 13 | 14 | namespace sg 15 | { 16 | class MaterialImageComponent; 17 | class Mesh; 18 | class Scene; 19 | } 20 | 21 | namespace glsg 22 | { 23 | /** 24 | * Maps geSG Scene Meshes and Images to geGL provided structures. 25 | * This class provides the link between implementation independent scene graph 26 | * and OpenGL. 27 | * Meshes are mapped to a collection of GLAttributes and MaterialImageComponents 28 | * are mapped to ge::gl::TextureObjects 29 | * This class is just a data conatiner. Management needs to be provided elsewhere. 30 | */ 31 | class GLScene 32 | { 33 | public: 34 | typedef std::vector GLAttribArray; 35 | 36 | GLScene() : scene(nullptr){} 37 | 38 | std::shared_ptr scene; ///< The original scene 39 | std::unordered_map GLMeshes; ///< Dictionary connecting mesh with its GLAttribArray 40 | std::unordered_map> textures; ///< Dictionary connecting MaterialImageComponent with Texture 41 | }; 42 | } 43 | } -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/glsg/MatrixUniformCommands.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ge 8 | { 9 | namespace core 10 | { 11 | template 12 | inline TYPE convertTo(glm::mat4& mat){ 13 | return glm::value_ptr(mat); 14 | } 15 | 16 | template 17 | inline TYPE convertTo(std::shared_ptr& mat){ 18 | return glm::value_ptr(*mat); 19 | } 20 | 21 | template 22 | inline TYPE convertTo(glm::vec4& vec4){ 23 | return glm::value_ptr(vec4); 24 | } 25 | 26 | template 27 | inline TYPE convertTo(std::shared_ptr& vec4){ 28 | return glm::value_ptr(*vec4); 29 | } 30 | } 31 | } 32 | 33 | namespace fsg{ 34 | 35 | typedef ge::gl::UniformMatrix4fv UniformMatrixGLM; 36 | typedef ge::gl::UniformMatrix4fv> UniformMatrixGLMShared; 37 | 38 | typedef ge::gl::Uniform4fv Uniform4fGLM; 39 | typedef ge::gl::Uniform4fv> Uniform4fGLMShared; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /examples/Simple_QtgeSG/src/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | using namespace std; 13 | 14 | /** 15 | * Simple function that loads images that are found at image components of materials 16 | * and populate its image property. 17 | * 18 | * \warning Assumes relative texture file paths or empty imageDir. There should be an extended check 19 | * in production code. 20 | */ 21 | void loadImages(ge::sg::Scene* scene, std::string& imageDir) 22 | { 23 | std::shared_ptr defaultImage(make_shared()); 24 | 25 | for(auto model : scene->models) 26 | { 27 | for(std::shared_ptr material : model->materials) 28 | { 29 | for(std::vector>::iterator it = material->materialComponents.begin(); it != material->materialComponents.end(); ++it) 30 | { 31 | if((*it)->getType() == ge::sg::MaterialComponent::ComponentType::IMAGE) 32 | { 33 | ge::sg::MaterialImageComponent *img = dynamic_cast((*it).get()); 34 | //cout << img->semantic << " " << img->filePath << endl; 35 | std::string textFile(imageDir + img->filePath); 36 | std::shared_ptr image(QtImageLoader::loadImage(textFile.c_str())); 37 | if(image == nullptr) 38 | { 39 | cout << " " << "FAILED TO LOAD!" << "substituting default image\n"; 40 | img->image = defaultImage; 41 | } 42 | else { 43 | img->image = image; 44 | } 45 | } 46 | } 47 | } 48 | } 49 | } 50 | 51 | int main(int argc, char** argv) 52 | { 53 | QGuiApplication app(argc, argv); 54 | 55 | QQuickWindow qw; 56 | qw.resize(800, 600); 57 | fsg::SimplegeSGRenderer basicRenderer(&qw); 58 | 59 | 60 | //model loading 61 | QString modelFileName(APP_RESOURCES"/models/texCube/texCube.obj"); 62 | QFileInfo fi(modelFileName); 63 | string modelPath(qUtf8Printable(fi.canonicalPath() + "/")); 64 | 65 | std::shared_ptr scene(AssimpModelLoader::loadScene(modelFileName.toUtf8().constData())); 66 | if(!scene) 67 | { 68 | cerr << "Failed to load scene!" << endl; 69 | return -1; 70 | } 71 | basicRenderer.setScene(scene); 72 | 73 | //load Images 74 | loadImages(scene.get(), modelPath); 75 | 76 | 77 | qw.show(); 78 | 79 | return app.exec(); 80 | } -------------------------------------------------------------------------------- /geAd/AssimpModelLoader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(AssimpModelLoader) 2 | 3 | include(GNUInstallDirs) 4 | 5 | ################################################ 6 | # PACKAGES 7 | 8 | find_package(glm) 9 | find_package(ste) 10 | find_package(GPUEngine COMPONENTS geSG) 11 | find_package(assimp) 12 | 13 | foreach(dep glm ste geSG assimp::assimp) 14 | if(NOT TARGET ${dep}) 15 | return() 16 | endif() 17 | endforeach() 18 | 19 | set(public_headers 20 | src/AssimpModelLoader.h 21 | ) 22 | 23 | add_library(${PROJECT_NAME}) 24 | 25 | target_sources(${PROJECT_NAME} 26 | PRIVATE 27 | ${public_headers} 28 | src/UnicodeIOStream.h 29 | src/UnicodeIOSystem.h 30 | PRIVATE 31 | src/AssimpModelLoader.cpp 32 | src/UnicodeIOStream.cpp 33 | src/$ 34 | ) 35 | 36 | ################################################ 37 | # External_libs - external libs or targets to link with 38 | 39 | set(External_libs ste glm assimp::assimp) 40 | if(UNIX) 41 | set(External_libs ${External_libs} dl) 42 | endif() 43 | 44 | 45 | target_link_libraries(${PROJECT_NAME} geSG ${External_libs}) 46 | 47 | target_include_directories(${PROJECT_NAME} PUBLIC 48 | $ 49 | $ 50 | ) 51 | 52 | #set(PROJECT_NAME_UPPER) 53 | string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) 54 | target_compile_definitions(${PROJECT_NAME} 55 | PRIVATE "${PROJECT_NAME_UPPER}_EXPORT=__declspec(dllexport)" 56 | INTERFACE "${PROJECT_NAME_UPPER}_EXPORT=__declspec(dllimport)" 57 | ) 58 | set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER ${addons_folder_name}) 59 | ######################################### 60 | # Install 61 | 62 | 63 | install(FILES 64 | ${public_headers} 65 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geAd/${PROJECT_NAME} 66 | ) 67 | 68 | install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets 69 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 70 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 71 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 72 | ) 73 | 74 | 75 | ######################################### 76 | #Export 77 | 78 | install(EXPORT ${PROJECT_NAME}Targets 79 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/geAd 80 | ) 81 | 82 | #export(EXPORT ${PROJECT_NAME}Targets) #error https://stackoverflow.com/questions/5378528/install-export-problem-for-shared-lib-with-dependencies 83 | 84 | set(Dependencies geSG glm assimp) 85 | 86 | configure_file( 87 | ../geAd.cmake.in 88 | "${PROJECT_NAME}Config.cmake" 89 | @ONLY 90 | ) 91 | 92 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake 93 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/geAd 94 | ) 95 | -------------------------------------------------------------------------------- /geAd/AssimpModelLoader/src/UnicodeIOStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class UnicodeIOStream : public Assimp::IOStream 6 | { 7 | friend class UnicodeIOSystem; 8 | 9 | UnicodeIOStream(); 10 | #ifdef _WIN32 11 | UnicodeIOStream(FILE* pFile, const std::wstring &strFilename); 12 | #else 13 | UnicodeIOStream(FILE* pFile, const std::string &strFilename); 14 | #endif 15 | public: 16 | virtual ~UnicodeIOStream(); 17 | // ------------------------------------------------------------------- 18 | /** @brief Read from the file 19 | * 20 | * See fread() for more details 21 | * This fails for write-only files */ 22 | virtual size_t Read(void* pvBuffer, 23 | size_t pSize, 24 | size_t pCount) override; 25 | 26 | // ------------------------------------------------------------------- 27 | /** @brief Write to the file 28 | * 29 | * See fwrite() for more details 30 | * This fails for read-only files */ 31 | virtual size_t Write(const void* pvBuffer, 32 | size_t pSize, 33 | size_t pCount) override; 34 | 35 | // ------------------------------------------------------------------- 36 | /** @brief Set the read/write cursor of the file 37 | * 38 | * Note that the offset is _negative_ for aiOrigin_END. 39 | * See fseek() for more details */ 40 | virtual aiReturn Seek(size_t pOffset, 41 | aiOrigin pOrigin) override; 42 | 43 | // ------------------------------------------------------------------- 44 | /** @brief Get the current position of the read/write cursor 45 | * 46 | * See ftell() for more details */ 47 | virtual size_t Tell() const override; 48 | 49 | // ------------------------------------------------------------------- 50 | /** @brief Returns filesize 51 | * Returns the filesize. */ 52 | virtual size_t FileSize() const override; 53 | 54 | // ------------------------------------------------------------------- 55 | /** @brief Flush the contents of the file buffer (for writers) 56 | * See fflush() for more details. 57 | */ 58 | virtual void Flush() override; 59 | 60 | private: 61 | //! File data structure, using climb 62 | FILE* mFile; 63 | //! Filename 64 | #ifdef _WIN32 65 | std::wstring mFilename; 66 | #else 67 | std::string mFilename; 68 | #endif 69 | 70 | //! Cached file size 71 | mutable size_t cachedSize; 72 | }; -------------------------------------------------------------------------------- /geAd/AssimpModelLoader/src/UnicodeIOSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class UnicodeIOSystem : public Assimp::IOSystem 6 | { 7 | public: 8 | bool Exists(const char* pFile) const override; 9 | Assimp::IOStream* Open(const char* pFile, const char* pMode = "rb") override; 10 | virtual char getOsSeparator() const override; 11 | virtual void Close(Assimp::IOStream* pFile) override; 12 | }; -------------------------------------------------------------------------------- /geAd/AssimpModelLoader/src/UnicodeIOSystem_other.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Assimp; 6 | 7 | bool UnicodeIOSystem::Exists(const char* pFile) const 8 | { 9 | FILE* file = ::fopen(pFile, "rb"); 10 | if(!file) 11 | return false; 12 | 13 | ::fclose(file); 14 | return true; 15 | } 16 | 17 | // ------------------------------------------------------------------------------------------------ 18 | // Open a new file with a given path. 19 | IOStream* UnicodeIOSystem::Open(const char* strFile, const char* strMode) 20 | { 21 | FILE* file = ::fopen(strFile, strMode); 22 | if(NULL == file) 23 | return NULL; 24 | 25 | return new UnicodeIOStream(file, (std::string) strFile); 26 | } 27 | 28 | // ------------------------------------------------------------------------------------------------ 29 | // Closes the given file and releases all resources associated with it. 30 | void UnicodeIOSystem::Close(IOStream* pFile) 31 | { 32 | delete pFile; 33 | } 34 | 35 | // ------------------------------------------------------------------------------------------------ 36 | // Returns the operation specific directory separator 37 | char UnicodeIOSystem::getOsSeparator() const 38 | { 39 | return '/'; 40 | } -------------------------------------------------------------------------------- /geAd/AssimpModelLoader/src/UnicodeIOSystem_win32.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #define WIN32_LEAN_AND_MEAN 6 | #include 7 | 8 | using namespace Assimp; 9 | 10 | bool UnicodeIOSystem::Exists(const char* pFile) const 11 | { 12 | int size = (int)strlen(pFile); 13 | int destLen = MultiByteToWideChar(CP_UTF8, 0, pFile, size, 0, 0); 14 | std::wstring wFilename(destLen, L'\0'); 15 | destLen = MultiByteToWideChar(CP_UTF8, 0, pFile, size, &wFilename[0], destLen); 16 | FILE* file; 17 | errno_t err; 18 | err = ::_wfopen_s(&file, wFilename.c_str(), L"rb"); 19 | if(err !=0 ) 20 | return false; 21 | 22 | ::fclose(file); 23 | return true; 24 | } 25 | 26 | IOStream* UnicodeIOSystem::Open(const char* strFile, const char* strMode) 27 | { 28 | 29 | int size = (int)strlen(strFile); 30 | int destLen = MultiByteToWideChar(CP_UTF8, 0, strFile, size, 0, 0); 31 | std::wstring wFilename(destLen, L'\0'); 32 | destLen = MultiByteToWideChar(CP_UTF8, 0, strFile, size, &wFilename[0], destLen); 33 | FILE* file; 34 | errno_t err; 35 | err = ::_wfopen_s(&file, wFilename.c_str(), L"rb"); 36 | if(err != 0) 37 | return NULL; 38 | 39 | return new UnicodeIOStream(file, (std::wstring) wFilename); 40 | } 41 | 42 | char UnicodeIOSystem::getOsSeparator() const 43 | { 44 | return '\\'; 45 | } 46 | 47 | void UnicodeIOSystem::Close(IOStream* pFile) 48 | { 49 | delete pFile; 50 | } -------------------------------------------------------------------------------- /geAd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(addons_folder_name "geAd") 2 | 3 | set(addons AssimpModelLoader QtImageLoader) 4 | 5 | foreach(addon ${addons}) 6 | add_subdirectory(${addon}) 7 | endforeach() 8 | 9 | message(STATUS "Addons configured:") 10 | foreach(addon ${addons}) 11 | if(TARGET ${addon}) 12 | message(STATUS " ${addon}") 13 | endif() 14 | endforeach() -------------------------------------------------------------------------------- /geAd/FreeImageImageLoader/cmake/FreeImageImageLoaderConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(MODULE_NAME "FreeImageImageLoader") 3 | set(MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}/..") 4 | 5 | #If target was already defined then return. Perhaps it was included from another package. 6 | IF(TARGET ${MODULE_NAME}) 7 | return() 8 | ENDIF() 9 | 10 | set(${MODULE_NAME}_HEADER_FILES 11 | ${MODULE_DIR}/src/FreeImageImageLoader.h 12 | ) 13 | 14 | set(${MODULE_NAME}_SOURCE_FILES 15 | ${MODULE_DIR}/src/FreeImageImageLoader.cpp 16 | ) 17 | 18 | 19 | find_package(FreeImage) 20 | find_package(FreeImagePlus) 21 | 22 | IF(NOT TARGET geSG) 23 | find_package(GPUEngine COMPONENTS geSG) 24 | ENDIF() 25 | 26 | add_library(${MODULE_NAME} INTERFACE) 27 | 28 | target_sources(${MODULE_NAME} INTERFACE ${${MODULE_NAME}_SOURCE_FILES}) 29 | target_include_directories(${MODULE_NAME} INTERFACE "${MODULE_DIR}/src/" ${FREEIMAGE_INCLUDE_PATH} ${FREEIMAGEPLUS_INCLUDE_PATH}) 30 | target_link_libraries(${MODULE_NAME} INTERFACE 31 | general geSG ${FREEIMAGE_LIBRARIES} ${FREEIMAGEPLUS_LIBRARIES} 32 | ) 33 | -------------------------------------------------------------------------------- /geAd/FreeImageImageLoader/src/FreeImageImageLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class fipImage; 6 | class FreeImageImage; 7 | 8 | class FreeImageImageLoader 9 | { 10 | public: 11 | 12 | static FreeImageImage* loadImage(const char* imageIdentifier, int options = 0); 13 | static FreeImageImage* loadImage(const wchar_t* imageIdentifier, int options = 0); 14 | }; 15 | 16 | class FreeImageImage : public ge::sg::ImageTemplate < fipImage > 17 | { 18 | public: 19 | ~FreeImageImage(); 20 | 21 | virtual unsigned char* getBits(); 22 | 23 | virtual size_t getSizeInBytes(); 24 | virtual ge::sg::Image::Format getFormat(); //should this function return int or some template type which could be specified as GLenum 25 | virtual ge::sg::Image::DataType getDataType(); 26 | virtual size_t getWidth(); 27 | virtual size_t getHeight(); 28 | }; -------------------------------------------------------------------------------- /geAd/QtImageLoader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(QtImageLoader) 2 | 3 | include(GNUInstallDirs) 4 | 5 | ################################################ 6 | # PACKAGES 7 | 8 | find_package(Qt5 COMPONENTS Gui) 9 | find_package(GPUEngine COMPONENTS geSG) 10 | 11 | foreach(dep Qt5::Gui geSG) 12 | if(NOT TARGET ${dep}) 13 | return() 14 | endif() 15 | endforeach() 16 | 17 | set(public_headers 18 | src/QtImageLoader.h 19 | ) 20 | 21 | add_library(${PROJECT_NAME}) 22 | 23 | target_sources(${PROJECT_NAME} 24 | PRIVATE 25 | ${public_headers} 26 | PRIVATE 27 | src/QtImageLoader.cpp 28 | ) 29 | 30 | ################################################ 31 | # External_libs - external libs or targets to link with 32 | 33 | set(External_libs Qt5::Gui) 34 | if(UNIX) 35 | set(External_libs ${External_libs} dl) 36 | endif() 37 | 38 | 39 | target_link_libraries(${PROJECT_NAME} geSG ${External_libs}) 40 | 41 | target_include_directories(${PROJECT_NAME} PUBLIC 42 | $ 43 | $ 44 | ) 45 | 46 | #set(PROJECT_NAME_UPPER) 47 | string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) 48 | target_compile_definitions(${PROJECT_NAME} 49 | PRIVATE "${PROJECT_NAME_UPPER}_EXPORT=__declspec(dllexport)" 50 | INTERFACE "${PROJECT_NAME_UPPER}_EXPORT=__declspec(dllimport)" 51 | ) 52 | set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER ${addons_folder_name}) 53 | ######################################### 54 | # Install 55 | 56 | 57 | install(FILES 58 | ${public_headers} 59 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geAd/${PROJECT_NAME} 60 | ) 61 | 62 | install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets 63 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 64 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 65 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 66 | ) 67 | 68 | 69 | ######################################### 70 | #Export 71 | 72 | install(EXPORT ${PROJECT_NAME}Targets 73 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/geAd 74 | ) 75 | 76 | #export(EXPORT ${PROJECT_NAME}Targets) #error https://stackoverflow.com/questions/5378528/install-export-problem-for-shared-lib-with-dependencies 77 | 78 | set(Dependencies geSG) 79 | 80 | configure_file( 81 | QtImageLoader.cmake.in 82 | "${PROJECT_NAME}Config.cmake" 83 | @ONLY 84 | ) 85 | 86 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake 87 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/geAd 88 | ) 89 | -------------------------------------------------------------------------------- /geAd/QtImageLoader/QtImageLoader.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | 4 | if(NOT TARGET @PROJECT_NAME@) 5 | 6 | foreach(_dep @Dependencies@) 7 | if(NOT TARGET ${_dep}) 8 | find_dependency(${_dep} HINTS "${CMAKE_CURRENT_LIST_DIR}/../") 9 | endif() 10 | endforeach() 11 | 12 | if(NOT TARGET Qt5::Gui) 13 | find_dependency(Qt5 COMPONENTS Gui) 14 | endif() 15 | 16 | include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake) 17 | 18 | endif(NOT TARGET @PROJECT_NAME@) -------------------------------------------------------------------------------- /geAd/QtImageLoader/src/QtImageLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class QImage; 6 | class QString; 7 | class QtImage; 8 | 9 | /** 10 | * Image loader for Qt. 11 | * Use loadImage with path to an image file and options if supported. The funtions return 12 | * the pointer to QtImage. The receiver takes ownership of returned image and it is required 13 | * to stuff it inside the shared_ptr if you want to use it with the rest of GPUEngine. 14 | * The loaded image is converted to either Format_Grayscale8 for grey scale images or 15 | * Format_RGBA8888. 16 | * 17 | * \example Simple_QtgeSG/main.cpp 18 | */ 19 | class QTIMAGELOADER_EXPORT QtImageLoader 20 | { 21 | public: 22 | 23 | static QtImage* loadImage(const char* imageIdentifier, int options = 0); 24 | static QtImage* loadImage(const wchar_t* imageIdentifier, int options = 0); 25 | static QtImage* loadImage(const QString& imageIdentifier, int options = 0); 26 | }; 27 | 28 | class QTIMAGELOADER_EXPORT QtImage : public ge::sg::ImageTemplate < QImage > 29 | { 30 | public: 31 | ~QtImage(); 32 | 33 | virtual unsigned char* getBits(); 34 | 35 | virtual size_t getSizeInBytes(); 36 | virtual ge::sg::Image::Format getFormat(); //should this function return int or some template type which could be specified as GLenum 37 | virtual ge::sg::Image::DataType getDataType(); 38 | virtual size_t getWidth(); 39 | virtual size_t getHeight(); 40 | }; -------------------------------------------------------------------------------- /geAd/geAd.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | 4 | if(NOT TARGET @PROJECT_NAME@) 5 | 6 | foreach(_dep @Dependencies@) 7 | if(NOT TARGET ${_dep}) 8 | find_dependency(${_dep} HINTS "${CMAKE_CURRENT_LIST_DIR}/../") 9 | endif() 10 | endforeach() 11 | 12 | include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake) 13 | 14 | endif(NOT TARGET @PROJECT_NAME@) -------------------------------------------------------------------------------- /geCore/src/geCore/CallStackPrinter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(ENABLE_PRINT_CALL_STACK) 4 | 5 | #define HIDDEN_VARIABLE_NAME superduperhidden 6 | #define OUTPUT cout 7 | 8 | #include 9 | #include 10 | 11 | namespace ge{ 12 | namespace core{ 13 | template 14 | std::string argsToStr(ARGS...); 15 | 16 | template 17 | inline std::string argsToStr_help(F const&a,ARGS...args){ 18 | std::stringstream ss; 19 | ss<0) 21 | ss<<","< 26 | inline std::string argsToStr(ARGS...args){ 27 | return argsToStr_help(args...); 28 | } 29 | 30 | template<>inline std::string argsToStr(){ 31 | return ""; 32 | } 33 | 34 | class CallStackPrinter{ 35 | public: 36 | int&indentCounter(){ 37 | static int counter = 0; 38 | return counter; 39 | } 40 | std::string&indent(){ 41 | static std::string s = ""; 42 | return s; 43 | } 44 | std::string argsData=""; 45 | template 46 | CallStackPrinter(ARGS...args){ 47 | this->argsData = argsToStr(args...); 48 | } 49 | void print(std::string const&fceName){ 50 | std::OUTPUT<argsData<<"){"< 2 | #include 3 | 4 | using namespace ge::core; 5 | 6 | CommandList::CommandList(){} 7 | CommandList::~CommandList(){ 8 | for(auto x:*this)delete x; 9 | } 10 | void CommandList::operator()(){ 11 | for(auto x:*this)(*x)(); 12 | } 13 | 14 | SharedCommandList::SharedCommandList(){} 15 | SharedCommandList::~SharedCommandList(){} 16 | void SharedCommandList::operator()(){ 17 | for(auto x:*this)(*x)(); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /geCore/src/geCore/Command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace ge{ 9 | namespace core{ 10 | class GECORE_EXPORT Command : public Functor{ 11 | public: 12 | virtual void operator()(){}; 13 | virtual ~Command(){}; 14 | }; 15 | 16 | class GECORE_EXPORT CommandList: public std::vector, public Command{ 17 | public: 18 | CommandList(); 19 | virtual ~CommandList(); 20 | virtual void operator()()override; 21 | }; 22 | 23 | class GECORE_EXPORT SharedCommandList: public std::vector>, public Command{ 24 | public: 25 | SharedCommandList(); 26 | virtual ~SharedCommandList(); 27 | virtual void operator()()override; 28 | }; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /geCore/src/geCore/Defines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define REMOVE_RETURN(name) std::string(name).substr(std::string(name).rfind(" ")+1) 4 | #define REMOVE_ARGS(name) std::string(name).substr(0,std::string(name).find("(")) 5 | 6 | #if _MSC_VER 7 | #define __PRETTY_FUNCTION__ __FUNCSIG__ 8 | #endif 9 | 10 | #define GE_CORE_FCENAME REMOVE_RETURN(REMOVE_ARGS(__PRETTY_FUNCTION__)) 11 | -------------------------------------------------------------------------------- /geCore/src/geCore/DisjointSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ge{ 7 | namespace core{ 8 | template 9 | class DisjointSet:public std::vector>{ 10 | public: 11 | void makeSet(TYPE const&a){ 12 | if(this->find(a)!=this->end())return; 13 | this->push_back(std::set(a)); 14 | } 15 | void add(TYPE const&a,TYPE const&b){ 16 | typename std::vector>::iterator fa=this->find(a); 17 | typename std::vector>::iterator fb=this->find(b); 18 | if(fa==fb){ 19 | if(fa==this->end()){ 20 | std::setnewSet; 21 | newSet.insert(a); 22 | newSet.insert(b); 23 | this->push_back(newSet); 24 | } 25 | }else{ 26 | if(fa==this->end()){ 27 | fb->insert(a); 28 | }else if(fb==this->end()){ 29 | fa->insert(b); 30 | }else{ 31 | std::setnewSet; 32 | for(auto x:*fa) 33 | newSet.insert(x); 34 | for(auto x:*fb) 35 | newSet.insert(x); 36 | this->erase(fa); 37 | this->erase(fb); 38 | this->push_back(newSet); 39 | } 40 | } 41 | } 42 | 43 | bool eq(TYPE const&a,TYPE const&b){ 44 | for(auto x:*this) 45 | if(x.find(a)!=x.end()){ 46 | if(x.find(b)!=x.end())return true; 47 | else return false; 48 | } 49 | return false; 50 | } 51 | 52 | typename std::vector>::iterator find(TYPE const &a){ 53 | for(auto x=this->begin();x!=this->end();++x) 54 | if(x->find(a)!=x->end())return x; 55 | return this->end(); 56 | } 57 | }; 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /geCore/src/geCore/ErrorPrinter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ge{ 7 | namespace core{ 8 | template> 9 | void printError(std::string fceName,std::string message,ARGS...args){ 10 | std::cerr<<"ERROR: "<argStrings = {value2str(args)...}; 12 | bool first=true; 13 | for(auto const&x:argStrings){ 14 | if(first)first=false; 15 | else std::cerr<<","; 16 | std::cerr< 3 | 4 | namespace ge 5 | { 6 | namespace core 7 | { 8 | class GECORE_EXPORT Functor 9 | { 10 | public: 11 | virtual void operator()() = 0; 12 | }; 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /geCore/src/geCore/InitAndFinalize.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace ge::core; 5 | 6 | 7 | static int niftyCounter; // according to standard, 8 | // this is initialized to zero before any global object constructor is called: 9 | // Citing ($3.6.2/1): "Objects with static storage duration (3.7.1) shall 10 | // be zero-initialized (8.5) before any other initialization takes place." 11 | // Do not try to improve the code and make it "niftyCounter=0;" as 12 | // this may theoretically postpone the initialization to later time. 13 | 14 | 15 | typedef std::unordered_set FceSet; 16 | 17 | 18 | static FceSet& getInitSet() 19 | { 20 | static FceSet s; 21 | return s; 22 | } 23 | 24 | 25 | static FceSet& getFinalizeSet() 26 | { 27 | static FceSet s; 28 | return s; 29 | } 30 | 31 | 32 | InitAndFinalize::InitAndFinalize(void (*initFce)(),void (*finalizeFce)()) 33 | { 34 | // increment global counter 35 | ++niftyCounter; 36 | 37 | // call initFce 38 | // but do it only on the first such request 39 | // (InitAndFinalize object is instantiated in header (that is how NiftyCounter idiom works) 40 | // and number times it is included, it is instantiated with the same values) 41 | if(initFce) { 42 | auto r=getInitSet().insert(initFce); 43 | if(r.second) 44 | initFce(); 45 | } 46 | 47 | // register finalizeFce 48 | if(finalizeFce) 49 | getFinalizeSet().insert(finalizeFce); 50 | } 51 | 52 | 53 | InitAndFinalize::~InitAndFinalize() 54 | { 55 | if(--niftyCounter==0) 56 | { 57 | auto& s=getFinalizeSet(); 58 | for(void (*f)():s) 59 | f(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /geCore/src/geCore/InitAndFinalize.h: -------------------------------------------------------------------------------- 1 | #ifndef GE_INIT_AND_FINALIZE_H 2 | #define GE_INIT_AND_FINALIZE_H 3 | 4 | #include 5 | 6 | namespace ge 7 | { 8 | namespace core 9 | { 10 | 11 | class GECORE_EXPORT InitAndFinalize { 12 | public: 13 | InitAndFinalize(void (*initFce)(),void (*finalizeFce)()); 14 | ~InitAndFinalize(); 15 | }; 16 | 17 | } 18 | } 19 | 20 | #endif /* GE_CORE_INIT_AND_FINALIZE_H */ 21 | -------------------------------------------------------------------------------- /geCore/src/geCore/KeyPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ge 4 | { 5 | namespace core 6 | { 7 | /** 8 | * KeyPoint is interface used as a basis for interpolation framework. Used it with conjuction with 9 | * interpolators to produce meaningful result. But it might be useful in different ways. 10 | * \tparam _FP Type of parameter space used for interpolation. 11 | */ 12 | template 13 | class KeyPointInterface 14 | { 15 | public: 16 | 17 | using parameter_type = _FP; ///< Type used for numerical interpolation. The real used parameter is converted to this for arithmetic operation. 18 | 19 | 20 | /** 21 | * Since the implementation of this interface can use any type of parameter it seems fit it allows to supply another type for 22 | * arithmetic computation purposes. This function allows others to get the internal type (e.g. time_point) transformed to type 23 | * that is more suitable for arithmetic purposes (e.g. float). It is used in animation key frame interpolators. 24 | * \return The parameter of the key point transformed to parameter_type. 25 | */ 26 | virtual parameter_type getT() const = 0; 27 | 28 | virtual ~KeyPointInterface() = default; 29 | }; 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /geCore/src/geCore/StandardSemanticsNames.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace ge::core; 4 | 5 | 6 | std::string StandardSemanticNames::ambientColor = "ambientColor"; 7 | std::string StandardSemanticNames::diffuseColor = "diffuseColor"; 8 | std::string StandardSemanticNames::specularColor = "specularColor"; 9 | std::string StandardSemanticNames::emissiveColor = "emissiveColor"; 10 | std::string StandardSemanticNames::shininess = "shininess"; 11 | std::string StandardSemanticNames::ambientTexture = "ambientTexture"; 12 | std::string StandardSemanticNames::diffuseTexture = "diffuseTexture"; 13 | std::string StandardSemanticNames::specularTexture = "specularTexture"; 14 | std::string StandardSemanticNames::emissiveTexture = "emissiveTexture"; 15 | std::string StandardSemanticNames::heightTexture = "heightTexture"; 16 | std::string StandardSemanticNames::normalTexture = "normalTexture"; 17 | std::string StandardSemanticNames::shininessTexture = "shininessTexture"; 18 | std::string StandardSemanticNames::opacityTexture = "opacityTexture"; 19 | std::string StandardSemanticNames::displacementTexture = "displacementTexture"; 20 | std::string StandardSemanticNames::lightmapTexture = "lightmapTexture"; 21 | std::string StandardSemanticNames::reflectionTexture = "reflectionTexture"; 22 | 23 | std::string StandardSemanticNames::position = "position"; 24 | std::string StandardSemanticNames::normal = "normal"; 25 | std::string StandardSemanticNames::tangent = "tangent"; 26 | std::string StandardSemanticNames::binormal = "binormal"; 27 | std::string StandardSemanticNames::indices = "indices"; 28 | std::string StandardSemanticNames::texcoord = "texcoord"; -------------------------------------------------------------------------------- /geCore/src/geCore/StandardSemanticsNames.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace ge 8 | { 9 | namespace core 10 | { 11 | struct GECORE_EXPORT StandardSemanticNames 12 | { 13 | static std::string ambientColor; 14 | static std::string diffuseColor; 15 | static std::string specularColor; 16 | static std::string emissiveColor; 17 | static std::string shininess; 18 | static std::string ambientTexture; 19 | static std::string diffuseTexture; 20 | static std::string specularTexture; 21 | static std::string emissiveTexture; 22 | static std::string heightTexture; 23 | static std::string normalTexture; 24 | static std::string shininessTexture; 25 | static std::string opacityTexture; 26 | static std::string displacementTexture; 27 | static std::string lightmapTexture; 28 | static std::string reflectionTexture; 29 | 30 | static std::string position; 31 | static std::string normal; 32 | static std::string tangent; 33 | static std::string binormal; 34 | static std::string indices; 35 | static std::string texcoord; 36 | }; 37 | } 38 | } -------------------------------------------------------------------------------- /geCore/src/geCore/Updatable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace ge 6 | { 7 | namespace core 8 | { 9 | /*This alias does not work when you need - time_point t = time_point::clock::now() - type conversion error!!!! (maybe a bug)*/ 10 | //using time_point = std::chrono::time_point; 11 | using time_unit = std::chrono::duration; ///< Basic duration used in GE. Time unit doubles of seconds. 12 | using time_point = std::chrono::time_point; ///< Time point on steady clock of time_unit 13 | 14 | /** 15 | * Simple convenient class to convert an arbitrary duration to our time_unit. Wrapper of duration_cast<>. 16 | */ 17 | //template 18 | //inline time_unit toTimeUnit(const Duration& tp){ return std::chrono::duration_cast(tp); } 19 | 20 | /** 21 | * Takes time in _Rep (e.g. doubles) of time_units (seconds by default) and returns time_unit representation of this value. 22 | */ 23 | template 24 | inline time_unit toTimeUnit(const _Rep& tp){ return std::chrono::duration_cast(std::chrono::duration<_Rep, ratio>(tp)); } 25 | 26 | /** 27 | * Convenience function to convert time_point to type FP that could be staticaly casted from time_point's duration::period 28 | * for Animation key frame interpolation purposes. 29 | */ 30 | template 31 | inline FP TPtoFP(const time_point& tp) { return static_cast(tp.time_since_epoch().count()); } 32 | 33 | /** 34 | * Pure virtual interface for "updatable" classes such as animations. 35 | * The implementation relies on std::chrono. Subclasses are forced to implement 36 | * only the update method. 37 | */ 38 | class Updatable 39 | { 40 | public: 41 | virtual void update(const time_point& t = time_point()) = 0; 42 | }; 43 | } 44 | } -------------------------------------------------------------------------------- /geCore/src/geCore/enum_definition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | #define ENUM_CLASS(name,...) \ 7 | enum class name {__VA_ARGS__}; \ 8 | std::ostream& operator<<(std::ostream& os, name val) \ 9 | {\ 10 | char s[]=#__VA_ARGS__;\ 11 | char*ret = strtok(&s[0],",");\ 12 | for(int i=0; i<(int)val;++i)\ 13 | {\ 14 | ret=strtok(NULL,",");\ 15 | }\ 16 | return os << ret;\ 17 | } 18 | 19 | #define ENUM_CLASS_FRIEND_OPERATOR(name,...) \ 20 | enum class name {__VA_ARGS__}; \ 21 | friend std::ostream& operator<<(std::ostream& os, name val) \ 22 | {\ 23 | char s[]=#__VA_ARGS__;\ 24 | char*ret = strtok(&s[0],",");\ 25 | for(int i=0; i<(int)val;++i)\ 26 | {\ 27 | ret=strtok(NULL,",");\ 28 | }\ 29 | return os << ret;\ 30 | } 31 | */ 32 | 33 | #define ENUM_CLASS(name,...) \ 34 | enum class name {__VA_ARGS__}; \ 35 | std::ostream& operator<<(std::ostream& os, name val) \ 36 | {\ 37 | static std::maptable = ge::core::ParseEnumArgs()(VA_ARGS_TO_STRING(__VA_ARGS__));\ 38 | auto a=table.find(val);\ 39 | if(a!=table.end())os << a->second;\ 40 | return os;\ 41 | } 42 | 43 | #define ENUM_CLASS_FRIEND_OPERATOR(name,...) \ 44 | enum class name {__VA_ARGS__}; \ 45 | friend std::ostream& operator<<(std::ostream& os, name val) \ 46 | {\ 47 | static std::maptable = ge::core::ParseEnumArgs()(VA_ARGS_TO_STRING(__VA_ARGS__));\ 48 | auto a=table.find((unsigned)val);\ 49 | if(a!=table.end())os << a->second;\ 50 | return os;\ 51 | } 52 | 53 | -------------------------------------------------------------------------------- /geCore/src/geCore/fsa/FusedCallbackData.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace ge::core; 4 | 5 | FSACallback::FSACallback(FSACallback::Fce fce,void*data){ 6 | this->_fce = fce; 7 | this->_data = data; 8 | } 9 | 10 | FSACallback::~FSACallback(){} 11 | 12 | FSACallback::Fce const& FSACallback::getFce()const{ 13 | return this->_fce; 14 | } 15 | 16 | void* const& FSACallback::getData()const{ 17 | return this->_data; 18 | } 19 | 20 | bool FSACallback::operator==(FSACallback const&other)const{ 21 | return this->_fce==other._fce && this->_data == other._data; 22 | } 23 | 24 | bool FSACallback::operator<(FSACallback const&other)const{ 25 | return this->_fce_fce)this->_fce(fsa,this->_data); 30 | } 31 | 32 | FSAFusedCallback::FSAFusedCallback(){ 33 | 34 | } 35 | 36 | FSAFusedCallback::FSAFusedCallback(FSACallback const&callback){ 37 | this->_callbacks.push_back(callback); 38 | } 39 | 40 | FSAFusedCallback::FSAFusedCallback(FSAFusedCallback const&a,FSAFusedCallback const&b){ 41 | unsigned ai=0,bi=0; 42 | while(ai_callbacks.push_back(a._callbacks[ai]); 45 | ai++; 46 | bi++; 47 | }else if(a._callbacks[ai]_callbacks.push_back(a._callbacks[ai++]); 49 | else 50 | this->_callbacks.push_back(b._callbacks[bi++]); 51 | } 52 | } 53 | 54 | void FSAFusedCallback::operator()(FSA*fsa)const{ 55 | for(auto x:this->_callbacks) 56 | x(fsa); 57 | } 58 | 59 | bool FSAFusedCallback::operator==(FSAFusedCallback const&other)const{ 60 | if(this->_callbacks.size()!=other._callbacks.size())return false; 61 | for(unsigned i=0;i_callbacks.size();++i) 62 | if(!(this->_callbacks[i]==other._callbacks[i]))return false; 63 | return true; 64 | } 65 | 66 | bool FSAFusedCallback::operator!=(FSAFusedCallback const&other)const{ 67 | return !(*this==other); 68 | } 69 | -------------------------------------------------------------------------------- /geCore/src/geCore/fsa/FusedCallbackData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | //#include 6 | 7 | namespace ge{ 8 | namespace core{ 9 | class FSA; 10 | class GECORE_EXPORT FSACallback{ 11 | public: 12 | typedef void(*Fce)(FSA*,void*); 13 | FSACallback(Fce fce = nullptr,void*data = nullptr); 14 | virtual ~FSACallback(); 15 | Fce const& getFce ()const; 16 | void* const& getData()const; 17 | bool operator==(FSACallback const&other)const; 18 | bool operator< (FSACallback const&other)const; 19 | void operator()(FSA*fsa); 20 | protected: 21 | Fce _fce ; 22 | void* _data; 23 | }; 24 | 25 | class FSAFusedCallback{ 26 | public: 27 | FSAFusedCallback(); 28 | FSAFusedCallback(FSACallback const&callback); 29 | FSAFusedCallback(FSAFusedCallback const&a,FSAFusedCallback const&b); 30 | void operator()(FSA*fsa)const; 31 | bool operator==(FSAFusedCallback const&other)const; 32 | bool operator!=(FSAFusedCallback const&other)const; 33 | protected: 34 | std::vector_callbacks; 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /geCore/src/geCore/fsa/MapTransitionChooser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ge{ 8 | namespace core{ 9 | template 10 | class MapTransitionChooser: public TransitionChooser{ 11 | public: 12 | MapTransitionChooser():TransitionChooser(N){} 13 | virtual ~MapTransitionChooser()override{ 14 | for(auto&x:this->_keys) 15 | delete[]x; 16 | } 17 | virtual MealyMachine::TransitionIndex getTransition( 18 | MealyMachine::TransitionSymbol const&data)const override{ 19 | auto ii=this->_translator.find(data); 20 | if(ii==this->_translator.end())return MealyMachine::nonexistingTransition; 21 | return ii->second; 22 | return 0; 23 | } 24 | virtual bool addTransition( 25 | MealyMachine::TransitionSymbol const&data)override{ 26 | auto key = new MealyMachine::BasicUnit[N]; 27 | std::memcpy(key,data,N*sizeof(MealyMachine::BasicUnit)); 28 | this->_keys.push_back(key); 29 | 30 | auto id = this->_translator.size(); 31 | this->_translator[(MealyMachine::BasicUnit const*)this->_keys.back()] = id; 32 | return true; 33 | } 34 | virtual MealyMachine::TransitionSymbol const&getSymbol( 35 | MealyMachine::TransitionIndex const&i)const override{ 36 | return this->_keys.at(i); 37 | } 38 | protected: 39 | struct Comparer{ 40 | bool operator()( 41 | MealyMachine::BasicUnit const*const&a, 42 | MealyMachine::BasicUnit const*const&b)const{ 43 | for(size_t i=0;ib[i])return false; 46 | } 47 | return false; 48 | } 49 | }; 50 | std::vector_keys; 51 | std::map< 52 | MealyMachine::BasicUnit const*, 53 | MealyMachine::TransitionIndex,Comparer>_translator; 54 | }; 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /geCore/src/geCore/fsa/State.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ge{ 8 | namespace core{ 9 | class FSA; 10 | class GECORE_EXPORT FSAState{ 11 | private: 12 | std::string _name ; 13 | std::map_transitions ; 14 | FSATransition _eofTransition ; 15 | public: 16 | FSAState(std::string name); 17 | virtual ~FSAState(); 18 | void addTransition (char lex,FSAState*state,FSAFusedCallback callback); 19 | void addElseTransition( FSAState*state,FSAFusedCallback callback); 20 | void addEOFTransition ( FSAState*state,FSAFusedCallback callback); 21 | void setCallback (char lex,FSAFusedCallback callback); 22 | void setElseCallback( FSAFusedCallback callback); 23 | void setEOFCallback ( FSAFusedCallback callback); 24 | FSATransition const&getTransition (char lex)const; 25 | FSATransition const&getEOFTransition ( )const; 26 | void clearTransitions (); 27 | void clearEofTransition (); 28 | std::string getName()const; 29 | decltype(_transitions)::size_type getNofTransition()const; 30 | char getTransitionLex(unsigned i)const; 31 | void setEndState (char lex,FSAState*state = nullptr); 32 | void setEOFEndState ( FSAState*state = nullptr); 33 | FSAState* apply(char lex,FSA*fsa); 34 | bool hasEOFTransition ( )const; 35 | bool hasTransition (char lex)const; 36 | std::string toStr()const; 37 | typedef std::map::const_iterator Iterator; 38 | Iterator begin()const; 39 | Iterator end ()const; 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /geCore/src/geCore/fsa/Transition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | using namespace ge::core; 9 | 10 | FSATransition::FSATransition(FSAState*state,FSAFusedCallback const&callback){ 11 | this->_nextState = state ; 12 | this->_callback = callback; 13 | } 14 | 15 | FSATransition::~FSATransition(){ 16 | } 17 | 18 | bool FSATransition::operator==(FSATransition const&other)const{ 19 | return this->_nextState == other._nextState && this->_callback == other._callback; 20 | } 21 | 22 | bool FSATransition::operator!=(FSATransition const&other)const{ 23 | return !(*this==other); 24 | } 25 | 26 | void FSATransition::setCallback(FSAFusedCallback const& callback){ 27 | this->_callback = callback; 28 | } 29 | 30 | FSAState* FSATransition::getNextState()const{ 31 | return this->_nextState; 32 | } 33 | 34 | void FSATransition::setNextState(FSAState*state){ 35 | this->_nextState = state; 36 | } 37 | 38 | FSAFusedCallback const&FSATransition::getCallback()const{ 39 | return this->_callback; 40 | } 41 | 42 | void FSATransition::callCallback(FSA*fsa)const{ 43 | this->_callback(fsa); 44 | } 45 | 46 | std::string FSATransition::toStr()const{ 47 | std::stringstream ss; 48 | ss<_nextState->getName(); 49 | return ss.str(); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /geCore/src/geCore/fsa/Transition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ge{ 8 | namespace core{ 9 | class FSA; 10 | class FSAState; 11 | class GECORE_EXPORT FSATransition{ 12 | public: 13 | FSATransition(FSAState*state = nullptr,FSAFusedCallback const& callback = FSAFusedCallback()); 14 | virtual ~FSATransition(); 15 | bool operator==(FSATransition const&other)const; 16 | bool operator!=(FSATransition const&other)const; 17 | void setCallback(FSAFusedCallback const& callback = FSAFusedCallback()); 18 | FSAState*getNextState()const; 19 | FSAFusedCallback const&getCallback()const; 20 | void callCallback (FSA*fsa )const; 21 | std::string toStr ( )const; 22 | void setNextState (FSAState*state = nullptr); 23 | private: 24 | FSAState* _nextState = nullptr; 25 | FSAFusedCallback _callback ; 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /geCore/src/geCore/fsa/TransitionChooser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace ge{ 6 | namespace core{ 7 | class TransitionChooser{ 8 | public: 9 | inline TransitionChooser(size_t size); 10 | virtual inline ~TransitionChooser(); 11 | inline size_t getSize()const; 12 | virtual MealyMachine::TransitionIndex getTransition( 13 | MealyMachine::TransitionSymbol const&data)const = 0; 14 | virtual bool addTransition( 15 | MealyMachine::TransitionSymbol const&data) = 0; 16 | virtual MealyMachine::TransitionSymbol const& getSymbol( 17 | MealyMachine::TransitionIndex const&index)const = 0; 18 | protected: 19 | size_t _size; 20 | }; 21 | 22 | inline TransitionChooser::TransitionChooser(size_t size){ 23 | this->_size = size; 24 | } 25 | 26 | inline TransitionChooser::~TransitionChooser(){} 27 | 28 | inline size_t TransitionChooser::getSize()const{ 29 | return this->_size; 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /geGL/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | build/ 35 | 36 | .* 37 | ~* 38 | *~ 39 | -------------------------------------------------------------------------------- /geGL/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/dormon/geGL.git 8 | branch = master 9 | commit = 5464a364329982d5d5b04574e16458581cbeb806 10 | parent = 6d35d13892ee13859772ff133b351a4d0841ffa5 11 | method = rebase 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /geGL/README.md: -------------------------------------------------------------------------------- 1 | # geGL 2 | Simple OpenGL c++ wrapper for GPUEngine. 3 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/decomment.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | #if len(sys.argv)<2: 8 | # sys.exit(0) 9 | 10 | import fileinput 11 | from subprocess import Popen, PIPE 12 | 13 | data0="" 14 | for line in fileinput.input(): 15 | data0+=line 16 | 17 | data0 = re.sub(r"/\*.*?\*/","",data0,flags=re.DOTALL) 18 | 19 | data0 = re.sub(r"//.*$","",data0,flags=re.DOTALL) 20 | 21 | print data0 22 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/decorateHeader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | print "#pragma once" 17 | for x in data0: 18 | print x 19 | 20 | 21 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/depreprocess.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | #if len(sys.argv)<2: 8 | # sys.exit(0) 9 | 10 | import fileinput 11 | from subprocess import Popen, PIPE 12 | 13 | data0="" 14 | for line in fileinput.input(): 15 | data0+=line 16 | 17 | data1 = Popen(["g++","-std=c++1y","-E","-"],stdout=PIPE,stdin=PIPE).communicate(data0)[0] 18 | 19 | data2 = re.sub(r"#.*","",data1).split("\n") 20 | data3 = filter(lambda x: not re.match(r'^\s*$', x), data2) 21 | 22 | data4 = [] 23 | headerLine="" 24 | for line in data3: 25 | if headerLine == "": 26 | if re.search(";",line): 27 | data4+=[line] 28 | else: 29 | headerLine = line 30 | else: 31 | if re.search(";",line): 32 | headerLine+=line; 33 | data4+=[headerLine] 34 | headerLine = "" 35 | else: 36 | headerLine+=line 37 | if headerLine != "": 38 | data4 += [headerLine] 39 | 40 | for x in data4: 41 | print ' '.join(x.split()) 42 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/extensionBucketer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #!/usr/bin/python 3 | 4 | import sys 5 | import re 6 | import os 7 | 8 | import fileinput 9 | from subprocess import Popen, PIPE 10 | 11 | data0="" 12 | for line in fileinput.input(): 13 | data0+=line 14 | 15 | data0 = data0.split("\n")[::-1] 16 | 17 | if len(sys.argv)<2: 18 | exit(0) 19 | 20 | 21 | 22 | extensions = ["AMD","NV","ATI","IBM","HP","EXT","ARB","OES","SUN","SGI","MESA","INTEL","APPLE","3DFX","GREMEDY","OVR","PGI","INGR","KHR"] 23 | 24 | pre = "#pragma once" 25 | post = "" 26 | fileName = sys.argv[1] 27 | 28 | 29 | for ext in extensions: 30 | print fileName+"_"+ext+".h" 31 | print pre 32 | for line in data0: 33 | if re.search(ext,line): 34 | print line 35 | print post 36 | 37 | reg = re.compile("|".join(extensions)) 38 | 39 | print fileName+"_CORE.h" 40 | print pre 41 | for line in data0: 42 | if reg.findall(line)!=[]: 43 | continue 44 | if line=="": 45 | continue 46 | print line 47 | print post 48 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/extractConstants.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0={} 11 | for line in fileinput.input(): 12 | if re.search("#define",line) and re.search("GL_",line): 13 | words = line.split() 14 | if len(words)==3: 15 | data0[words[1]] = words[2]; 16 | data1 = sorted(data0.items()) 17 | for val in data1: 18 | print "#define "+val[0]+" "+val[1] 19 | 20 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/extractTypes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0=[] 11 | for line in fileinput.input(): 12 | if re.search("typedef",line) and re.search("GL",line) and not re.search("PFN",line): 13 | data0+=[' '.join(line.split())] 14 | 15 | print "#include" 16 | print "#include" 17 | for x in data0: 18 | print x 19 | print "struct _cl_context;" 20 | print "struct _cl_event;" 21 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateAllFunction.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -e "#define GL_GLEXT_PROTOTYPES\n" | cat - /usr/include/GL/gl.h /usr/include/GL/glext.h | ./decomment.py | ./depreprocess.py | ./matchbrackes.py | ./getFunctions.py | ./glFuncFormater.py | sort #| ./glExtensionFilter.py 4 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateCheckOpenFunctions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def printTrapFunctionTest(data): 17 | params = data.split(",") 18 | print "if("+"table->"+params[1]+" == nullptr)table->"+params[1]+" = geglTrap"+params[1]+";" 19 | 20 | for x in data0: 21 | printTrapFunctionTest(x) 22 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateContextCalls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def getReturn(type): 17 | if type == "void" or type == "GLvoid": 18 | return "" 19 | return "return " 20 | 21 | def printContextCall(data): 22 | params = data.split(",") 23 | args = ",".join(map(lambda x:x[0]+" "+x[1],zip(params[2::2],params[3::2]))) 24 | params2 = map(lambda x:re.sub(r"\[.*\]","",x),params); 25 | print params[0]+" "+"ge::gl::Context::"+params[1]+"("+args+")const{"+getReturn(params[0])+"this->getFunctionTable()->"+params[1]+"("+",".join(params2[3::2])+");}" 26 | 27 | for x in data0: 28 | printContextCall(x) 29 | 30 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateContextDeclarations.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def getReturn(type): 17 | if type == "void" or type == "GLvoid": 18 | return "" 19 | return "return " 20 | 21 | def printContextDeclaration(data): 22 | params = data.split(",") 23 | args = ",".join(map(lambda x:x[0]+" "+x[1],zip(params[2::2],params[3::2]))) 24 | params2 = map(lambda x:re.sub(r"\[.*\]","",x),params); 25 | print "GEGL_EXPORT "+params[0]+" "+params[1]+"("+args+")const;" 26 | 27 | for x in data0: 28 | printContextDeclaration(x) 29 | 30 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateCoreFunction.py: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo -e "#define GL_GLEXT_PROTOTYPES\n" | cat - glcorearb.h | ./decomment.py | ./matchbrackes.py | g++ -E - | grep "extern" | grep -v "ARB" | sed "s/extern //g" | ./glFuncFormater.py | grep "gl" 3 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateFunctionTableCalls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def getReturn(type): 17 | if type == "void" or type == "GLvoid": 18 | return "" 19 | return "return " 20 | 21 | def printFunctionTableCall(data): 22 | params = data.split(",") 23 | args = ",".join(map(lambda x:x[0]+" "+x[1],zip(params[2::2],params[3::2]))) 24 | params2 = map(lambda x:re.sub(r"\[.*\]","",x),params); 25 | print "inline "+params[0]+" "+params[1]+"("+args+")const{"+getReturn(params[0])+"(this->*(this->m_ptr_"+params[1]+"))("+",".join(params2[3::2])+");}" 26 | 27 | for x in data0: 28 | printFunctionTableCall(x) 29 | 30 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateFunctions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def printFunction(data): 17 | params = data.split(",") 18 | pfn = ("pfn"+params[1]+"proc").upper() 19 | #print "#if !defined("+pfn+")" 20 | print pfn+" "+"m_"+params[1]+";"#" = nullptr;" 21 | #print "#endif" 22 | 23 | for x in data0: 24 | printFunction(x) 25 | 26 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateLoadFunctions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def printLoadFunction(data): 17 | params = data.split(",") 18 | pfn = ("pfn"+params[1]+"proc").upper() 19 | print "table->"+params[1]+" = ("+"OpenGLFunctionTable::"+pfn+")getProcAddress(\""+params[1]+"\");" 20 | 21 | for x in data0: 22 | printLoadFunction(x) 23 | 24 | 25 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateLoaderImplementation.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def getReturn(type): 17 | if type == "void" or type == "GLvoid": 18 | return "" 19 | return "return " 20 | 21 | def printFunctionImplementation(data): 22 | params = data.split(",") 23 | args = ",".join(map(lambda x:x[0]+" "+x[1],zip(params[2::2],params[3::2]))) 24 | params2 = map(lambda x:re.sub(r"\[.*\]","",x),params); 25 | print params[0]+" m_"+params[1]+"_impl("+args+")const{"+getReturn(params[0])+"this->m_"+params[1]+"("+",".join(params2[3::2])+");}" 26 | 27 | 28 | for x in data0: 29 | printFunctionImplementation(x) 30 | 31 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateLoaderLoadingCalls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | #def getReturn(type): 17 | # if type == "void" or type == "GLvoid": 18 | # return "" 19 | # return "return " 20 | # 21 | #def printLoadingCall(data): 22 | # params = data.split(",") 23 | # pfn = ("pfn"+params[1]+"proc").upper() 24 | # memberpfn = ("memberpfn"+params[1]+"proc").upper() 25 | # print "this->m_"+params[1]+" = (FunctionTable::"+pfn+")this->m_functionLoader->load(\""+params[1]+"\");" 26 | # print "if(this->m_"+params[1]+")this->m_ptr_"+params[1]+" = (FunctionTable::"+memberpfn+")&LoaderTableDecorator::m_"+params[1]+"_impl;" 27 | # 28 | #for x in data0: 29 | # printLoadingCall(x) 30 | 31 | 32 | print "using MEMBER_FUNCTION_POINTER = void(FunctionTable::*)();" 33 | 34 | print "char const* functionNames[] = {" 35 | for line in data0: 36 | print " \""+line.split(",")[1]+"\"," 37 | print "};" 38 | 39 | print "MEMBER_FUNCTION_POINTER const functionPointers[] = {" 40 | for line in data0: 41 | print " (MEMBER_FUNCTION_POINTER)(&LoaderTableDecorator::m_"+line.split(",")[1]+"_impl)," 42 | print "};" 43 | 44 | firstFunction = data0[0].split(",")[1] 45 | 46 | print "FUNCTION_POINTER *baseFunctions = (FUNCTION_POINTER*)&this->FunctionTable::m_"+firstFunction+";" 47 | print "for(size_t i=0;im_functionLoader->load(functionNames[i]);" 49 | print "MEMBER_FUNCTION_POINTER *memberFunctions = (MEMBER_FUNCTION_POINTER*)&this->FunctionTable::m_ptr_"+firstFunction+";" 50 | print "for(size_t i=0;i_getTable()->"+params[1]+"("+",".join(params[3::2])+");}" 25 | 26 | for x in data0: 27 | printCall(x) 28 | 29 | 30 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generatePFN.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def printPFN(data): 17 | params = data.split(",") 18 | pfn = ("pfn"+params[1]+"proc").upper() 19 | i = 2; 20 | while i"+params[1]+"("+",".join(params2[3::2])+");}" 26 | 27 | print "#include" 28 | print "#include" 29 | 30 | for x in data0: 31 | printContextCall(x) 32 | 33 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateStaticDeclarations.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def getReturn(type): 17 | if type == "void" or type == "GLvoid": 18 | return "" 19 | return "return " 20 | 21 | def printContextDeclaration(data): 22 | params = data.split(",") 23 | args = ",".join(map(lambda x:x[0]+" "+x[1],zip(params[2::2],params[3::2]))) 24 | params2 = map(lambda x:re.sub(r"\[.*\]","",x),params); 25 | print " GEGL_EXPORT "+params[0]+" "+params[1]+"("+args+");" 26 | 27 | print "#include" 28 | print "namespace ge{" 29 | print " namespace gl{" 30 | for x in data0: 31 | printContextDeclaration(x) 32 | print " }" 33 | print "}" 34 | 35 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateTrapCalls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def getReturn(type): 17 | if type == "void" or type == "GLvoid": 18 | return "" 19 | return "return " 20 | 21 | def printTrapCall(data): 22 | params = data.split(",") 23 | pfn = ("memberpfn"+params[1]+"proc").upper() 24 | print "if(!this->m_ptr_"+params[1]+")this->m_ptr_"+params[1]+" = (FunctionTable::"+pfn+")&TrapTableDecorator::m_"+params[1]+"_trap;" 25 | 26 | for x in data0: 27 | printTrapCall(x) 28 | 29 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/generateTrapImplementation.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def getReturn(type): 17 | if type == "void" or type == "GLvoid": 18 | return "" 19 | return "return " 20 | 21 | def printTrapImplementation(data): 22 | params = data.split(",") 23 | i = 2; 24 | while im_printMissingFunctionErrorAndExit(\""+params[1]+"\");return ("+params[0]+")0;}" 29 | 30 | 31 | for x in data0: 32 | printTrapImplementation(x) 33 | 34 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/getFunctions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | #if len(sys.argv)<2: 8 | # sys.exit(0) 9 | 10 | import fileinput 11 | from subprocess import Popen, PIPE 12 | 13 | data0="" 14 | for line in fileinput.input(): 15 | data0+=line 16 | 17 | 18 | for i in data0.split("\n"): 19 | if i.find("default")<0: 20 | continue 21 | print re.sub(r"^[^ ]* ","",i) 22 | 23 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/glExtensionFilter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | #ext = re.compile(r"AMD|NV|ATI|IBM|HP|EXT|ARB|OES|SUN|SGI|MESA|INTEL|APPLE|3DFX|GREMEDY|OVR|PGI|INGR|KHR|\[") 15 | ext = re.compile(r"AMD|NV|ATI|IBM|HP|ARB|OES|SUN|SGI|MESA|INTEL|APPLE|3DFX|GREMEDY|OVR|PGI|INGR|KHR|\[") 16 | 17 | for i in data0.split("\n"): 18 | if ext.findall(i)!=[]: 19 | continue 20 | if i=="": 21 | continue 22 | print i 23 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/glFuncFormater.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | #if len(sys.argv)<2: 8 | # sys.exit(0) 9 | 10 | import fileinput 11 | from subprocess import Popen, PIPE 12 | 13 | data0="" 14 | for line in fileinput.input(): 15 | data0+=line 16 | 17 | data0=data0.split("\n") 18 | 19 | data1 = map(lambda x:re.sub(r" ,",r",",re.sub(r", ",r",",re.sub(r"\* ","*",re.sub(r" \*","*",x)))),data0) 20 | data2 = map(lambda x:re.sub(r"([a-zA-Z0-9_* ]*?[a-zA-Z0-9_*]+) ? ?(gl[a-zA-Z0-9_]*) ?\( ?(.*) ?\);",r"\1,\2,\3",x),data1) 21 | data2 = map(lambda x:re.sub(r"\s*$","",x),data2) 22 | data3 = list(set(data2)) 23 | 24 | #for i in data3: 25 | # if i=="": 26 | # continue 27 | # if len(i.split(","))==3 and i.split(",")[2]=="void": 28 | # print ",".join(i.split(",")[:-1]) 29 | # else: 30 | # print i 31 | 32 | def genTypeName(string): 33 | spacepos=string.rfind(" "); 34 | starpos =string.rfind("*"); 35 | if(spacepos>starpos): 36 | return (string[:string.rfind(" ")],string[string.rfind(" ")+1:]) 37 | else: 38 | return (string[:string.rfind("*")+1],string[string.rfind("*")+1:]) 39 | 40 | listOfFCE=[] 41 | 42 | for i in data3: 43 | if i=="": 44 | continue 45 | components = i.split(",") 46 | final = "" 47 | if components[0][-1]==" ": 48 | final+=components[0][:-1] 49 | else: 50 | final+=components[0] 51 | final+=","+components[1] 52 | for j in components[2:]: 53 | if j!="void": 54 | final+=","+genTypeName(j)[0] 55 | final+=","+genTypeName(j)[1] 56 | listOfFCE+=[final] 57 | 58 | uniqListofFCE=dict() 59 | for i in listOfFCE: 60 | uniqListofFCE[i.split(",")[1]]=i 61 | 62 | 63 | for i in uniqListofFCE.keys(): 64 | print uniqListofFCE[i] 65 | 66 | 67 | #for i in listOfFCE: 68 | # print i 69 | 70 | 71 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/matchbrackes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | #if len(sys.argv)<2: 8 | # sys.exit(0) 9 | 10 | import fileinput 11 | from subprocess import Popen, PIPE 12 | 13 | data0="" 14 | for line in fileinput.input(): 15 | data0+=line 16 | 17 | data0 = re.sub(r"/\*.*?\*/","",data0,flags=re.DOTALL) 18 | 19 | 20 | closed="" 21 | depth=0 22 | for i in data0: 23 | if i=="\n" and depth!=0: 24 | continue 25 | if i=="(": 26 | depth+=1 27 | if i==")": 28 | depth-=1 29 | closed+=i 30 | 31 | data0=re.sub(r"[ \t]+"," ",closed,flags=0) 32 | 33 | print data0 34 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/printHEADER.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | 8 | if len(sys.argv)<2: 9 | exit(0) 10 | 11 | print "#define GL_GLEXT_PROTOTYPES" 12 | for x in sys.argv[1:]: 13 | print open(x).read() 14 | -------------------------------------------------------------------------------- /geGL/scripts/subscripts/trapGenerator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | import os 6 | 7 | import fileinput 8 | from subprocess import Popen, PIPE 9 | 10 | data0="" 11 | for line in fileinput.input(): 12 | data0+=line 13 | 14 | data0=data0.split("\n")[:-1] 15 | 16 | def printTrapFunctions(data): 17 | params = data.split(",") 18 | print "GEGL_EXPORT "+params[0]+" geglTrap"+params[1]+"("+",".join(params[2::2])+"){printMissingFunctionError(\""+params[1]+"\");std::exit(1);return ("+params[0]+")0;}" 19 | 20 | 21 | 22 | print "GEGL_EXPORT void printMissingFunctionError(char const*fce){std::cerr<<\"Function \"< 4 | 5 | class ge::gl::AsynchronousQuery: public OpenGLObject{ 6 | public: 7 | enum ResultSize{ 8 | INT32 , 9 | UINT32, 10 | INT64 , 11 | UINT64, 12 | }; 13 | GEGL_EXPORT AsynchronousQuery(); 14 | GEGL_EXPORT void create( 15 | GLenum const&target , 16 | GLenum const&waitingType, 17 | ResultSize const&resultSize ); 18 | GEGL_EXPORT AsynchronousQuery( 19 | GLenum const&target , 20 | GLenum const&waitingType, 21 | ResultSize const&resultSize ); 22 | GEGL_EXPORT AsynchronousQuery( 23 | AsynchronousQuery const*const&existingQuery); 24 | GEGL_EXPORT AsynchronousQuery( 25 | FunctionTablePointer const&table , 26 | GLenum const&target , 27 | GLenum const&waitingType, 28 | ResultSize const&resultSize ); 29 | GEGL_EXPORT AsynchronousQuery( 30 | FunctionTablePointer const&table , 31 | AsynchronousQuery const*const&existingQuery); 32 | GEGL_EXPORT ~AsynchronousQuery(); 33 | GEGL_EXPORT void begin(); 34 | GEGL_EXPORT void end (); 35 | GEGL_EXPORT void begin(GLuint const&index); 36 | GEGL_EXPORT void end (GLuint const&index); 37 | GEGL_EXPORT GLuint64 getui64 ()const; 38 | GEGL_EXPORT GLint64 geti64 ()const; 39 | GEGL_EXPORT GLuint getui ()const; 40 | GEGL_EXPORT GLint geti ()const; 41 | GEGL_EXPORT GLenum getTarget ()const; 42 | GEGL_EXPORT GLenum getWaitingType()const; 43 | protected: 44 | /** 45 | * @brief 46 | * GL_ANY_SAMPLES_PASSED 47 | * GL_ANY_SAMPLES_PASSED_CONSERVATIVE 48 | * GL_PRIMITIVES_GENERATED 49 | * GL_SAMPLES_PASSED 50 | * GL_TIME_ELAPSED 51 | * GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 52 | */ 53 | GLenum _target; 54 | /** 55 | * @brief 56 | * GL_QUERY_RESULT 57 | * GL_QUERY_RESULT_AVAILABLE 58 | * GL_QUERy_RESULT_NO_WAIT 59 | */ 60 | GLenum _waitingType; 61 | GLint _datai32 ;/// 4 | #include 5 | 6 | namespace ge{ 7 | namespace gl{ 8 | GEGL_EXPORT void setDefaultDebugMessage( 9 | ContextPointer const&gl = nullptr); 10 | GEGL_EXPORT void setLowAndGreaterDebugMessage( 11 | ContextPointer const&gl = nullptr); 12 | GEGL_EXPORT void setMediumAndGreaterDebugMessage( 13 | ContextPointer const&gl = nullptr); 14 | GEGL_EXPORT void setHighDebugMessage( 15 | ContextPointer const&gl = nullptr); 16 | GEGL_EXPORT void setDebugMessage( 17 | GLDEBUGPROC fce, 18 | void*data, 19 | ContextPointer const&gl = nullptr); 20 | }//gl 21 | }//ge 22 | 23 | -------------------------------------------------------------------------------- /geGL/src/geGL/DefaultLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace ge{ 6 | namespace gl{ 7 | class DefaultLoader: public FunctionLoaderInterface{ 8 | public: 9 | /** 10 | * @brief constructor 11 | * 12 | * @param getProcAddress loading function like (SDL_GL_GetProcAddress, wglGetProcAddress, ...) 13 | */ 14 | DefaultLoader(GET_PROC_ADDRESS getProcAddress){ 15 | this->m_getProcAddress = getProcAddress; 16 | } 17 | ~DefaultLoader(){} 18 | /** 19 | * @brief This function loads OpenGL function using its name 20 | * 21 | * @param fceName function name of OpenGL fuction ("glUseProgram", ...) 22 | * 23 | * @return function pointer to requested OpenGL function 24 | */ 25 | virtual FUNCTION_POINTER load(char const*fceName)const override{ 26 | return ((FUNCTION_POINTER(*)(char const*))this->m_getProcAddress)(fceName); 27 | } 28 | protected: 29 | GET_PROC_ADDRESS m_getProcAddress = nullptr; 30 | }; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /geGL/src/geGL/Definitions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _MSC_VER 4 | #define SIZED_VARIADIC_PARAMS(NAME,SIZE)\ 5 | typename...NAME, typename std::enable_if::type = 0 6 | #else 7 | #define SIZED_VARIADIC_PARAMS(NAME)\ 8 | typename...NAME 9 | #endif//immature Visual Studio compiler... 10 | 11 | -------------------------------------------------------------------------------- /geGL/src/geGL/FunctionLoaderInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ge{ 4 | namespace gl{ 5 | typedef void(*FUNCTION_POINTER)(); 6 | typedef void*(*GET_PROC_ADDRESS)(char const*); 7 | class FunctionLoaderInterface{ 8 | public: 9 | FunctionLoaderInterface(){} 10 | virtual ~FunctionLoaderInterface(){} 11 | virtual FUNCTION_POINTER load(char const*fceName)const = 0; 12 | }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /geGL/src/geGL/Fwd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace ge{ 6 | namespace gl{ 7 | class FunctionTable; 8 | using FunctionTablePointer = std::shared_ptr; 9 | class FunctionLoaderInterface; 10 | using FunctionLoaderInterfacePointer = std::shared_ptr; 11 | class Context; 12 | using ContextPointer = std::shared_ptr; 13 | class OpenGLObject; 14 | class OpenGLObjectImpl; 15 | class Buffer; 16 | class BufferImpl; 17 | class Program; 18 | class ProgramImpl; 19 | class Shader; 20 | class ShaderImpl; 21 | class Texture; 22 | class VertexArray; 23 | class VertexArrayImpl; 24 | class AsynchronousQuery; 25 | class Framebuffer; 26 | class ProgramPipeline; 27 | class Sampler; 28 | class Renderbuffer; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /geGL/src/geGL/GLSLNoise.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ge{ 7 | namespace gl{ 8 | GEGL_EXPORT std::string getNoiseSource(); 9 | GEGL_EXPORT std::string getGradientSource(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /geGL/src/geGL/Generated/NumberOfFunctions.h: -------------------------------------------------------------------------------- 1 | size_t const GE_GL_NOF_OPENGL_FUNCTIONS = 2926; 2 | -------------------------------------------------------------------------------- /geGL/src/geGL/Generated/OpenGLTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | typedef unsigned int GLenum; 5 | typedef unsigned char GLboolean; 6 | typedef unsigned int GLbitfield; 7 | typedef void GLvoid; 8 | typedef signed char GLbyte; 9 | typedef short GLshort; 10 | typedef int GLint; 11 | typedef unsigned char GLubyte; 12 | typedef unsigned short GLushort; 13 | typedef unsigned int GLuint; 14 | typedef int GLsizei; 15 | typedef float GLfloat; 16 | typedef float GLclampf; 17 | typedef double GLdouble; 18 | typedef double GLclampd; 19 | typedef ptrdiff_t GLsizeiptr; 20 | typedef ptrdiff_t GLintptr; 21 | typedef char GLchar; 22 | typedef unsigned short GLhalf; 23 | typedef struct __GLsync *GLsync; 24 | typedef uint64_t GLuint64; 25 | typedef int64_t GLint64; 26 | typedef void ( *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); 27 | typedef uint64_t GLuint64EXT; 28 | typedef void ( *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); 29 | typedef unsigned short GLhalfARB; 30 | #if __APPLE__ 31 | typedef void* GLhandleARB; 32 | #else 33 | typedef unsigned int GLhandleARB; 34 | #endif 35 | typedef char GLcharARB; 36 | typedef ptrdiff_t GLsizeiptrARB; 37 | typedef ptrdiff_t GLintptrARB; 38 | typedef GLint GLfixed; 39 | typedef void ( *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); 40 | typedef int64_t GLint64EXT; 41 | typedef void *GLeglClientBufferEXT; 42 | typedef void ( *GLVULKANPROCNV)(void); 43 | typedef unsigned short GLhalfNV; 44 | typedef GLintptr GLvdpauSurfaceNV; 45 | typedef void* GLeglImageOES; 46 | struct _cl_context; 47 | struct _cl_event; 48 | -------------------------------------------------------------------------------- /geGL/src/geGL/LoaderTableDecorator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ge{ 8 | namespace gl{ 9 | template 10 | class LoaderTableDecorator: public T{ 11 | public: 12 | template 13 | LoaderTableDecorator( 14 | std::shared_ptrconst&functionLoader, 15 | ARGS&&...args):T(args...){ 16 | assert(this!=nullptr); 17 | this->m_functionLoader = functionLoader; 18 | } 19 | virtual ~LoaderTableDecorator(){} 20 | protected: 21 | std::shared_ptrm_functionLoader = nullptr; 22 | virtual bool m_init(){ 23 | assert(this!=nullptr); 24 | if(!T::m_init())return false; 25 | assert(this->m_functionLoader!=nullptr); 26 | #include 27 | return true; 28 | } 29 | #include 30 | }; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGL.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | thread_local ge::gl::FunctionTablePointer _defaultOpenGLFunctionTable = nullptr; 12 | thread_local ge::gl::ContextPointer _defaultOpenGLContext = nullptr; 13 | 14 | using namespace ge::gl; 15 | 16 | /** 17 | * @brief Function returns default, global OpenGLFunctionTable 18 | * 19 | * @return default OpenGLFunctionTable 20 | */ 21 | ge::gl::FunctionTablePointer const&ge::gl::getDefaultFunctionTable(){ 22 | return _defaultOpenGLFunctionTable; 23 | } 24 | 25 | /** 26 | * @brief Function returns default OpenGLContext 27 | * 28 | * @return default OpenGLfunctionProvider 29 | */ 30 | ge::gl::ContextPointer const& ge::gl::getDefaultContext(){ 31 | return _defaultOpenGLContext; 32 | } 33 | 34 | /** 35 | * @brief Function sets default, global OpenGLFunctionTable 36 | * 37 | * @param OpenGLFunctionTable 38 | */ 39 | void ge::gl::setDefaultFunctionTable (FunctionTablePointer const&table ){ 40 | _defaultOpenGLFunctionTable = table; 41 | if(_defaultOpenGLContext) 42 | _defaultOpenGLContext->setFunctionTable(table); 43 | } 44 | 45 | /** 46 | * @brief Function sets default, global OpenGLContext 47 | * 48 | * @param provider OpenGLContext 49 | */ 50 | void ge::gl::setDefaultContext(ContextPointer const&provider){ 51 | _defaultOpenGLContext = provider; 52 | } 53 | 54 | /** 55 | * @brief Function creates OpenGL function table 56 | * Function table is decorated using LoaderTableDecorator, DSATableDecorator, CapabilitiesTableDecorator and TrapTableDecorator 57 | * 58 | * @param loader valid FunctionLoaderInterface that can load OpenGL functions 59 | * 60 | * @return OpenGLFunctionTable 61 | */ 62 | FunctionTablePointer ge::gl::createTable(FunctionLoaderInterfacePointer const&loader){ 63 | auto table = std::make_shared< 64 | TrapTableDecorator< 65 | CapabilitiesTableDecorator< 66 | DSATableDecorator< 67 | LoaderTableDecorator< 68 | FunctionTable>>>>>(loader); 69 | table->construct(); 70 | return table; 71 | } 72 | 73 | /** 74 | * @brief Function creates Context instance 75 | * 76 | * @param table FunctionTable 77 | * 78 | * @return Context 79 | */ 80 | ContextPointer ge::gl::createContext(FunctionTablePointer const&table){ 81 | return std::make_shared(table); 82 | } 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGL.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * OpenGL part of geGL library contains two main objects - FunctionTable and Context 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace ge{ 16 | namespace gl{ 17 | GEGL_EXPORT FunctionTablePointer const& getDefaultFunctionTable(); 18 | GEGL_EXPORT ContextPointer const& getDefaultContext (); 19 | GEGL_EXPORT void setDefaultFunctionTable(FunctionTablePointer const&table ); 20 | GEGL_EXPORT void setDefaultContext (ContextPointer const&provider); 21 | GEGL_EXPORT FunctionTablePointer createTable(FunctionLoaderInterfacePointer const&loader); 22 | GEGL_EXPORT ContextPointer createContext(FunctionTablePointer const&table = nullptr); 23 | } 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGLCapabilities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ge{ 7 | namespace gl{ 8 | class GEGL_EXPORT Capabilities{ 9 | public: 10 | bool opengl200 = false; 11 | bool opengl210 = false; 12 | bool opengl300 = false; 13 | bool opengl310 = false; 14 | bool opengl320 = false; 15 | bool opengl330 = false; 16 | bool opengl400 = false; 17 | bool opengl410 = false; 18 | bool opengl420 = false; 19 | bool opengl430 = false; 20 | bool opengl440 = false; 21 | bool opengl450 = false; 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGLContext.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace ge::gl; 5 | 6 | Context::Context(FunctionTablePointer const&table){ 7 | assert(this!=nullptr); 8 | if(table == nullptr)this->m_table = ge::gl::getDefaultFunctionTable(); 9 | else this->m_table = table; 10 | } 11 | 12 | #include 13 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGLContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class ge::gl::Context{ 7 | public: 8 | GEGL_EXPORT Context(FunctionTablePointer const&t = nullptr); 9 | GEGL_EXPORT ~Context(){} 10 | FunctionTablePointer const&getFunctionTable()const{ 11 | assert(this!=nullptr); 12 | return this->m_table; 13 | } 14 | void setFunctionTable(FunctionTablePointer const&t){ 15 | assert(this!=nullptr); 16 | this->m_table = t; 17 | } 18 | #include 19 | private: 20 | FunctionTablePointer m_table = nullptr; 21 | }; 22 | 23 | 24 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGLFunctionTable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace ge{ 9 | namespace gl{ 10 | class FunctionTable{ 11 | public: 12 | using FUNCTION_POINTER = void(*)(); 13 | using MEMBER_FUNCTION_POINTER = void(FunctionTable::*)(); 14 | FunctionTable(){} 15 | virtual ~FunctionTable(){} 16 | bool construct(){ 17 | assert(this!=nullptr); 18 | return this->m_init(); 19 | } 20 | virtual bool m_init(){return true;} 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | }; 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGLObject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace ge::gl; 5 | 6 | class ge::gl::OpenGLObjectImpl { 7 | public: 8 | GLuint id = 0u;///impl->getId(); 38 | } 39 | 40 | GLuint&OpenGLObject::getId(){ 41 | assert(this != nullptr); 42 | return this->impl->getId(); 43 | } 44 | 45 | ge::gl::Context const&OpenGLObject::getContext()const{ 46 | return this->impl->getContext(); 47 | } 48 | -------------------------------------------------------------------------------- /geGL/src/geGL/OpenGLObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class GEGL_EXPORT ge::gl::OpenGLObject{ 6 | public: 7 | OpenGLObject(GLuint id = 0u); 8 | OpenGLObject(FunctionTablePointer const&table,GLuint id = 0u); 9 | virtual ~OpenGLObject(); 10 | GLuint getId()const; 11 | GLuint&getId(); 12 | Context const&getContext()const; 13 | OpenGLObject(OpenGLObject const&) = delete; 14 | private: 15 | OpenGLObjectImpl*impl = nullptr; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /geGL/src/geGL/ProgramInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace ge{ 11 | namespace gl{ 12 | class ProgramInfo; 13 | } 14 | } 15 | 16 | class ge::gl::ProgramInfo{ 17 | public: 18 | using Properties = 19 | std::tuple< 20 | GLint , 21 | GLenum , 22 | std::string, 23 | GLint >; 24 | enum PropertiesParts{ 25 | LOCATION = 0, 26 | TYPE = 1, 27 | NAME = 2, 28 | SIZE = 3, 29 | }; 30 | 31 | using BufferProperties = std::tuple< 32 | std::string, 33 | GLint , 34 | GLint , 35 | GLint , 36 | GLint , 37 | GLint , 38 | GLint , 39 | GLint , 40 | GLint , 41 | GLint >; 42 | enum BufferPropertiesParts{ 43 | BUFFER_NAME = 0, 44 | BUFFER_BINDING = 1, 45 | BUFFER_DATA_SIZE = 2, 46 | BUFFER_NOF_ACTIVE_VARIABLES = 3, 47 | BUFFER_REFERENCED_BY_VERTEX_SHADER = 4, 48 | BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER = 5, 49 | BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER = 6, 50 | BUFFER_REFERENCED_BY_GEOMETRY_SHADER = 7, 51 | BUFFER_REFERENCED_BY_FRAGMENT_SHADER = 8, 52 | BUFFER_REFERENCED_BY_COMPUTE_SHADER = 9, 53 | }; 54 | 55 | using SubroutineUniformProperties = std::tuple< 56 | GLint , 57 | GLint , 58 | GLint , 59 | std::string, 60 | GLuint >; 61 | enum SubroutineUniformPropertiesParts{ 62 | SUBROUTINE_UNIFORM_LOCATION = 0, 63 | SUBROUTINE_UNIFORM_SIZE = 1, 64 | SUBROUTINE_UNIFORM_COMPATIBLE = 2, 65 | SUBROUTINE_UNIFORM_NAME = 3, 66 | SUBROUTINE_UNIFORM_INDEX = 4, 67 | }; 68 | 69 | std::mapattribs ; 70 | std::mapuniforms ; 71 | std::mapbuffers ; 72 | std::mapsubroutineUniforms; 73 | 74 | }; 75 | -------------------------------------------------------------------------------- /geGL/src/geGL/ProgramPipeline.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace ge::gl; 4 | 5 | ProgramPipeline::ProgramPipeline(){ 6 | assert(this!=nullptr); 7 | this->getContext().glCreateProgramPipelines(1,&this->getId()); 8 | } 9 | 10 | ProgramPipeline::ProgramPipeline( 11 | FunctionTablePointer const&table):OpenGLObject(table){ 12 | assert(this!=nullptr); 13 | this->getContext().glCreateProgramPipelines(1,&this->getId()); 14 | } 15 | 16 | ProgramPipeline::~ProgramPipeline(){ 17 | assert(this!=nullptr); 18 | this->getContext().glDeleteProgramPipelines(1,&this->getId()); 19 | } 20 | 21 | void ProgramPipeline::bind()const{ 22 | assert(this!=nullptr); 23 | this->getContext().glBindProgramPipeline(this->getId()); 24 | } 25 | 26 | void ProgramPipeline::unbind()const{ 27 | assert(this!=nullptr); 28 | this->getContext().glBindProgramPipeline(0); 29 | } 30 | void ProgramPipeline::useProgramStages(GLbitfield stages,GLuint program)const{ 31 | assert(this!=nullptr); 32 | this->getContext().glUseProgramStages(this->getId(),stages,program); 33 | } 34 | void ProgramPipeline::useVertexStage (GLuint program)const{ 35 | assert(this!=nullptr); 36 | this->getContext().glUseProgramStages(this->getId(),GL_VERTEX_SHADER_BIT,program); 37 | } 38 | void ProgramPipeline::useControlStage (GLuint program)const{ 39 | assert(this!=nullptr); 40 | this->getContext().glUseProgramStages(this->getId(),GL_TESS_CONTROL_SHADER_BIT,program); 41 | } 42 | void ProgramPipeline::useEvaluationStage(GLuint program)const{ 43 | assert(this!=nullptr); 44 | this->getContext().glUseProgramStages(this->getId(),GL_TESS_EVALUATION_SHADER_BIT,program); 45 | } 46 | void ProgramPipeline::useGeometryStage (GLuint program)const{ 47 | assert(this!=nullptr); 48 | this->getContext().glUseProgramStages(this->getId(),GL_GEOMETRY_SHADER_BIT,program); 49 | } 50 | void ProgramPipeline::useFragmentStage (GLuint program)const{ 51 | assert(this!=nullptr); 52 | this->getContext().glUseProgramStages(this->getId(),GL_FRAGMENT_SHADER_BIT,program); 53 | } 54 | void ProgramPipeline::useComputeStage (GLuint program)const{ 55 | assert(this!=nullptr); 56 | this->getContext().glUseProgramStages(this->getId(),GL_COMPUTE_SHADER_BIT,program); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /geGL/src/geGL/ProgramPipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ge::gl::ProgramPipeline: public OpenGLObject{ 6 | public: 7 | GEGL_EXPORT ProgramPipeline(); 8 | GEGL_EXPORT ProgramPipeline(FunctionTablePointer const&table); 9 | GEGL_EXPORT ~ProgramPipeline(); 10 | GEGL_EXPORT void bind()const; 11 | GEGL_EXPORT void unbind()const; 12 | GEGL_EXPORT void useProgramStages(GLbitfield stages,GLuint program)const; 13 | GEGL_EXPORT void useVertexStage (GLuint program)const; 14 | GEGL_EXPORT void useControlStage (GLuint program)const; 15 | GEGL_EXPORT void useEvaluationStage(GLuint program)const; 16 | GEGL_EXPORT void useGeometryStage (GLuint program)const; 17 | GEGL_EXPORT void useFragmentStage (GLuint program)const; 18 | GEGL_EXPORT void useComputeStage (GLuint program)const; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /geGL/src/geGL/Renderbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class ge::gl::Renderbuffer: public OpenGLObject{ 7 | public: 8 | GEGL_EXPORT Renderbuffer(); 9 | GEGL_EXPORT Renderbuffer( 10 | GLenum const&internalFormat , 11 | GLsizei const&width , 12 | GLsizei const&height , 13 | GLsizei const&samples = 0); 14 | GEGL_EXPORT Renderbuffer( 15 | FunctionTablePointer const&table , 16 | GLenum const&internalFormat , 17 | GLsizei const&width , 18 | GLsizei const&height , 19 | GLsizei const&samples = 0); 20 | GEGL_EXPORT ~Renderbuffer(); 21 | GEGL_EXPORT void setStorage( 22 | GLenum const&internalFormat , 23 | GLsizei const&width , 24 | GLsizei const&height , 25 | GLsizei const&samples = 0)const; 26 | GEGL_EXPORT void bind ()const; 27 | GEGL_EXPORT void unbind ()const; 28 | GEGL_EXPORT GLint getWidth ()const; 29 | GEGL_EXPORT GLint getHeight ()const; 30 | GEGL_EXPORT GLenum getInternalFormat()const; 31 | GEGL_EXPORT GLint getSamples ()const; 32 | GEGL_EXPORT GLint getRedSize ()const; 33 | GEGL_EXPORT GLint getGreenSize ()const; 34 | GEGL_EXPORT GLint getBlueSize ()const; 35 | GEGL_EXPORT GLint getAlphaSize ()const; 36 | GEGL_EXPORT GLint getDepthSize ()const; 37 | GEGL_EXPORT GLint getStencilSize ()const; 38 | enum InternalFormat{ 39 | RED = GL_RED , 40 | RG = GL_RG , 41 | RGB = GL_RGB , 42 | RGBA = GL_RGBA , 43 | RGBA32F = GL_RGBA32F , 44 | RGBA32UI = GL_RGBA32UI , 45 | DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16 , 46 | DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24 , 47 | DEPTH_COMPONENT32 = GL_DEPTH_COMPONENT32 , 48 | DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F, 49 | DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8 , 50 | DEPTH32F_STENCIL8 = GL_DEPTH32F_STENCIL8 , 51 | STENCIL_INDEX1 = GL_STENCIL_INDEX1 , 52 | STENCIL_INDEX4 = GL_STENCIL_INDEX4 , 53 | STENCIL_INDEX8 = GL_STENCIL_INDEX8 , 54 | STENCIL_INDEX16 = GL_STENCIL_INDEX16 , 55 | }; 56 | protected: 57 | GLint _getParamateri(GLenum pname)const; 58 | std::set_framebuffers; 59 | friend class Framebuffer; 60 | }; 61 | 62 | -------------------------------------------------------------------------------- /geGL/src/geGL/Sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /** 6 | * @brief table 23.18 7 | */ 8 | class ge::gl::Sampler: public OpenGLObject{ 9 | public: 10 | GEGL_EXPORT Sampler (); 11 | GEGL_EXPORT Sampler (Sampler*sampler); 12 | GEGL_EXPORT Sampler (FunctionTablePointer const&table); 13 | GEGL_EXPORT Sampler ( 14 | FunctionTablePointer const&table, 15 | Sampler*sampler); 16 | GEGL_EXPORT ~Sampler(); 17 | GEGL_EXPORT void setBorderColor(GLfloat const*const&color )const; 18 | GEGL_EXPORT void setCompareFunc(GLenum const&func )const; 19 | GEGL_EXPORT void setCompareMode(GLenum const&mode )const; 20 | GEGL_EXPORT void setLodBias (GLfloat const&lodBias )const; 21 | GEGL_EXPORT void setMinLod (GLfloat const&minLod )const; 22 | GEGL_EXPORT void setMaxLod (GLfloat const&maxLod )const; 23 | GEGL_EXPORT void setMinFilter (GLenum const&minFilter)const; 24 | GEGL_EXPORT void setMagFilter (GLenum const&magFilter)const; 25 | GEGL_EXPORT void setWrapS (GLenum const&wrapS )const; 26 | GEGL_EXPORT void setWrapT (GLenum const&wrapT )const; 27 | GEGL_EXPORT void setWrapR (GLenum const&wrapR )const; 28 | GEGL_EXPORT void getBorderColor(GLfloat *const&constcolor)const; 29 | GEGL_EXPORT GLenum getCompareFunc()const; 30 | GEGL_EXPORT GLenum getCompareMode()const; 31 | GEGL_EXPORT GLfloat getLodBias ()const; 32 | GEGL_EXPORT GLfloat getMinLod ()const; 33 | GEGL_EXPORT GLfloat getMaxLod ()const; 34 | GEGL_EXPORT GLenum getMinFilter ()const; 35 | GEGL_EXPORT GLenum getMagFilter ()const; 36 | GEGL_EXPORT GLenum getWrapS ()const; 37 | GEGL_EXPORT GLenum getWrapT ()const; 38 | GEGL_EXPORT GLenum getWrapR ()const; 39 | GEGL_EXPORT void bind (GLuint const&unit)const; 40 | GEGL_EXPORT void unbind(GLuint const&unit)const; 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /geGL/src/geGL/TrapTableDecorator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ge{ 7 | namespace gl{ 8 | template 9 | class TrapTableDecorator: public T{ 10 | public: 11 | template 12 | TrapTableDecorator(ARGS&&...args):T(args...){} 13 | virtual~TrapTableDecorator(){} 14 | protected: 15 | virtual bool m_init(){ 16 | assert(this!=nullptr); 17 | if(!T::m_init())return false; 18 | #include 19 | return true; 20 | } 21 | void m_printMissingFunctionErrorAndExit(std::string fceName)const{ 22 | std::cerr<<"ERROR: function: "< 26 | }; 27 | 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /geGL/src/geGL/geGL.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | void ge::gl::init(std::shared_ptrconst&loader){ 12 | auto table = ge::gl::createTable(loader); 13 | ge::gl::setDefaultFunctionTable(table); 14 | ge::gl::setDefaultContext(ge::gl::createContext(table)); 15 | } 16 | 17 | void ge::gl::init(GET_PROC_ADDRESS getProcAddress){ 18 | auto loader = std::make_shared(getProcAddress); 19 | init(loader); 20 | } 21 | 22 | void*ge::gl::getProcAddress(char const*name){ 23 | static OpenGLFunctionLoader loader{}; 24 | return loader(name); 25 | } 26 | -------------------------------------------------------------------------------- /geGL/src/geGL/geGL.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * geGL library contains 10 OpenGLObject. 3 | * All are derived from OpenGLObject. 4 | * OpenGLObject class is derived from FunctionProvider that provides OpenGL. 5 | * 6 | * ┌───────┐ 7 | * │Context│ 8 | * └────△──┘ 9 | * ┌──────┴─────┐ 10 | * │OpenGLObject│ 11 | * └──────△─────┘ 12 | * ┌───────────────┬──────────┴──┬─────────────┬──────────┬─────┐ 13 | * ┌────────┴────────┐ ┌──┴───┐ ┌─────┴─────┐ ┌───┴──┐ ┌───┴───┐ │ 14 | * │AsynchronousQuery│ │Buffer│ │Framebuffer│ │Shader│ │Program│ │ 15 | * └─────────────────┘ └──────┘ └───────────┘ └──────┘ └───────┘ │ 16 | * ┌────────────┬────────┬──────────┬─────────────┬──────────────┘ 17 | * ┌───────┴───────┐┌───┴───┐┌───┴───┐┌─────┴──────┐┌─────┴─────┐ 18 | * │ProgramPipeline││Texture││Sampler││Renderbuffer││VertexArray│ 19 | * └───────────────┘└───────┘└───────┘└────────────┘└───────────┘ 20 | * 21 | * geGL library also contains OpenGL debug message handling, 22 | * FunctionTable and FunctionProvider classes and FunctionTable decorators. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | namespace ge{ 42 | namespace gl{ 43 | /** 44 | * @brief This function returns pointers to opengl functions 45 | * 46 | * @param name name of opengl function 47 | * 48 | * @return pointer to opengl function 49 | */ 50 | GEGL_EXPORT void*getProcAddress(char const*name); 51 | 52 | /** 53 | * @brief This function initialises geGL library. 54 | * It requires FunctionLoader object that can load OpenGL functions 55 | * 56 | * @param loader function loader (see DefaultLoader.h) 57 | */ 58 | GEGL_EXPORT void init( 59 | std::shared_ptrconst&loader); 60 | /** 61 | * @brief This function initialises geGL library 62 | * It requires getProcAddress such as SDL_GL_GetProcAddress or wglGetProcAddress or glxGetProcAddress ... 63 | * 64 | * @param getProc function that takes name of opengl function and returns its address 65 | */ 66 | GEGL_EXPORT void init(GET_PROC_ADDRESS getProc = getProcAddress); 67 | 68 | } 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/BufferImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class ge::gl::BufferImpl { 7 | public: 8 | BufferImpl(Buffer* b); 9 | ~BufferImpl(); 10 | GLint getBufferParameter(GLenum pname) const; 11 | GLint64 getBufferParameter64(GLenum pname) const; 12 | GLvoid* getBufferPointer(GLenum pname) const; 13 | void bufferData(GLsizeiptr size, GLvoid const* data, GLbitfield flags) const; 14 | void updateVertexArrays(); 15 | void realloc(GLsizeiptr size, Buffer::ReallocFlags f); 16 | void resizeBuffer(GLsizeiptr size, GLbitfield flags); 17 | void resizeBufferKeepData(GLsizeiptr size, GLbitfield flags); 18 | void resizeBufferKeepDataKeepId(GLsizeiptr size, GLbitfield flags); 19 | void newBuffer(GLsizeiptr size, GLbitfield flags); 20 | void removeReferences(); 21 | Buffer* buffer = nullptr; 22 | std::set vertexArrays; 23 | }; 24 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/ProgramImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class ge::gl::ProgramImpl { 9 | public: 10 | using ShaderPointer = std::shared_ptr; 11 | std::setshaders; 12 | std::mapname2Uniform; 13 | std::shared_ptrinfo; 14 | }; -------------------------------------------------------------------------------- /geGL/src/geGL/private/ShaderImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class ge::gl::ShaderImpl { 7 | public: 8 | std::setprograms; 9 | }; 10 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/VertexArrayImpl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace ge::gl; 6 | 7 | VertexArrayImpl::VertexArrayImpl(VertexArray*v):vao(v){ 8 | vao->getContext().glCreateVertexArrays(1,&vao->getId()); 9 | } 10 | 11 | VertexArrayImpl::~VertexArrayImpl(){ 12 | vao->getContext().glDeleteVertexArrays(1,&vao->getId()); 13 | removeReferencesFromBuffers(); 14 | removeReferenceFromElementBuffer(); 15 | } 16 | 17 | size_t VertexArrayImpl::getNofBufferUsages(Buffer const*buffer)const{ 18 | size_t counter = size_t(elementBuffer == buffer); 19 | for(auto const&x:buffers) 20 | if(x==buffer)++counter; 21 | return counter; 22 | } 23 | 24 | GLint VertexArrayImpl::getAttrib(GLuint index,GLenum pname)const{ 25 | GLint param; 26 | vao->getContext().glGetVertexArrayIndexediv(vao->getId(),index,pname,¶m); 27 | return param; 28 | } 29 | 30 | void VertexArrayImpl::addElementBuffer(Buffer*buffer){ 31 | removeReferenceFromElementBufferIfItIsOnlyReference(); 32 | elementBuffer = buffer; 33 | addReferenceToBuffer(buffer); 34 | vao->getContext().glVertexArrayElementBuffer(vao->getId(), buffer->getId()); 35 | } 36 | 37 | void VertexArrayImpl::removeReferencesFromBuffers(){ 38 | for(auto const&x:buffers) 39 | if(x)x->impl->vertexArrays.erase(vao); 40 | } 41 | 42 | void VertexArrayImpl::removeReferenceFromElementBuffer(){ 43 | if(elementBuffer)elementBuffer->impl->vertexArrays.erase(vao); 44 | } 45 | 46 | void VertexArrayImpl::removeReferenceFromElementBufferIfItIsOnlyReference(){ 47 | if (!elementBuffer) return; 48 | size_t nofBufferUsages = getNofBufferUsages(elementBuffer); 49 | if (nofBufferUsages == 1) 50 | elementBuffer->impl->vertexArrays.erase(vao); 51 | } 52 | 53 | void VertexArrayImpl::addReferenceToBuffer(Buffer*buffer)const{ 54 | buffer->impl->vertexArrays.insert(vao); 55 | } 56 | 57 | void VertexArrayImpl::resizeBuffersForIndex(GLuint index){ 58 | if (index >= buffers.size()) buffers.resize(index + 1, nullptr); 59 | } 60 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/VertexArrayImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class ge::gl::VertexArrayImpl { 7 | public: 8 | VertexArrayImpl(VertexArray*v); 9 | ~VertexArrayImpl(); 10 | size_t getNofBufferUsages(Buffer const* buffer) const; 11 | GLint getAttrib(GLuint index, GLenum pname) const; 12 | void addElementBuffer(Buffer*buffer); 13 | void removeReferencesFromBuffers(); 14 | void removeReferenceFromElementBuffer(); 15 | void removeReferenceFromElementBufferIfItIsOnlyReference(); 16 | void addReferenceToBuffer(Buffer*buffer)const; 17 | void resizeBuffersForIndex(GLuint index); 18 | std::vectorbuffers; 19 | Buffer*elementBuffer = nullptr; 20 | VertexArray*vao = nullptr; 21 | }; 22 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/global.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | thread_local ge::gl::Global ge::gl::global; 4 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/global.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ge{ 7 | namespace gl{ 8 | class Global; 9 | extern thread_local ge::gl::Global global; 10 | } 11 | } 12 | 13 | class ge::gl::Global{ 14 | public: 15 | FunctionTablePointer table = nullptr; 16 | ContextPointer context = nullptr; 17 | }; 18 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/linux_OpenGLFunctionLoader.cpp: -------------------------------------------------------------------------------- 1 | #ifdef __linux__ 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | void* ge::gl::OpenGLFunctionLoader::operator()(char const* name) 8 | { 9 | const string libName = "libGL.so.1"; 10 | const string getProcAddressName = "glXGetProcAddress"; 11 | if (!triedToLoadOpenGL) { 12 | triedToLoadOpenGL = true; 13 | openglLib = dlopen(libName.c_str(), RTLD_LAZY); 14 | } 15 | if (!triedToLoadGetProcAddress) { 16 | triedToLoadGetProcAddress = true; 17 | if (openglLib) 18 | reinterpret_cast(glXGetProcAddress) = 19 | dlsym(openglLib, getProcAddressName.c_str()); 20 | else 21 | throw runtime_error( 22 | "geGL::OpenGLFunctionLoader::operator() - cannot open " + libName); 23 | } 24 | if (!glXGetProcAddress) { 25 | throw runtime_error( 26 | "geGL::OpenGLFunctionLoader::operator() - cannot load " + 27 | getProcAddressName); 28 | return nullptr; 29 | } 30 | return (void*)glXGetProcAddress((uint8_t const*)(name)); 31 | } 32 | 33 | ge::gl::OpenGLFunctionLoader::~OpenGLFunctionLoader() 34 | { 35 | if (openglLib) dlclose(openglLib); 36 | openglLib = nullptr; 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/linux_OpenGLFunctionLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __linux__ 4 | 5 | namespace ge{ 6 | namespace gl{ 7 | class OpenGLFunctionLoader; 8 | } 9 | } 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | class GEGL_EXPORT ge::gl::OpenGLFunctionLoader{ 17 | protected: 18 | bool triedToLoadOpenGL = false; 19 | bool triedToLoadGetProcAddress = false; 20 | void*openglLib = nullptr; 21 | using PROC = void(*)(); 22 | using GETPROCTYPE = PROC(*)(uint8_t const*); 23 | GETPROCTYPE glXGetProcAddress = nullptr; 24 | public: 25 | void*operator()(char const*name); 26 | ~OpenGLFunctionLoader(); 27 | }; 28 | #endif 29 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/mac_OpenGLFunctionLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __APPLE__ 4 | 5 | class ge::gl::OpenGLFunctionLoader { 6 | public: 7 | void* operator()(char const* name); 8 | ~OpenGLFunctionLoader(); 9 | 10 | protected: 11 | bool triedToLoadOpenGL = false; 12 | void* openglLib = nullptr; 13 | }; 14 | #endif 15 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/windows_OpenGLFunctionLoader.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | void* ge::gl::OpenGLFunctionLoader::operator()(char const* name) 10 | { 11 | assert(this != nullptr); 12 | const string libName = "opengl32.dll"; 13 | const string getProcAddressName = "wglGetProcAddress"; 14 | if (!triedToLoadOpenGL) { 15 | triedToLoadOpenGL = true; 16 | openglLib = LoadLibrary(TEXT(libName.c_str())); 17 | } 18 | if (!triedToLoadGetProcAddress) { 19 | triedToLoadGetProcAddress = true; 20 | if (openglLib) 21 | wglGetProcAddress = (WGLGETPROCADDRESS)GetProcAddress( 22 | openglLib, TEXT(getProcAddressName.c_str())); 23 | else 24 | throw runtime_error( 25 | string("geGL::OpenGLFunctionLoader::operator() - cannot open ") + 26 | libName); 27 | } 28 | if (!wglGetProcAddress) { 29 | throw runtime_error( 30 | string("geGL::OpenGLFunctionLoader::operator() - cannot load ") + 31 | getProcAddressName); 32 | return nullptr; 33 | } 34 | auto ret = (void*)wglGetProcAddress(name); 35 | if (ret) return ret; 36 | return (void*)GetProcAddress(openglLib, TEXT(name)); 37 | } 38 | 39 | ge::gl::OpenGLFunctionLoader::~OpenGLFunctionLoader() 40 | { 41 | if (openglLib) FreeLibrary(openglLib); 42 | openglLib = nullptr; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /geGL/src/geGL/private/windows_OpenGLFunctionLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef _MSC_VER 4 | #define WIN32_LEAN_AND_MEAN 5 | #include 6 | #include 7 | 8 | 9 | namespace ge{ 10 | namespace gl{ 11 | class OpenGLFunctionLoader; 12 | } 13 | } 14 | 15 | class GEGL_EXPORT ge::gl::OpenGLFunctionLoader{ 16 | public: 17 | void*operator()(char const*name); 18 | ~OpenGLFunctionLoader(); 19 | protected: 20 | bool triedToLoadOpenGL = false; 21 | bool triedToLoadGetProcAddress = false; 22 | HMODULE openglLib = nullptr; 23 | using PROC = int(*)(); 24 | using WGLGETPROCADDRESS = PROC(__stdcall*)(LPCSTR); 25 | WGLGETPROCADDRESS wglGetProcAddress = nullptr; 26 | }; 27 | #endif 28 | -------------------------------------------------------------------------------- /geGL/tests/BufferTests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace ge::gl; 6 | using namespace std; 7 | 8 | TEST_CASE("Buffer Tests"){ 9 | SDLWin win; 10 | win.beginFrame(); 11 | ge::gl::init(); 12 | { 13 | float data[4] = {1.f,2.f,3.f,4.f}; 14 | auto b = make_shared(4*sizeof(float),data); 15 | REQUIRE(b->getSize() == 4*sizeof(float)); 16 | data[0] = data[1] = data[2] = data[3] = 0.f; 17 | b->getData(data); 18 | REQUIRE(data[0] == 1.f); 19 | REQUIRE(data[1] == 2.f); 20 | REQUIRE(data[2] == 3.f); 21 | REQUIRE(data[3] == 4.f); 22 | data[0] = data[1] = data[2] = data[3] = 10.f; 23 | b->setData(data); 24 | data[0] = data[1] = data[2] = data[3] = 0.f; 25 | b->getData(data); 26 | REQUIRE(data[0] == 10.f); 27 | REQUIRE(data[1] == 10.f); 28 | REQUIRE(data[2] == 10.f); 29 | REQUIRE(data[3] == 10.f); 30 | data[0] = data[1] = data[2] = data[3] = 100.f; 31 | b->setData(data,sizeof(float)*2,sizeof(float)*2); 32 | data[0] = data[1] = data[2] = data[3] = 0.f; 33 | b->getData(data); 34 | REQUIRE(data[0] == 10.f); 35 | REQUIRE(data[1] == 10.f); 36 | REQUIRE(data[2] == 100.f); 37 | REQUIRE(data[3] == 100.f); 38 | auto c = make_shared(3*sizeof(float)); 39 | c->copy(*b); 40 | data[0] = data[1] = data[2] = data[3] = 0.f; 41 | c->getData(data); 42 | REQUIRE(data[0] == 10.f); 43 | REQUIRE(data[1] == 10.f); 44 | REQUIRE(data[2] == 100.f); 45 | REQUIRE(data[3] == 0.f); 46 | auto oldId = c->getId(); 47 | c->realloc(10*sizeof(float),Buffer::KEEP_DATA_ID); 48 | REQUIRE(c->getSize() == 10*sizeof(float)); 49 | REQUIRE(c->getId() == oldId); 50 | float dd[10]; 51 | for(int i=0;i<10;++i)dd[i] = 0.f; 52 | c->getData(dd); 53 | REQUIRE(dd[0] == 10.f); 54 | REQUIRE(dd[1] == 10.f); 55 | REQUIRE(dd[2] == 100.f); 56 | oldId = c->getId(); 57 | c->realloc(sizeof(float),Buffer::KEEP_ID); 58 | REQUIRE(c->getSize() == sizeof(float)); 59 | REQUIRE(c->getId() == oldId); 60 | } 61 | win.endFrame(); 62 | } 63 | 64 | TEST_CASE("BufferSize"){ 65 | SDLWin win; 66 | win.beginFrame(); 67 | ge::gl::init(); 68 | { 69 | std::cerr << "sizeof(GLsizeiptr): " << sizeof(GLsizeiptr) << std::endl; 70 | size_t const size = 1024ull*1024ull*1024ull*3ull; 71 | auto b = make_shared(size); 72 | REQUIRE(b->getSize() == size); 73 | } 74 | win.endFrame(); 75 | } 76 | -------------------------------------------------------------------------------- /geGL/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12.1) 2 | 3 | find_package(SDL2 2.0.9 CONFIG REQUIRED) 4 | 5 | add_executable(tests TestsMain.cpp SDLWin.h SDLWin.cpp catch.hpp BufferTests.cpp ComputeShaderTests.cpp ProgramTests.cpp blitTests.cpp) 6 | 7 | target_link_libraries(tests geGL::geGL SDL2::SDL2 SDL2::SDL2main) 8 | 9 | -------------------------------------------------------------------------------- /geGL/tests/SDLWin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class SDLWinImpl; 4 | class SDLWin{ 5 | public: 6 | enum ContextType{ 7 | CORE, 8 | COMPATIBILITY, 9 | ES, 10 | }; 11 | SDLWin(int w=1,int h=1,int version = 450,ContextType type = CORE); 12 | ~SDLWin(); 13 | void beginFrame(); 14 | void endFrame(); 15 | private: 16 | SDLWinImpl*impl = nullptr; 17 | }; 18 | -------------------------------------------------------------------------------- /geGL/tests/TestsMain.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include 3 | -------------------------------------------------------------------------------- /geGL/tests/blitTests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace ge::gl; 7 | using namespace std; 8 | 9 | GLuint createDepthTex(uint32_t w,uint32_t h){ 10 | GLuint id; 11 | REQUIRE(glGetError() == GL_NO_ERROR); 12 | glCreateTextures(GL_TEXTURE_RECTANGLE,1,&id); 13 | REQUIRE(glGetError() == GL_NO_ERROR); 14 | glTextureStorage2D(id,1,GL_DEPTH_COMPONENT24,w,h); 15 | REQUIRE(glGetError() == GL_NO_ERROR); 16 | return id; 17 | } 18 | 19 | void clear(GLuint id,float a){ 20 | glClearTexImage(id,0,GL_DEPTH_COMPONENT,GL_FLOAT,&a); 21 | REQUIRE(glGetError() == GL_NO_ERROR); 22 | } 23 | 24 | float getTexel(GLuint id,uint32_t w,uint32_t h){ 25 | std::vectord(w*h); 26 | glGetTextureImage(id,0,GL_DEPTH_COMPONENT,GL_FLOAT,sizeof(float)*d.size(),d.data()); 27 | REQUIRE(glGetError() == GL_NO_ERROR); 28 | return d.at(0); 29 | } 30 | 31 | GLuint createDepthFrame(GLuint tex){ 32 | GLuint id; 33 | REQUIRE(glGetError() == GL_NO_ERROR); 34 | glCreateFramebuffers(1,&id); 35 | REQUIRE(glGetError() == GL_NO_ERROR); 36 | glNamedFramebufferTexture(id,GL_DEPTH_ATTACHMENT,tex,0); 37 | REQUIRE(glGetError() == GL_NO_ERROR); 38 | return id; 39 | } 40 | 41 | TEST_CASE("blitTests"){ 42 | SDLWin win; 43 | win.beginFrame(); 44 | ge::gl::init(); 45 | ge::gl::setHighDebugMessage(); 46 | { 47 | int const w=10; 48 | int const h=10; 49 | GLuint id = createDepthTex(w,h); 50 | clear(id,1.f); 51 | 52 | auto d = getTexel(id,w,h); 53 | REQUIRE(d==1.f); 54 | 55 | GLuint tid = createDepthTex(w,h); 56 | clear(tid,0.f); 57 | REQUIRE(getTexel(tid,w,h) == 0.f); 58 | 59 | auto fid = createDepthFrame(id); 60 | auto ftid = createDepthFrame(tid); 61 | glBlitNamedFramebuffer(fid,ftid,0,0,w,h,0,0,w,h,GL_DEPTH_BUFFER_BIT,GL_NEAREST); 62 | REQUIRE(glGetError() == GL_NO_ERROR); 63 | REQUIRE(getTexel(tid,w,h) == 1.f); 64 | 65 | 66 | glDeleteTextures(1,&id); 67 | REQUIRE(glGetError() == GL_NO_ERROR); 68 | } 69 | win.endFrame(); 70 | } 71 | -------------------------------------------------------------------------------- /geSG/geSGConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | 4 | if(NOT TARGET @PROJECT_NAME@) 5 | 6 | foreach(_dep @Dependencies@) 7 | if(NOT TARGET ${_dep}) 8 | find_dependency(${_dep} HINTS "${CMAKE_CURRENT_LIST_DIR}/../") 9 | endif() 10 | endforeach() 11 | 12 | include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake) 13 | 14 | endif(NOT TARGET @PROJECT_NAME@) -------------------------------------------------------------------------------- /geSG/src/geSG/AABB.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace ge::sg; 5 | 6 | AABB::AABB(const AABB& other): min(other.min) 7 | , max(other.max) 8 | { 9 | } 10 | 11 | void AABB::expand(const glm::vec3& p) 12 | { 13 | min.x = min.x <= p.x ? min.x : p.x; 14 | min.y = min.y <= p.y ? min.y : p.y; 15 | min.z = min.z <= p.z ? min.z : p.z; 16 | 17 | max.x = max.x >= p.x ? max.x : p.x; 18 | max.y = max.y >= p.y ? max.y : p.y; 19 | max.z = max.z >= p.z ? max.z : p.z; 20 | } 21 | 22 | void AABB::expand(const std::array& p) 23 | { 24 | min.x = min.x <= p[0] ? min.x : p[0]; 25 | min.y = min.y <= p[1] ? min.y : p[1]; 26 | min.z = min.z <= p[2] ? min.z : p[2]; 27 | 28 | max.x = max.x >= p[0] ? max.x : p[0]; 29 | max.y = max.y >= p[1] ? max.y : p[1]; 30 | max.z = max.z >= p[2] ? max.z : p[2]; 31 | } 32 | 33 | void AABB::expand(const AABB& aabb) 34 | { 35 | min.x = min.x <= aabb.min.x ? min.x : aabb.min.x; 36 | min.y = min.y <= aabb.min.y ? min.y : aabb.min.y; 37 | min.z = min.z <= aabb.min.z ? min.z : aabb.min.z; 38 | 39 | max.x = max.x >= aabb.max.x ? max.x : aabb.max.x; 40 | max.y = max.y >= aabb.max.y ? max.y : aabb.max.y; 41 | max.z = max.z >= aabb.max.z ? max.z : aabb.max.z; 42 | } 43 | -------------------------------------------------------------------------------- /geSG/src/geSG/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace std 8 | { 9 | template class array; 10 | } 11 | 12 | namespace ge 13 | { 14 | namespace sg 15 | { 16 | class GESG_EXPORT AABB : public BoundingVolume 17 | { 18 | public: 19 | AABB() = default; 20 | 21 | AABB(const AABB& other); 22 | 23 | void expand(const glm::vec3& p); 24 | void expand(const std::array& p); 25 | 26 | void expand(const AABB& aabb); 27 | 28 | glm::vec3 min; 29 | glm::vec3 max; 30 | }; 31 | 32 | template 33 | class AABBTemplate : public AABB 34 | { 35 | public: 36 | AABBTemplate() 37 | :AABB() 38 | {} 39 | 40 | AABBTemplate(const AABBTemplate& other) 41 | : AABB(other) 42 | , insideThing(other.insideThing) 43 | {} 44 | 45 | Insides insideThing; 46 | }; 47 | } 48 | } -------------------------------------------------------------------------------- /geSG/src/geSG/Animation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace ge::sg; 7 | using namespace ge::core; 8 | 9 | Animation::Animation() 10 | : mode(Mode::ONCE) 11 | , duration(time_unit(0)) 12 | { 13 | } 14 | 15 | /** 16 | * Computes duration, sets start time to t and calls update with t. If the animation has no channels nothing is done. 17 | * The duration is computed as maximum time value (t) of all keyframes of all channels. 18 | * \param t 19 | */ 20 | void Animation::start(const time_point& t) 21 | { 22 | startTime = t; 23 | if(channels.empty()) { 24 | duration = time_unit(0); 25 | return; 26 | } 27 | auto it = std::max_element(channels.begin(), channels.end(), [](const std::shared_ptr& a, const std::shared_ptr& b) { return a->getDuration() < b->getDuration(); }); 28 | duration = (**it).getDuration(); 29 | update(t); 30 | } 31 | 32 | /** 33 | * Use to update all animation channels. If the animation has no channels nothing is done. 34 | * @param t Is the simulation time resp. aplication gloab time. The start time is then substracted 35 | * from this t and determines the current animation (relative) time. All channels are fed 36 | * this relative time. 37 | * 38 | */ 39 | void Animation::update(const time_point& t) 40 | { 41 | time_unit anim_time(std::chrono::duration_cast(t - startTime)); //relative time -> 0.0 is when the animation starts 42 | switch (mode) 43 | { 44 | case Mode::LOOP: 45 | anim_time = duration > time_unit(0) ? time_unit(fmod(anim_time.count(),duration.count())) : time_unit(0); 46 | break; 47 | case Mode::ONCE: 48 | default: 49 | anim_time = std::min(anim_time,duration); 50 | break; 51 | } 52 | 53 | currentTime = time_point(anim_time); 54 | 55 | for (auto channel : channels) 56 | { 57 | channel->update(currentTime); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /geSG/src/geSG/Animation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace ge 11 | { 12 | namespace sg{ 13 | class AnimationChannel; 14 | 15 | /** 16 | * Basic animation which groups particular channels. The init 17 | * should set the duration, mode and add some channels. Befor each 18 | * replay you need to set start time to 0 (default constructed time_point). 19 | * The correct startTime is properly on the first (of current replay) 20 | * update invocation. 21 | */ 22 | class GESG_EXPORT Animation : public ge::core::Updatable 23 | { 24 | public: 25 | ENUM_CLASS_FRIEND_OPERATOR(Mode, ONCE, LOOP); 26 | 27 | Animation(); 28 | 29 | template> 30 | void start(const std::chrono::duration& duration) 31 | { 32 | start(core::time_point(std::chrono::duration_cast(duration))); 33 | } 34 | 35 | virtual void start(const core::time_point& t = core::time_point()); 36 | 37 | template> 38 | void update(const std::chrono::duration& duration) 39 | { 40 | update(core::time_point(std::chrono::duration_cast(duration))); 41 | } 42 | 43 | void update(const core::time_point& t = core::time_point()) override; 44 | 45 | inline core::time_point getCurrentTime(){ return currentTime; } 46 | 47 | std::vector> channels; 48 | 49 | Mode mode; 50 | core::time_unit duration; 51 | 52 | core::time_point currentTime; //animation relative time 53 | core::time_point startTime; ///< simulation time of animation start 54 | protected: 55 | }; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /geSG/src/geSG/AnimationChannel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace ge::sg; 8 | using namespace ge::core; 9 | 10 | AnimationChannel::AnimationChannel() 11 | {} 12 | 13 | AnimationChannel::~AnimationChannel() 14 | {} 15 | 16 | /////////////////////////////////////////////////////////////////////////// 17 | 18 | /** 19 | * Sets up linear interpolator (LinearKeyframeInterpolator) for orientation and scale and 20 | * spherical linear interpolation (SlerpKeyframeInterpolator) for the orientation. 21 | */ 22 | MovementAnimationChannel::MovementAnimationChannel() 23 | : positionInterpolator(new ge::sg::LinearKeyframeInterpolator>()) 24 | , orientationInterpolator(new ge::sg::SlerpKeyframeInterpolator>()) 25 | , scaleInterpolator(new ge::sg::LinearKeyframeInterpolator>()) 26 | { 27 | 28 | } 29 | 30 | 31 | /** 32 | * Updates the target matrix. This function should not be called directly from the end user code. 33 | * It is better to use channels through Animation. 34 | * \param t Animation relative time. 35 | */ 36 | void MovementAnimationChannel::update(const time_point& t) 37 | { 38 | glm::vec3 position; 39 | glm::vec3 scale(1, 1, 1); 40 | glm::quat oriantation; 41 | 42 | position = positionInterpolator->interpolate(positionKF, TPtoFP(t)); 43 | if(!scaleKF.empty()) 44 | scale = scaleInterpolator->interpolate(scaleKF, TPtoFP(t)); 45 | oriantation = orientationInterpolator->interpolate(orientationKF, TPtoFP(t)); 46 | 47 | 48 | glm::mat4 mat = glm::mat4_cast(oriantation); 49 | mat = glm::scale(mat, scale); 50 | mat[3] = glm::vec4(position, 1.f); 51 | 52 | if(_target) 53 | *_target = mat; 54 | } 55 | 56 | 57 | /** 58 | * Computes the duration of this channel. It takes the maximal t from the last key frame of 59 | * all containers. 60 | * \return Duration in core::time_unit. 61 | */ 62 | time_unit MovementAnimationChannel::getDuration() const 63 | { 64 | std::array endFrameTimes; 65 | endFrameTimes[0] = positionKF.empty() ? time_point() : positionKF.back().getTime(); 66 | endFrameTimes[1] = orientationKF.empty() ? time_point() : orientationKF.back().getTime(); 67 | endFrameTimes[2] = scaleKF.empty() ? time_point() : scaleKF.back().getTime(); 68 | return std::chrono::duration_cast(std::max_element(endFrameTimes.begin(),endFrameTimes.end())->time_since_epoch()); 69 | } 70 | 71 | MovementAnimationChannel::~MovementAnimationChannel() 72 | { 73 | } 74 | -------------------------------------------------------------------------------- /geSG/src/geSG/AnimationManager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace ge::sg; 6 | using namespace ge::core; 7 | 8 | 9 | /** 10 | * Updates each animation to time point t. 11 | */ 12 | void AnimationManager::update(const time_point& t) 13 | { 14 | std::for_each(playlist.begin(), playlist.end(), [t](std::shared_ptr animation){animation->update(t); }); 15 | removeFinishedAnimation(); 16 | } 17 | 18 | /** 19 | * Not implemented. 20 | */ 21 | void AnimationManager::pauseAnimation(std::shared_ptr 22 | /*animation*/& ) 23 | { 24 | } 25 | 26 | /** 27 | * Adds the animation to the play list and starts the animation. 28 | */ 29 | void AnimationManager::playAnimation(std::shared_ptr& animation, const time_point& startTime) 30 | { 31 | auto it = std::find(playlist.begin(), playlist.end(), animation); 32 | if(it == playlist.end()) 33 | { 34 | playlist.push_back(animation); 35 | } 36 | animation->start(startTime); 37 | } 38 | 39 | /** 40 | * Removes finished animations from manager. This method is called at the end 41 | * of the update method. 42 | */ 43 | void AnimationManager::removeFinishedAnimation() 44 | { 45 | auto it = playlist.begin(); 46 | for(; it != playlist.end(); ) 47 | { 48 | if((*it)->getCurrentTime() >= time_point((*it)->duration) && (*it)->mode == Animation::Mode::ONCE) 49 | { 50 | auto rm = it; 51 | ++it; 52 | playlist.erase(rm); 53 | } 54 | else 55 | { 56 | ++it; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /geSG/src/geSG/AnimationManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace ge 12 | { 13 | namespace sg{ 14 | 15 | /** 16 | * Simple class responsible for playing (updating) animations. Only currently played 17 | * animations are held in the manager. When animation is done it is automaticaly removed. 18 | * 19 | */ 20 | class GESG_EXPORT AnimationManager: public core::Updatable 21 | { 22 | public: 23 | 24 | template> 25 | void playAnimation(std::shared_ptr& animation, const std::chrono::duration& duration) 26 | { 27 | playAnimation(animation, core::time_point(std::chrono::duration_cast(duration))); 28 | } 29 | 30 | template> 31 | void update(const std::chrono::duration& duration) 32 | { 33 | update(core::time_point(std::chrono::duration_cast(duration))); 34 | } 35 | 36 | virtual void update(const core::time_point& t) override; 37 | void pauseAnimation(std::shared_ptr& animation); 38 | void playAnimation(std::shared_ptr& animation, const core::time_point& startTime); 39 | 40 | virtual ~AnimationManager(){} 41 | 42 | protected: 43 | 44 | std::list> playlist; ///< list of all playing animation, needs to be list for convenient cleanup 45 | 46 | private: 47 | void removeFinishedAnimation(); 48 | 49 | }; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /geSG/src/geSG/AttributeDescriptor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace ge { 7 | namespace sg { 8 | 9 | /** 10 | * AttributeDescriptor manages vertex attribute data. 11 | * From OpenGL point of view, it represents vertex attrib pointer. 12 | */ 13 | struct AttributeDescriptor 14 | { 15 | idlist(DataType, UNKNOWN, BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT, UNSIGNED_INT, FLOAT, DOUBLE); 16 | 17 | unsigned getSize(DataType type) 18 | { 19 | switch(type) 20 | { 21 | case DataType::UNKNOWN: return 0; 22 | case DataType::BYTE: 23 | case DataType::UNSIGNED_BYTE: return sizeof(char); 24 | case DataType::SHORT: 25 | case DataType::UNSIGNED_SHORT: return sizeof(short); 26 | case DataType::INT: 27 | case DataType::UNSIGNED_INT: return sizeof(int); 28 | case DataType::FLOAT: return sizeof(float); 29 | case DataType::DOUBLE: return sizeof(double); 30 | default: return 0; 31 | } 32 | } 33 | 34 | idlist(Semantic, unknown, position, normal, color, texcoord, indices, tangent, binormal); 35 | 36 | int size = 0; ///< size of buffer AttributeDescriptor::data in bytes 37 | unsigned numComponents = 0; ///< number of vector component 38 | DataType type = DataType::UNKNOWN; ///< vector data type 39 | size_t stride = 0; 40 | size_t offset= 0; 41 | Semantic semantic = Semantic::unknown; 42 | std::shared_ptr data; ///< data buffer 43 | }; 44 | 45 | } // namespace sg 46 | } // namespace ge 47 | -------------------------------------------------------------------------------- /geSG/src/geSG/BoundingSphere.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace ge::sg; 6 | 7 | BoundingSphere::BoundingSphere(const BoundingSphere& other): center(other.center) 8 | , radius(other.radius) 9 | { 10 | } 11 | 12 | void BoundingSphere::transform(const glm::mat4& mat) 13 | { 14 | glm::vec4 pos(this->center, 1.0f); 15 | pos = mat * pos; 16 | glm::vec4 x(1, 0, 0, 0), y(0, 1, 0, 0), z(0, 0, 1, 0); 17 | x = mat * x; 18 | y = mat * y; 19 | z = mat * z; 20 | float maxScale = 0.0f; 21 | float lx = glm::length(x); 22 | float ly = glm::length(y); 23 | float lz = glm::length(z); 24 | maxScale = std::max(lx, ly); 25 | maxScale = std::max(maxScale, lz); 26 | this->center = glm::vec3(pos); 27 | this->radius *= maxScale; 28 | } 29 | -------------------------------------------------------------------------------- /geSG/src/geSG/BoundingSphere.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace ge 10 | { 11 | namespace sg 12 | { 13 | /** 14 | * Class representing Bounding Sphere. 15 | */ 16 | class GESG_EXPORT BoundingSphere : public BoundingVolume 17 | { 18 | public: 19 | BoundingSphere() = default; 20 | BoundingSphere(const BoundingSphere& other); 21 | 22 | /** 23 | * Transforms the BS with transform matrix. 24 | * 25 | */ 26 | void transform(const glm::mat4& mat); 27 | 28 | /** 29 | * Probably doesn't work yet. 30 | */ 31 | template