added new cmake setup, graphics, vendors, obj importer, etc.

This commit is contained in:
Daniel Ledda
2022-12-29 12:57:19 +01:00
parent 783f9ee055
commit e83185f011
30 changed files with 18711 additions and 116 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
/build
/emcc_build
/debug
.vscode

View File

@@ -1,24 +1,79 @@
cmake_minimum_required(VERSION 3.24)
project(somaesque)
set(VENDOR_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor")
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
#find_package(glfw3 3.3 REQUIRED)
#find_package(glm REQUIRED)
set(CMAKE_CXX_STANDARD 20)
#set(CMAKE_CXX_FLAGS -I/usr/include/SDL2)
add_executable(somaesque
main.cpp
VoxelSpace.cpp
VoxelSpace.h
SomaSolve.cpp
SomaSolve.h
option(GLFW_BUILD_DOCS OFF)
option(GLFW_BUILD_EXAMPLES OFF)
option(GLFW_BUILD_TESTS OFF)
option(GLFW_INSTALL OFF)
find_package(glfw3 3.3 REQUIRED)
find_package(glm REQUIRED)
# Glad
add_library(glad
STATIC
${VENDOR_DIR}/glad/glad.c
)
target_include_directories(glad
PUBLIC
${VENDOR_DIR}
)
# KHR
# STB
add_library(loaders
STATIC
${VENDOR_DIR}/loaders/tinyobj.cpp
${VENDOR_DIR}/loaders/stb_image.cpp
)
target_include_directories(loaders
PUBLIC
${VENDOR_DIR}
)
# somaesque
add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME}
PRIVATE
${SRC_DIR}/main.cpp
${SRC_DIR}/VoxelSpace.cpp
${SRC_DIR}/VoxelSpace.h
${SRC_DIR}/SomaSolve.cpp
${SRC_DIR}/SomaSolve.h
${SRC_DIR}/gfx/Texture.h
${SRC_DIR}/gfx/Texture.cpp
${SRC_DIR}/gfx/Mesh.h
${SRC_DIR}/gfx/Mesh.cpp
${SRC_DIR}/gfx/Shader.h
${SRC_DIR}/gfx/Shader.cpp
${SRC_DIR}/gfx/geometry.h
${SRC_DIR}/gfx/geometry.cpp
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
glfw
GL
X11
pthread
Xrandr
dl
glm::glm
glad
loaders
)
target_include_directories(somaesque
PUBLIC
${VENDOR_DIR}/KHR
)
#target_link_libraries(somaesque glfw GL X11 pthread Xrandr dl SDL2 glm::glm)
#target_include_directories(somaesque PRIVATE src/KHR src/glad)
# TESTING
include(FetchContent)
@@ -30,15 +85,14 @@ FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(tests
tests.cpp
VoxelSpace.cpp
VoxelSpace.h
${SRC_DIR}/tests.cpp
${SRC_DIR}/VoxelSpace.cpp
${SRC_DIR}/VoxelSpace.h
)
target_link_libraries(
tests
target_link_libraries(tests
GTest::gtest_main
)
)
include(GoogleTest)
gtest_discover_tests(tests)

674
assets/models/c000000.obj Normal file
View File

@@ -0,0 +1,674 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
o Cube_Cube.001
v 0.399961 0.500000 -0.399961
v 0.500000 0.399961 -0.399961
v 0.399961 0.399961 -0.500000
v 0.438244 0.492385 -0.399961
v 0.470699 0.470699 -0.399961
v 0.399961 0.492385 -0.438244
v 0.439203 0.483194 -0.439203
v 0.465612 0.465612 -0.437212
v 0.457718 0.457718 -0.457718
v 0.492385 0.399961 -0.438244
v 0.470699 0.399961 -0.470699
v 0.492385 0.438244 -0.399961
v 0.483194 0.439203 -0.439203
v 0.465612 0.437212 -0.465612
v 0.399961 0.438244 -0.492385
v 0.399961 0.470699 -0.470699
v 0.438244 0.399961 -0.492385
v 0.439203 0.439203 -0.483194
v 0.437212 0.465612 -0.465612
v 0.500000 -0.399961 -0.399961
v 0.399961 -0.500000 -0.399961
v 0.399961 -0.399961 -0.500000
v 0.492385 -0.438244 -0.399961
v 0.470699 -0.470699 -0.399961
v 0.492385 -0.399961 -0.438244
v 0.483194 -0.439203 -0.439203
v 0.465612 -0.465612 -0.437212
v 0.457718 -0.457718 -0.457718
v 0.399961 -0.492385 -0.438244
v 0.399961 -0.470699 -0.470699
v 0.438244 -0.492385 -0.399961
v 0.439203 -0.483194 -0.439203
v 0.437212 -0.465612 -0.465612
v 0.438244 -0.399961 -0.492385
v 0.470699 -0.399961 -0.470699
v 0.399961 -0.438244 -0.492385
v 0.439203 -0.439203 -0.483194
v 0.465612 -0.437212 -0.465612
v 0.500000 0.399961 0.399961
v 0.399961 0.500000 0.399961
v 0.399961 0.399961 0.500000
v 0.492385 0.438244 0.399961
v 0.470699 0.470699 0.399961
v 0.492385 0.399961 0.438244
v 0.483194 0.439203 0.439203
v 0.465612 0.465612 0.437212
v 0.457718 0.457718 0.457718
v 0.399961 0.492385 0.438244
v 0.399961 0.470699 0.470699
v 0.438244 0.492385 0.399961
v 0.439203 0.483194 0.439203
v 0.437212 0.465612 0.465612
v 0.438244 0.399961 0.492385
v 0.470699 0.399961 0.470699
v 0.399961 0.438244 0.492385
v 0.439203 0.439203 0.483194
v 0.465612 0.437212 0.465612
v 0.399961 -0.399961 0.500000
v 0.399961 -0.500000 0.399961
v 0.500000 -0.399961 0.399961
v 0.399961 -0.438244 0.492385
v 0.399961 -0.470699 0.470699
v 0.438244 -0.399961 0.492385
v 0.439203 -0.439203 0.483194
v 0.437212 -0.465612 0.465612
v 0.457718 -0.457718 0.457718
v 0.438244 -0.492385 0.399961
v 0.470699 -0.470699 0.399961
v 0.399961 -0.492385 0.438244
v 0.439203 -0.483194 0.439203
v 0.465612 -0.465612 0.437212
v 0.492385 -0.399961 0.438244
v 0.470699 -0.399961 0.470699
v 0.492385 -0.438244 0.399961
v 0.483194 -0.439203 0.439203
v 0.465612 -0.437212 0.465612
v -0.500000 0.399961 -0.399961
v -0.399961 0.500000 -0.399961
v -0.399961 0.399961 -0.500000
v -0.492385 0.438244 -0.399961
v -0.470699 0.470699 -0.399961
v -0.492385 0.399961 -0.438244
v -0.483194 0.439203 -0.439203
v -0.465612 0.465612 -0.437212
v -0.457718 0.457718 -0.457718
v -0.399961 0.492385 -0.438244
v -0.399961 0.470699 -0.470699
v -0.438244 0.492385 -0.399961
v -0.439203 0.483194 -0.439203
v -0.437212 0.465612 -0.465612
v -0.438244 0.399961 -0.492385
v -0.470699 0.399961 -0.470699
v -0.399961 0.438244 -0.492385
v -0.439203 0.439203 -0.483194
v -0.465612 0.437212 -0.465612
v -0.399961 -0.399961 -0.500000
v -0.399961 -0.500000 -0.399961
v -0.500000 -0.399961 -0.399961
v -0.399961 -0.438244 -0.492385
v -0.399961 -0.470699 -0.470699
v -0.438244 -0.399961 -0.492385
v -0.439203 -0.439203 -0.483194
v -0.437212 -0.465612 -0.465612
v -0.457718 -0.457718 -0.457718
v -0.438244 -0.492385 -0.399961
v -0.470699 -0.470699 -0.399961
v -0.399961 -0.492385 -0.438244
v -0.439203 -0.483194 -0.439203
v -0.465612 -0.465612 -0.437212
v -0.492385 -0.399961 -0.438244
v -0.470699 -0.399961 -0.470699
v -0.492385 -0.438244 -0.399961
v -0.483194 -0.439203 -0.439203
v -0.465612 -0.437212 -0.465612
v -0.500000 0.399961 0.399961
v -0.399961 0.399961 0.500000
v -0.399961 0.500000 0.399961
v -0.492385 0.399961 0.438244
v -0.470699 0.399961 0.470699
v -0.492385 0.438244 0.399961
v -0.483194 0.439203 0.439203
v -0.465612 0.437212 0.465612
v -0.457718 0.457718 0.457718
v -0.399961 0.438244 0.492385
v -0.399961 0.470699 0.470699
v -0.438244 0.399961 0.492385
v -0.439203 0.439203 0.483194
v -0.437212 0.465612 0.465612
v -0.438244 0.492385 0.399961
v -0.470699 0.470699 0.399961
v -0.399961 0.492385 0.438244
v -0.439203 0.483194 0.439203
v -0.465612 0.465612 0.437212
v -0.399961 -0.399961 0.500000
v -0.500000 -0.399961 0.399961
v -0.399961 -0.500000 0.399961
v -0.438244 -0.399961 0.492385
v -0.470699 -0.399961 0.470699
v -0.399961 -0.438244 0.492385
v -0.439203 -0.439203 0.483194
v -0.465612 -0.437212 0.465612
v -0.457718 -0.457718 0.457718
v -0.492385 -0.438244 0.399961
v -0.470699 -0.470699 0.399961
v -0.492385 -0.399961 0.438244
v -0.483194 -0.439203 0.439203
v -0.465612 -0.465612 0.437212
v -0.399961 -0.492385 0.438244
v -0.399961 -0.470699 0.470699
v -0.438244 -0.492385 0.399961
v -0.439203 -0.483194 0.439203
v -0.437212 -0.465612 0.465612
vt 0.150010 0.525010
vt 0.349990 0.525010
vt 0.349990 0.724990
vt 0.150010 0.724990
vt 0.650010 0.525010
vt 0.849990 0.525010
vt 0.849990 0.724990
vt 0.650010 0.724990
vt 0.400010 0.275010
vt 0.599990 0.275010
vt 0.599990 0.474990
vt 0.400010 0.474990
vt 0.400010 0.775010
vt 0.599990 0.775010
vt 0.599990 0.974990
vt 0.400010 0.974990
vt 0.400010 0.025010
vt 0.599990 0.025010
vt 0.599990 0.224990
vt 0.400010 0.224990
vt 0.400010 0.525010
vt 0.390439 0.525010
vt 0.390199 0.515199
vt 0.400010 0.515439
vt 0.375000 0.525010
vt 0.375000 0.515697
vt 0.390697 0.500000
vt 0.400010 0.500000
vt 0.375000 0.510570
vt 0.599990 0.265439
vt 0.609801 0.265199
vt 0.609561 0.275010
vt 0.599990 0.250000
vt 0.609303 0.250000
vt 0.625000 0.265697
vt 0.625000 0.275010
vt 0.614430 0.250000
vt 0.859561 0.724990
vt 0.859801 0.734801
vt 0.849990 0.734561
vt 0.875000 0.724990
vt 0.875000 0.734303
vt 0.859303 0.750000
vt 0.849990 0.750000
vt 0.875000 0.739430
vt 0.390439 0.275010
vt 0.390199 0.265199
vt 0.400010 0.265439
vt 0.375000 0.275010
vt 0.375000 0.265697
vt 0.390697 0.250000
vt 0.400010 0.250000
vt 0.375000 0.260570
vt 0.599990 0.015439
vt 0.609801 0.015199
vt 0.609561 0.025010
vt 0.599990 0.000000
vt 0.609303 0.000000
vt 0.625000 0.015697
vt 0.625000 0.025010
vt 0.614430 0.000000
vt 0.650010 0.734561
vt 0.640199 0.734801
vt 0.640439 0.724990
vt 0.650010 0.750000
vt 0.640697 0.750000
vt 0.625000 0.734303
vt 0.625000 0.724990
vt 0.635570 0.750000
vt 0.609561 0.474990
vt 0.609801 0.484801
vt 0.599990 0.484561
vt 0.625000 0.474990
vt 0.625000 0.484303
vt 0.609303 0.500000
vt 0.599990 0.500000
vt 0.625000 0.489430
vt 0.400010 0.724990
vt 0.400010 0.734561
vt 0.390199 0.734801
vt 0.390439 0.724990
vt 0.400010 0.750000
vt 0.390697 0.750000
vt 0.375000 0.734303
vt 0.375000 0.724990
vt 0.385570 0.750000
vt 0.349990 0.515439
vt 0.359801 0.515199
vt 0.359561 0.525010
vt 0.349990 0.500000
vt 0.359303 0.500000
vt 0.375000 0.515697
vt 0.375000 0.525010
vt 0.364430 0.500000
vt 0.140439 0.525010
vt 0.140199 0.515199
vt 0.150010 0.515439
vt 0.125000 0.525010
vt 0.125000 0.515697
vt 0.140697 0.500000
vt 0.150010 0.500000
vt 0.125000 0.510570
vt 0.609561 0.224990
vt 0.609801 0.234801
vt 0.599990 0.234561
vt 0.625000 0.224990
vt 0.625000 0.234303
vt 0.609303 0.250000
vt 0.599990 0.250000
vt 0.625000 0.239430
vt 0.400010 0.484561
vt 0.390199 0.484801
vt 0.390439 0.474990
vt 0.400010 0.500000
vt 0.390697 0.500000
vt 0.375000 0.484303
vt 0.375000 0.474990
vt 0.385570 0.500000
vt 0.609561 0.974990
vt 0.609801 0.984801
vt 0.599990 0.984561
vt 0.625000 0.974990
vt 0.625000 0.984303
vt 0.609303 1.000000
vt 0.599990 1.000000
vt 0.625000 0.989430
vt 0.599990 0.525010
vt 0.599990 0.515439
vt 0.609801 0.515199
vt 0.609561 0.525010
vt 0.599990 0.500000
vt 0.609303 0.500000
vt 0.625000 0.515697
vt 0.625000 0.525010
vt 0.614430 0.500000
vt 0.849990 0.515439
vt 0.859801 0.515199
vt 0.859561 0.525010
vt 0.849990 0.500000
vt 0.859303 0.500000
vt 0.875000 0.515697
vt 0.875000 0.525010
vt 0.864430 0.500000
vt 0.640439 0.525010
vt 0.640199 0.515199
vt 0.650010 0.515439
vt 0.625000 0.525010
vt 0.625000 0.515697
vt 0.640697 0.500000
vt 0.650010 0.500000
vt 0.625000 0.510570
vt 0.390439 0.025010
vt 0.390199 0.015199
vt 0.400010 0.015439
vt 0.375000 0.025010
vt 0.375000 0.015697
vt 0.390697 0.000000
vt 0.400010 0.000000
vt 0.375000 0.010570
vt 0.400010 0.984561
vt 0.390199 0.984801
vt 0.390439 0.974990
vt 0.400010 1.000000
vt 0.390697 1.000000
vt 0.375000 0.984303
vt 0.375000 0.974990
vt 0.385570 1.000000
vt 0.599990 0.765439
vt 0.609801 0.765199
vt 0.609561 0.775010
vt 0.599990 0.750000
vt 0.609303 0.750000
vt 0.625000 0.765697
vt 0.625000 0.775010
vt 0.614430 0.750000
vt 0.359561 0.724990
vt 0.359801 0.734801
vt 0.349990 0.734561
vt 0.375000 0.724990
vt 0.375000 0.734303
vt 0.359303 0.750000
vt 0.349990 0.750000
vt 0.375000 0.739430
vt 0.599990 0.724990
vt 0.609561 0.724990
vt 0.609801 0.734801
vt 0.599990 0.734561
vt 0.625000 0.724990
vt 0.625000 0.734303
vt 0.609303 0.750000
vt 0.599990 0.750000
vt 0.625000 0.739430
vt 0.150010 0.734561
vt 0.140199 0.734801
vt 0.140439 0.724990
vt 0.150010 0.750000
vt 0.140697 0.750000
vt 0.125000 0.734303
vt 0.125000 0.724990
vt 0.135570 0.750000
vt 0.390439 0.775010
vt 0.390199 0.765199
vt 0.400010 0.765439
vt 0.375000 0.775010
vt 0.375000 0.765697
vt 0.390697 0.750000
vt 0.400010 0.750000
vt 0.375000 0.760570
vt 0.400010 0.234561
vt 0.390199 0.234801
vt 0.390439 0.224990
vt 0.400010 0.250000
vt 0.390697 0.250000
vt 0.375000 0.234303
vt 0.375000 0.224990
vt 0.385570 0.250000
vn 0.1004 -0.1004 0.9899
vn 0.1004 0.1004 0.9899
vn -0.1004 0.1004 0.9899
vn -0.1004 -0.1004 0.9899
vn -0.1004 -0.1004 -0.9899
vn -0.1004 0.1004 -0.9899
vn 0.1004 0.1004 -0.9899
vn 0.1004 -0.1004 -0.9899
vn 0.9899 -0.1004 -0.1004
vn 0.9899 0.1004 -0.1004
vn 0.9899 0.1004 0.1004
vn 0.9899 -0.1004 0.1004
vn -0.9899 -0.1004 0.1004
vn -0.9899 0.1004 0.1004
vn -0.9899 0.1004 -0.1004
vn -0.9899 -0.1004 -0.1004
vn -0.1004 -0.9899 -0.1004
vn 0.1004 -0.9899 -0.1004
vn 0.1004 -0.9899 0.1004
vn -0.1004 -0.9899 0.1004
vn 0.1004 0.9899 -0.1004
vn 0.3792 0.9201 -0.0981
vn 0.3673 0.8545 -0.3673
vn 0.0981 0.9201 -0.3792
vn 0.7041 0.7041 -0.0919
vn 0.6663 0.6663 -0.3347
vn 0.3347 0.6663 -0.6663
vn 0.0919 0.7041 -0.7041
vn 0.5774 0.5774 -0.5774
vn 0.9201 0.0981 -0.3792
vn 0.8545 0.3673 -0.3673
vn 0.9201 0.3792 -0.0981
vn 0.7041 0.0919 -0.7041
vn 0.6663 0.3347 -0.6663
vn 0.0981 0.3792 -0.9201
vn 0.3673 0.3673 -0.8545
vn 0.3792 0.0981 -0.9201
vn 0.9201 -0.3792 -0.0981
vn 0.8545 -0.3673 -0.3673
vn 0.9201 -0.0981 -0.3792
vn 0.7041 -0.7041 -0.0919
vn 0.6663 -0.6663 -0.3347
vn 0.6663 -0.3347 -0.6663
vn 0.7041 -0.0919 -0.7041
vn 0.5774 -0.5774 -0.5773
vn 0.0981 -0.9201 -0.3792
vn 0.3673 -0.8545 -0.3673
vn 0.3792 -0.9201 -0.0981
vn 0.0919 -0.7041 -0.7041
vn 0.3347 -0.6663 -0.6663
vn 0.3792 -0.0981 -0.9201
vn 0.3673 -0.3673 -0.8545
vn 0.0981 -0.3792 -0.9201
vn 0.9201 0.3792 0.0981
vn 0.8545 0.3673 0.3673
vn 0.9201 0.0981 0.3792
vn 0.7041 0.7041 0.0919
vn 0.6663 0.6663 0.3347
vn 0.6663 0.3347 0.6663
vn 0.7041 0.0919 0.7041
vn 0.5774 0.5774 0.5773
vn 0.1004 0.9899 0.1004
vn 0.0981 0.9201 0.3792
vn 0.3673 0.8545 0.3673
vn 0.3792 0.9201 0.0981
vn 0.0919 0.7041 0.7041
vn 0.3347 0.6663 0.6663
vn 0.3792 0.0981 0.9201
vn 0.3673 0.3673 0.8545
vn 0.0981 0.3792 0.9201
vn 0.0981 -0.3792 0.9201
vn 0.3673 -0.3673 0.8545
vn 0.3792 -0.0981 0.9201
vn 0.0919 -0.7041 0.7041
vn 0.3347 -0.6663 0.6663
vn 0.6663 -0.3347 0.6663
vn 0.7041 -0.0919 0.7041
vn 0.5773 -0.5774 0.5774
vn 0.3792 -0.9201 0.0981
vn 0.3673 -0.8545 0.3673
vn 0.0981 -0.9201 0.3792
vn 0.7041 -0.7041 0.0919
vn 0.6663 -0.6663 0.3347
vn 0.9201 -0.0981 0.3792
vn 0.8545 -0.3673 0.3673
vn 0.9201 -0.3792 0.0981
vn -0.9201 0.3792 -0.0981
vn -0.8545 0.3673 -0.3673
vn -0.9201 0.0981 -0.3792
vn -0.7041 0.7041 -0.0919
vn -0.6663 0.6663 -0.3347
vn -0.6663 0.3347 -0.6663
vn -0.7041 0.0919 -0.7041
vn -0.5774 0.5774 -0.5773
vn -0.1004 0.9899 -0.1004
vn -0.0981 0.9201 -0.3792
vn -0.3673 0.8545 -0.3673
vn -0.3792 0.9201 -0.0981
vn -0.0919 0.7041 -0.7041
vn -0.3347 0.6663 -0.6663
vn -0.3792 0.0981 -0.9201
vn -0.3673 0.3673 -0.8545
vn -0.0981 0.3792 -0.9201
vn -0.0981 -0.3792 -0.9201
vn -0.3673 -0.3673 -0.8545
vn -0.3792 -0.0981 -0.9201
vn -0.0919 -0.7041 -0.7041
vn -0.3347 -0.6663 -0.6663
vn -0.6663 -0.3347 -0.6663
vn -0.7041 -0.0919 -0.7041
vn -0.5773 -0.5774 -0.5774
vn -0.3792 -0.9201 -0.0981
vn -0.3673 -0.8545 -0.3673
vn -0.0981 -0.9201 -0.3792
vn -0.7041 -0.7041 -0.0919
vn -0.6663 -0.6663 -0.3347
vn -0.9201 -0.0981 -0.3792
vn -0.8545 -0.3673 -0.3673
vn -0.9201 -0.3792 -0.0981
vn -0.9201 0.0981 0.3792
vn -0.8545 0.3673 0.3673
vn -0.9201 0.3792 0.0981
vn -0.7041 0.0919 0.7041
vn -0.6663 0.3347 0.6663
vn -0.6663 0.6663 0.3347
vn -0.7041 0.7041 0.0919
vn -0.5774 0.5774 0.5773
vn -0.0981 0.3792 0.9201
vn -0.3673 0.3673 0.8545
vn -0.3792 0.0981 0.9201
vn -0.0919 0.7041 0.7041
vn -0.3347 0.6663 0.6663
vn -0.1004 0.9899 0.1004
vn -0.3792 0.9201 0.0981
vn -0.3673 0.8545 0.3673
vn -0.0981 0.9201 0.3792
vn -0.3792 -0.0981 0.9201
vn -0.3673 -0.3673 0.8545
vn -0.0981 -0.3792 0.9201
vn -0.7041 -0.0919 0.7041
vn -0.6663 -0.3347 0.6663
vn -0.3347 -0.6663 0.6663
vn -0.0919 -0.7041 0.7041
vn -0.5774 -0.5774 0.5773
vn -0.9201 -0.3792 0.0981
vn -0.8545 -0.3673 0.3673
vn -0.9201 -0.0981 0.3792
vn -0.7041 -0.7041 0.0919
vn -0.6663 -0.6663 0.3347
vn -0.0981 -0.9201 0.3792
vn -0.3673 -0.8545 0.3673
vn -0.3792 -0.9201 0.0981
s 1
f 58/1/1 41/2/2 116/3/3 134/4/4
f 96/5/5 79/6/6 3/7/7 22/8/8
f 20/9/9 2/10/10 39/11/11 60/12/12
f 135/13/13 115/14/14 77/15/15 98/16/16
f 97/17/17 21/18/18 59/19/19 136/20/20
f 1/21/21 4/22/22 7/23/23 6/24/24
f 4/22/22 5/25/25 8/26/26 7/23/23
f 6/24/24 7/23/23 19/27/27 16/28/28
f 7/23/23 8/26/26 9/29/29 19/27/27
f 2/10/10 10/30/30 13/31/31 12/32/32
f 10/30/30 11/33/33 14/34/34 13/31/31
f 12/32/32 13/31/31 8/35/26 5/36/25
f 13/31/31 14/34/34 9/37/29 8/35/26
f 3/7/7 15/38/35 18/39/36 17/40/37
f 15/38/35 16/41/28 19/42/27 18/39/36
f 17/40/37 18/39/36 14/43/34 11/44/33
f 18/39/36 19/42/27 9/45/29 14/43/34
f 20/9/9 23/46/38 26/47/39 25/48/40
f 23/46/38 24/49/41 27/50/42 26/47/39
f 25/48/40 26/47/39 38/51/43 35/52/44
f 26/47/39 27/50/42 28/53/45 38/51/43
f 21/18/18 29/54/46 32/55/47 31/56/48
f 29/54/46 30/57/49 33/58/50 32/55/47
f 31/56/48 32/55/47 27/59/42 24/60/41
f 32/55/47 33/58/50 28/61/45 27/59/42
f 22/8/8 34/62/51 37/63/52 36/64/53
f 34/62/51 35/65/44 38/66/43 37/63/52
f 36/64/53 37/63/52 33/67/50 30/68/49
f 37/63/52 38/66/43 28/69/45 33/67/50
f 39/11/11 42/70/54 45/71/55 44/72/56
f 42/70/54 43/73/57 46/74/58 45/71/55
f 44/72/56 45/71/55 57/75/59 54/76/60
f 45/71/55 46/74/58 47/77/61 57/75/59
f 40/78/62 48/79/63 51/80/64 50/81/65
f 48/79/63 49/82/66 52/83/67 51/80/64
f 50/81/65 51/80/64 46/84/58 43/85/57
f 51/80/64 52/83/67 47/86/61 46/84/58
f 41/2/2 53/87/68 56/88/69 55/89/70
f 53/87/68 54/90/60 57/91/59 56/88/69
f 55/89/70 56/88/69 52/92/67 49/93/66
f 56/88/69 57/91/59 47/94/61 52/92/67
f 58/1/1 61/95/71 64/96/72 63/97/73
f 61/95/71 62/98/74 65/99/75 64/96/72
f 63/97/73 64/96/72 76/100/76 73/101/77
f 64/96/72 65/99/75 66/102/78 76/100/76
f 59/19/19 67/103/79 70/104/80 69/105/81
f 67/103/79 68/106/82 71/107/83 70/104/80
f 69/105/81 70/104/80 65/108/75 62/109/74
f 70/104/80 71/107/83 66/110/78 65/108/75
f 60/12/12 72/111/84 75/112/85 74/113/86
f 72/111/84 73/114/77 76/115/76 75/112/85
f 74/113/86 75/112/85 71/116/83 68/117/82
f 75/112/85 76/115/76 66/118/78 71/116/83
f 77/15/15 80/119/87 83/120/88 82/121/89
f 80/119/87 81/122/90 84/123/91 83/120/88
f 82/121/89 83/120/88 95/124/92 92/125/93
f 83/120/88 84/123/91 85/126/94 95/124/92
f 78/127/95 86/128/96 89/129/97 88/130/98
f 86/128/96 87/131/99 90/132/100 89/129/97
f 88/130/98 89/129/97 84/133/91 81/134/90
f 89/129/97 90/132/100 85/135/94 84/133/91
f 79/6/6 91/136/101 94/137/102 93/138/103
f 91/136/101 92/139/93 95/140/92 94/137/102
f 93/138/103 94/137/102 90/141/100 87/142/99
f 94/137/102 95/140/92 85/143/94 90/141/100
f 96/5/5 99/144/104 102/145/105 101/146/106
f 99/144/104 100/147/107 103/148/108 102/145/105
f 101/146/106 102/145/105 114/149/109 111/150/110
f 102/145/105 103/148/108 104/151/111 114/149/109
f 97/17/17 105/152/112 108/153/113 107/154/114
f 105/152/112 106/155/115 109/156/116 108/153/113
f 107/154/114 108/153/113 103/157/108 100/158/107
f 108/153/113 109/156/116 104/159/111 103/157/108
f 98/16/16 110/160/117 113/161/118 112/162/119
f 110/160/117 111/163/110 114/164/109 113/161/118
f 112/162/119 113/161/118 109/165/116 106/166/115
f 113/161/118 114/164/109 104/167/111 109/165/116
f 115/14/14 118/168/120 121/169/121 120/170/122
f 118/168/120 119/171/123 122/172/124 121/169/121
f 120/170/122 121/169/121 133/173/125 130/174/126
f 121/169/121 122/172/124 123/175/127 133/173/125
f 116/3/3 124/176/128 127/177/129 126/178/130
f 124/176/128 125/179/131 128/180/132 127/177/129
f 126/178/130 127/177/129 122/181/124 119/182/123
f 127/177/129 128/180/132 123/183/127 122/181/124
f 117/184/133 129/185/134 132/186/135 131/187/136
f 129/185/134 130/188/126 133/189/125 132/186/135
f 131/187/136 132/186/135 128/190/132 125/191/131
f 132/186/135 133/189/125 123/192/127 128/190/132
f 134/4/4 137/193/137 140/194/138 139/195/139
f 137/193/137 138/196/140 141/197/141 140/194/138
f 139/195/139 140/194/138 152/198/142 149/199/143
f 140/194/138 141/197/141 142/200/144 152/198/142
f 135/13/13 143/201/145 146/202/146 145/203/147
f 143/201/145 144/204/148 147/205/149 146/202/146
f 145/203/147 146/202/146 141/206/141 138/207/140
f 146/202/146 147/205/149 142/208/144 141/206/141
f 136/20/20 148/209/150 151/210/151 150/211/152
f 148/209/150 149/212/143 152/213/142 151/210/151
f 150/211/152 151/210/151 147/214/149 144/215/148
f 151/210/151 152/213/142 142/216/144 147/214/149
f 136/20/20 59/19/19 69/105/81 148/209/150
f 148/209/150 69/105/81 62/109/74 149/212/143
f 149/199/143 62/98/74 61/95/71 139/195/139
f 139/195/139 61/95/71 58/1/1 134/4/4
f 59/19/19 21/18/18 31/56/48 67/103/79
f 67/103/79 31/56/48 24/60/41 68/106/82
f 68/117/82 24/49/41 23/46/38 74/113/86
f 74/113/86 23/46/38 20/9/9 60/12/12
f 1/21/21 40/78/62 50/81/65 4/22/22
f 4/22/22 50/81/65 43/85/57 5/25/25
f 5/36/25 43/73/57 42/70/54 12/32/32
f 12/32/32 42/70/54 39/11/11 2/10/10
f 21/18/18 97/17/17 107/154/114 29/54/46
f 29/54/46 107/154/114 100/158/107 30/57/49
f 30/68/49 100/147/107 99/144/104 36/64/53
f 36/64/53 99/144/104 96/5/5 22/8/8
f 117/184/133 78/127/95 88/130/98 129/185/134
f 129/185/134 88/130/98 81/134/90 130/188/126
f 130/174/126 81/122/90 80/119/87 120/170/122
f 120/170/122 80/119/87 77/15/15 115/14/14
f 97/17/17 136/20/20 150/211/152 105/152/112
f 105/152/112 150/211/152 144/215/148 106/155/115
f 106/166/115 144/204/148 143/201/145 112/162/119
f 112/162/119 143/201/145 135/13/13 98/16/16
f 40/78/62 117/184/133 131/187/136 48/79/63
f 48/79/63 131/187/136 125/191/131 49/82/66
f 49/93/66 125/179/131 124/176/128 55/89/70
f 55/89/70 124/176/128 116/3/3 41/2/2
f 41/2/2 58/1/1 63/97/73 53/87/68
f 53/87/68 63/97/73 73/101/77 54/90/60
f 54/76/60 73/114/77 72/111/84 44/72/56
f 44/72/56 72/111/84 60/12/12 39/11/11
f 2/10/10 20/9/9 25/48/40 10/30/30
f 10/30/30 25/48/40 35/52/44 11/33/33
f 11/44/33 35/65/44 34/62/51 17/40/37
f 17/40/37 34/62/51 22/8/8 3/7/7
f 134/4/4 116/3/3 126/178/130 137/193/137
f 137/193/137 126/178/130 119/182/123 138/196/140
f 138/207/140 119/171/123 118/168/120 145/203/147
f 145/203/147 118/168/120 115/14/14 135/13/13
f 78/127/95 1/21/21 6/24/24 86/128/96
f 86/128/96 6/24/24 16/28/28 87/131/99
f 87/142/99 16/41/28 15/38/35 93/138/103
f 93/138/103 15/38/35 3/7/7 79/6/6
f 79/6/6 96/5/5 101/146/106 91/136/101
f 91/136/101 101/146/106 111/150/110 92/139/93
f 92/125/93 111/163/110 110/160/117 82/121/89
f 82/121/89 110/160/117 98/16/16 77/15/15
f 1/21/21 78/127/95 117/184/133 40/78/62

View File

@@ -0,0 +1,10 @@
#version 330 core
out vec4 FragColor;
uniform sampler2D ourTexture;
in vec2 TexCoord;
void main() {
FragColor = texture(ourTexture, TexCoord);
};

View File

@@ -0,0 +1,14 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
out vec2 TexCoord;
void main() {
gl_Position = projection * view * model * vec4(aPos, 1.0);
TexCoord = aTexCoord;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

View File

@@ -1,79 +0,0 @@
#include <bitset>
#include <array>
#include <span>
#include <cstdint>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include "VoxelSpace.h"
#include "SomaSolve.h"
auto get_dims_input(int dims[3]) -> void {
std::cout << "Enter dimensions separated by newlines. (x*y*z must not exceed 64)\n";
auto success = false;
while (!success) {
std::cout << "x: ";
std::cin >> dims[0];
std::cout << "y: ";
std::cin >> dims[1];
std::cout << "z: ";
std::cin >> dims[2];
auto size = dims[0]*dims[1]*dims[2];
if (size <= 64) {
success = true;
} else {
std::cout << "That resulted in " << size << " units. Try again.\n";
}
std::cin.ignore();
}
}
auto get_reprs_input(int units_required) -> std::vector<uint64_t> {
std::cout << "Enter bit-representations (big endian, max 64 bits, total 1s must add up to " << units_required << "). press ENTER twice to finish input.\n";
auto reprs = std::vector<uint64_t>();
auto total_units = 0;
while (true) {
auto input = std::string();
std::getline(std::cin, input);
if (input.size() == 0) {
if (total_units == units_required) {
break;
} else {
std::cout << "Bad number of units. You entered: " << total_units << ", but exactly " << units_required << " were required.\n";
total_units = 0;
continue;
}
}
auto bit_repr = 0ul;
auto i = 0;
auto good_repr = true;
for (auto it = input.rbegin(); it < input.rend(); it++, i++) {
if (*it == '1') {
bit_repr |= 1ul << i;
total_units++;
} else if (*it != '0' || i >= 64) {
std::cout << "Input invalid. Enter a binary string only with max 64 bits." << '\n';
good_repr = false;
break;
}
}
if (good_repr) {
reprs.push_back(bit_repr);
}
}
return reprs;
}
auto main() -> int {
int dims[3] = { 3, 3, 3 };
//get_dims_input(dims);
//std::cout << '\n';
//auto reprs = get_reprs_input(dims[0]*dims[1]*dims[2]);
std::cout << "Great. Calculating solutions...\n";
auto solutions = SomaSolve::solve(&SomaSolve::STD_SOMA, std::array<int, 3>{ 3, 3, 3 }.data());
std::cout << solutions.size() << " solutions found." << std::endl;
return 0;
}

View File

@@ -7,6 +7,63 @@
#include <vector>
#include "VoxelSpace.h"
auto get_dims_input(int dims[3]) -> void {
std::cout << "Enter dimensions separated by newlines. (x*y*z must not exceed 64)\n";
auto success = false;
while (!success) {
std::cout << "x: ";
std::cin >> dims[0];
std::cout << "y: ";
std::cin >> dims[1];
std::cout << "z: ";
std::cin >> dims[2];
auto size = dims[0]*dims[1]*dims[2];
if (size <= 64) {
success = true;
} else {
std::cout << "That resulted in " << size << " units. Try again.\n";
}
std::cin.ignore();
}
}
auto get_reprs_input(int units_required) -> std::vector<uint64_t> {
std::cout << "Enter bit-representations (big endian, max 64 bits, total 1s must add up to " << units_required << "). press ENTER twice to finish input.\n";
auto reprs = std::vector<uint64_t>();
auto total_units = 0;
while (true) {
auto input = std::string();
std::getline(std::cin, input);
if (input.size() == 0) {
if (total_units == units_required) {
break;
} else {
std::cout << "Bad number of units. You entered: " << total_units << ", but exactly " << units_required << " were required.\n";
total_units = 0;
continue;
}
}
auto bit_repr = 0ul;
auto i = 0;
auto good_repr = true;
for (auto it = input.rbegin(); it < input.rend(); it++, i++) {
if (*it == '1') {
bit_repr |= 1ul << i;
total_units++;
} else if (*it != '0' || i >= 64) {
std::cout << "Input invalid. Enter a binary string only with max 64 bits." << '\n';
good_repr = false;
break;
}
}
if (good_repr) {
reprs.push_back(bit_repr);
}
}
return reprs;
}
namespace SomaSolve {
using SomaSolution = std::vector<uint64_t>;
@@ -16,15 +73,7 @@ namespace SomaSolve {
std::vector<SomaSolution>* solutions;
};
auto STD_SOMA = std::vector<uint64_t>{
23ul,
30ul,
15ul,
1043ul,
24594ul,
12306ul,
11ul,
};
auto STD_SOMA = std::vector<uint64_t>{ 23ul, 30ul, 15ul, 1043ul, 24594ul, 12306ul, 11ul };
auto backtrack_solve_iter(std::vector<uint64_t> *polycube_input, std::vector<int> *offsets)-> void {
auto num_inputs = offsets->size() - 1;
@@ -191,4 +240,15 @@ namespace SomaSolve {
return filter_unique(solver.solutions, dims);
}
auto interactive_cmd_line_solve_soma() -> void {
int dims[3] = { 3, 3, 3 };
//get_dims_input(dims);
//std::cout << '\n';
//auto reprs = get_reprs_input(dims[0]*dims[1]*dims[2]);
std::cout << "Great. Calculating solutions...\n";
auto solutions = SomaSolve::solve(&SomaSolve::STD_SOMA, std::array<int, 3>{ 3, 3, 3 }.data());
std::cout << solutions.size() << " solutions found." << std::endl;
}
}

View File

@@ -5,5 +5,6 @@ namespace SomaSolve {
extern std::vector<uint64_t> STD_SOMA;
using SomaSolution = std::vector<uint64_t>;
auto solve(std::vector<uint64_t> *reprs_in, int dims[3]) -> std::vector<SomaSolution>;
auto interactive_cmd_line_solve_soma() -> void;
}

View File

@@ -10,23 +10,29 @@ namespace Voxel {
return dim_y * dim_z * x + dim_z * y + z;
}
// [1, 0, 0] [x] [ x]
// [0, 0, -1] * [y] = [-z]
// [0, 1, 0] [z] [ y]
// ┌ ┐ ┌ ┐ ┌ ┐
// │ 1, 0, 0 │ │ x │ │ x │
// 0, 0, -1 │ * │ y │ = │-z │
// │ 0, 1, 0 │ │ z │ │ y │
// └ ┘ └ ┘ └ ┘
auto newIndexRotX(Space *space, int x, int y, int z) -> int {
return space->dim_z * space->dim_y * x + space->dim_y * (space->dim_z - 1 - z) + y;
}
// [ 0, 0, 1] [x] [ z]
// [ 0, 1, 0] * [y] = [ y]
// [-1, 0, 0] [z] [-x]
// ┌ ┐ ┌ ┐ ┌ ┐
// 0, 0, 1 │ │ x │ │ z │
// │ 0, 1, 0 │ * │ y │ = │-y │
// │ -1, 0, 0 │ │ z │ │ x │
// └ ┘ └ ┘ └ ┘
auto newIndexRotY(Space *space, int x, int y, int z) -> int {
return space->dim_y * space->dim_x * z + space->dim_x * y + (space->dim_x - 1 - x);
}
// [0, -1, 0] [x] [-y]
// [1, 0, 0] * [y] = [ x]
// [0, 0, 1] [z] [ z]
// ┌ ┐ ┌ ┐ ┌ ┐
// │ 0, -1, 0 │ │ x │ │-y │
// │ 1, 0, 0 │ * │ y │ = │ x │
// │ 0, 0, 1 │ │ z │ │ z │
// └ ┘ └ ┘ └ ┘
auto newIndexRotZ(Space *space, int x, int y, int z) -> int {
return space->dim_x * space->dim_z * (space->dim_y - 1 - y) + space->dim_z * x + z;
}

60
src/gfx/Mesh.cpp Normal file
View File

@@ -0,0 +1,60 @@
#include <iostream>
#include "Mesh.h"
#include "loaders/tinyobj.h"
auto Mesh::init(const char* obj_file) -> void {
auto reader = tinyobj::ObjReader();
auto success = reader.ParseFromFile(obj_file);
std::cout << reader.Error() << std::endl;
auto attrib = reader.GetAttrib();
auto indices_t = reader.GetShapes().at(0).mesh.indices;
auto indices = std::vector<unsigned int>(indices_t.size());
for (int i = 0; i < indices_t.size(); i++) {
indices[i] = indices_t[i].vertex_index;
}
num_indices = indices.size();
glGenVertexArrays(1, &vao);
glGenBuffers(1, &vbo_xyz);
glGenBuffers(1, &vbo_uv);
glGenBuffers(1, &ebo);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo_xyz);
glBufferData(GL_ARRAY_BUFFER, attrib.vertices.size() * sizeof(float), attrib.vertices.data(), GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vbo_uv);
glBufferData(GL_ARRAY_BUFFER, attrib.texcoords.size() * sizeof(float), attrib.texcoords.data(), GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), indices.data(), GL_STATIC_DRAW);
}
auto Mesh::init(const LeddaGeometry::Shape* shape) -> void {
num_indices = shape->indices_size;
glGenVertexArrays(1, &vao);
glGenBuffers(1, &vbo_xyz);
glGenBuffers(1, &vbo_uv);
glGenBuffers(1, &ebo);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo_xyz);
glBufferData(GL_ARRAY_BUFFER, shape->xyz_size * sizeof(float), shape->xyz, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vbo_uv);
glBufferData(GL_ARRAY_BUFFER, shape->uv_size * sizeof(float), shape->uv, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, shape->indices_size * sizeof(unsigned int), shape->indices, GL_STATIC_DRAW);
}

17
src/gfx/Mesh.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef LEDDA_MESH_H
#define LEDDA_MESH_H
#include "glad/glad.h"
#include "geometry.h"
struct Mesh {
unsigned int vao;
unsigned int vbo_xyz;
unsigned int vbo_uv;
unsigned int ebo;
unsigned int num_indices;
auto init(const char* obj_file) -> void;
auto init(const LeddaGeometry::Shape* shape) -> void;
};
#endif

View File

81
src/gfx/OrbitControls.h Normal file
View File

@@ -0,0 +1,81 @@
#ifndef ORBIT_CONTROLS_H
#define ORBIT_CONTROLS_H
#include "glad/glad.h"
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "loaders/stb_image.h"
constexpr auto ROTATION_FACTOR = 1.0f / 200.0f;
struct Point {
float x;
float y;
};
class OrbitControls {
private:
bool dragging;
bool hovered;
bool scrolling;
bool flyingEnabled;
float lastX;
float lastY;
Point lastScroll1;
Point lastScroll2;
glm::vec3 y_axis;
glm::vec3 x_axis;
glm::vec3 start;
Entity* orbited_object;
OrbitControls(Entity* orbited, Camera* camera) {
camera = camera;
orbited_object = orbited;
y_axis = orbited_object.worldToLocal(camera.up);
x_axis = orbited_object.position.sub(camera.position);
x_axis /= sqrt(pow(x_axis.x) + pow(x_axis.y, 2) + pow(x_axis.z, 2));
x_axis = glm::cross(x_axis, y_axis);
start = orbited_object.rotation;
this.element.addEventListener('wheel', (ev) => this.handleScroll(ev));
this.element.addEventListener('mouseover', () => this.hovered = true);
this.element.addEventListener('mouseout', () => this.hovered = false);
this.element.addEventListener('mousedown', (ev) => this.handleMouseDown(ev));
window.addEventListener('mousemove', (ev) => this.handleMove(ev));
window.addEventListener('mouseup', () => this.dragging = false);
}
on_mouse_down(event) {
if (event.button === 1) {
this.object.setRotationFromEuler(this.start);
}
if (!this.dragging) {
this.lastX = event.x;
this.lastY = event.y;
this.dragging = true;
}
}
on_mouse_move(event) {
if (dragging) {
auto x_diff = event.movementX * ROTATION_FACTOR;
auto y_diff = event.movementY * ROTATION_FACTOR;
glm::rotate(&orbited_object, x_diff, &y_axis);
//rotate on world axis ???
glm::rotate(&orbited_object, y_diff &x_axis);
}
}
on_scroll(event) {
if (this.flyingEnabled && this.hovered) {
for (const fliable of this.fliables) {
const direction = event.deltaY / Math.abs(event.deltaY);
fliable.flyBy(direction / 10);
}
}
}
}
#endif

57
src/gfx/Shader.cpp Normal file
View File

@@ -0,0 +1,57 @@
#include "glad/glad.h"
#include <array>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include "Shader.h"
enum ShaderType {
fragment=GL_FRAGMENT_SHADER,
vertex=GL_VERTEX_SHADER,
};
auto create_shader(const char* file_path, ShaderType shader_type, char* info_log) -> unsigned int {
std::stringstream shader_stream;
std::ifstream shader_file;
shader_file.open(file_path);
shader_stream << shader_file.rdbuf();
shader_file.close();
auto shader_string = shader_stream.str();
const auto shader_code = shader_string.c_str();
auto vertex_shader = glCreateShader(shader_type);
glShaderSource(vertex_shader, 1, &shader_code, NULL);
glCompileShader(vertex_shader);
int success;
glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &success);
if (!success) {
glGetShaderInfoLog(vertex_shader, 512, NULL, info_log);
auto shader_type_name = shader_type == ShaderType::fragment ? "FRAGMENT" : "VERTEX";
std::cout << "ERROR::SHADER::" << shader_type_name << "::COMPILATION_FAILED\n" << info_log << std::endl;
}
return vertex_shader;
}
auto Shader::init(const char* vertex_path, const char* fragment_path) -> void {
auto info_log = std::array<char, 512>();
auto vertex_shader = create_shader(vertex_path, ShaderType::vertex, info_log.data());
auto fragment_shader = create_shader(fragment_path, ShaderType::fragment, info_log.data());
prog_id = glCreateProgram();
glAttachShader(prog_id, vertex_shader);
glAttachShader(prog_id, fragment_shader);
glLinkProgram(prog_id);
int success;
glGetProgramiv(prog_id, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(prog_id, 512, NULL, info_log.data());
std::cout << "ERROR::SHADER::PROGRAM::LINK_FAILED\n" << info_log.data() << std::endl;
}
glDeleteShader(vertex_shader);
glDeleteShader(fragment_shader);
}

9
src/gfx/Shader.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef LEDDA_SHADER_H
#define LEDDA_SHADER_H
struct Shader {
unsigned int prog_id;
auto init(const char* vertex_path, const char* fragment_path) -> void;
};
#endif

23
src/gfx/Texture.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "Texture.h"
#include <iostream>
#include "loaders/stb_image.h"
#include "glad/glad.h"
auto Texture::init(const char* source_path) -> void {
glGenTextures(1, &tex_id);
glBindTexture(GL_TEXTURE_2D, tex_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
int nr_channels;
auto data = stbi_load(source_path, &width, &height, &nr_channels, 0);
if (data) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
} else {
std::cout << "Failed to load texture." << std::endl;
}
stbi_image_free(data);
}

11
src/gfx/Texture.h Normal file
View File

@@ -0,0 +1,11 @@
#ifndef LEDDA_TEXTURE_H
#define LEDDA_TEXTURE_H
struct Texture {
unsigned int tex_id;
int width;
int height;
auto init(const char* source_path) -> void;
};
#endif

112
src/gfx/geometry.cpp Normal file
View File

@@ -0,0 +1,112 @@
#include <array>
#include "geometry.h"
// Buffer layout:
// X, Y, Z, U, V
auto triangle_vertices = std::to_array<float>({
-0.5f, -0.5f, 0.0f, 1.0f, 1.0f,
0.5f, -0.5f, 0.0f, 0.5f, 0.5f,
0.0f, 0.5f, 0.0f, 0.0f, 0.0f,
});
auto triangle_indices = std::to_array<unsigned int>({
0, 1, 2
});
auto cube_vertices = std::to_array<float>({
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f
});
auto cube_indices = std::to_array<unsigned int>({
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
});
auto square_xyz = std::to_array<float>({
0.5f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
-0.5f, -0.5f, 0.0f,
-0.5f, 0.5f, 0.0f,
});
auto square_uv = std::to_array<float>({
1.0f, 1.0f,
1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f,
});
auto square_indices = std::to_array<unsigned int>({
0, 1, 3,
1, 2, 3,
});
namespace LeddaGeometry {
const Shape TRIANGLE = {
.indices = triangle_indices.data(),
.indices_size = sizeof(triangle_indices),
.uv = triangle_vertices.data(),
.uv_size = sizeof(triangle_vertices),
.xyz = triangle_vertices.data(),
.xyz_size = sizeof(triangle_vertices),
};
const Shape SQUARE = {
.indices = square_indices.data(),
.indices_size = square_indices.size(),
.uv = square_uv.data(),
.uv_size = square_uv.size(),
.xyz = square_xyz.data(),
.xyz_size = square_xyz.size(),
};
const Shape CUBE = {
.indices = cube_indices.data(),
.indices_size = cube_indices.size(),
.uv = triangle_vertices.data(),
.uv_size = triangle_vertices.size(),
.xyz = triangle_vertices.data(),
.xyz_size = triangle_vertices.size(),
};
}

20
src/gfx/geometry.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef LEDDA_GEOMETRY_H
#define LEDDA_GEOMETRY_H
#include <cstddef>
namespace LeddaGeometry {
struct Shape {
unsigned int* indices;
size_t indices_size;
float* uv;
size_t uv_size;
float* xyz;
size_t xyz_size;
};
extern const Shape TRIANGLE;
extern const Shape SQUARE;
extern const Shape CUBE;
}
#endif

271
src/main.cpp Normal file
View File

@@ -0,0 +1,271 @@
#include <bitset>
#include <array>
#include <glm/ext/matrix_transform.hpp>
#include <span>
#include <cstdint>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include "glad/glad.h"
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "loaders/stb_image.h"
#include "gfx/geometry.h"
#include "gfx/Texture.h"
#include "gfx/Mesh.h"
#include "gfx/Shader.h"
#include "VoxelSpace.h"
#include "SomaSolve.h"
struct Camera {
glm::mat4 view;
glm::mat4 proj;
glm::vec3 pos;
glm::vec3 up;
glm::vec3 target;
auto init(float aspect_ratio = 800.0f / 600.0f) -> void {
view = glm::mat4();
proj = glm::perspective(glm::radians(45.0f), aspect_ratio, 0.1f, 100.0f);
pos = glm::vec3(0.0f, 5.0f, 0.0f);
up = glm::vec3(0.0f, 1.0f, 0.0f);
}
auto look_at(float x, float y, float z) -> void {
target = glm::vec3(x, y, z);
view = glm::lookAt(pos, target, up);
}
auto set_up(float up_x, float up_y, float up_z) -> void {
up = glm::vec3(up_x, up_y, up_z);
}
};
struct WindowDims {
unsigned int width;
unsigned int height;
};
struct TrsSpecs {
glm::vec3 translation;
glm::quat rotation;
glm::vec3 scale;
auto reset() -> void {
scale = glm::vec3(1.0f, 1.0f, 1.0f);
translation = glm::vec3(0.0f, 0.0f, 0.0f);
rotation = glm::quat(0.0f, 0.0f, 0.0f, 0.0f);
}
};
struct Entity {
glm::mat4 local;
glm::mat4 world;
TrsSpecs trs;
Mesh* mesh;
Texture* tex;
auto init() -> void {
trs.reset();
local = glm::mat4(1.0f);
}
auto update_model_mat() -> void {
local = glm::mat4(1.0f);
local = glm::scale(
glm::translate(
local,
trs.translation
) * glm::toMat4(trs.rotation),
trs.scale
);
world = local;
}
};
struct Polycube {
std::vector<Entity*>* entities;
uint8_t color;
};
struct Frame {
unsigned int width;
unsigned int height;
int x;
int y;
Camera* cam;
auto init(Camera* camera) -> void {
camera->init((float)width / (float)height);
cam = camera;
}
};
auto framebuffer_size_callback(GLFWwindow* window, int width, int height) -> void {
glViewport(0, 0, width, height);
}
auto process_input(GLFWwindow *window) -> void {
static auto wireframe = false;
static auto last_frame_state_press = false;
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
} else if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS && !last_frame_state_press) {
glPolygonMode(GL_FRONT_AND_BACK, !wireframe ? GL_LINE : GL_FILL);
wireframe = !wireframe;
last_frame_state_press = true;
} else if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_RELEASE) {
last_frame_state_press = false;
}
}
auto init_window_and_gl(WindowDims* window_dims) -> GLFWwindow* {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
auto window = glfwCreateWindow(window_dims->width, window_dims->height, "Somaesque", NULL, NULL);
if (window == NULL) {
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return nullptr;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout << "Failed to initilaize GLAD" << std::endl;
return nullptr;
}
glViewport(0, 0, 800, 600);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glEnable(GL_DEPTH_TEST);
return window;
}
auto gl_update_viewport(WindowDims* window_dims, Frame* frame) -> void {
glViewport(frame->x, window_dims->height - frame->y - frame->height, frame->width, frame->height);
}
auto rotate_cam_around_centre(Camera* cam, int radius) -> void {
cam->pos.x = sin(glfwGetTime()) * radius;
cam->pos.z = cos(glfwGetTime()) * radius;
cam->look_at(0.0f, 0.0f, 0.0f);
}
auto active_shader = Shader{};
auto cube_mesh = Mesh{};
auto wall_tex = Texture{};
auto entities = std::vector<Entity>();
auto draw_entity(Entity* entity) -> void {
auto modelUniformLoc = glGetUniformLocation(active_shader.prog_id, "model");
glUniformMatrix4fv(modelUniformLoc, 1, GL_FALSE, glm::value_ptr(entity->world));
glBindTexture(GL_TEXTURE_2D, entity->tex->tex_id);
glBindVertexArray(entity->mesh->vao);
glDrawElements(GL_TRIANGLES, entity->mesh->num_indices, GL_UNSIGNED_INT, 0);
}
auto use_default_shader(Camera* cam) -> void {
glUseProgram(active_shader.prog_id);
auto viewUniformLoc = glGetUniformLocation(active_shader.prog_id, "view");
auto projectionUniformLoc = glGetUniformLocation(active_shader.prog_id, "projection");
glUniformMatrix4fv(projectionUniformLoc, 1, GL_FALSE, glm::value_ptr(cam->proj));
glUniformMatrix4fv(viewUniformLoc, 1, GL_FALSE, glm::value_ptr(cam->view));
}
auto print_mat(glm::mat4* matrix) -> void {
auto mat = *matrix;
std::cout << mat[0][0] << mat[0][1] << mat[0][2] << mat[0][3] << std::endl;
std::cout << mat[1][0] << mat[1][1] << mat[1][2] << mat[1][3] << std::endl;
std::cout << mat[2][0] << mat[2][1] << mat[2][2] << mat[2][3] << std::endl;
std::cout << mat[3][0] << mat[3][1] << mat[3][2] << mat[3][3] << std::endl;
std::cout << std::endl;
}
auto create_polycube_from_repr(Voxel::Space* repr) -> std::vector<Entity*> {
auto result = std::vector<Entity*>(Voxel::size(repr->space));
for (int x = 0; x < repr->dim_x; x++) {
for (int y = 0; y < repr->dim_y; y++) {
for (int z = 0; z < repr->dim_z; z++) {
if (Voxel::filledAt(repr, x, y, z)) {
entities.push_back({
.mesh=&cube_mesh,
.tex=&wall_tex,
});
auto polycube_segment = &entities.back();
polycube_segment->init();
polycube_segment->trs.translation = glm::vec3(
-((repr->dim_z - 1)/2) + z,
((repr->dim_x - 1)/2) - x,
-((repr->dim_y - 1)/2) + y
);
result.push_back(polycube_segment);
}
}
}
}
return result;
}
auto main() -> int {
auto window_dims = WindowDims{ 800, 600 };
auto window = init_window_and_gl(&window_dims);
if (window == nullptr) {
return -1;
}
auto little_frame = Frame{ .width=80, .height=60, .x=20, .y=20 };
auto big_frame = Frame{ .width=800, .height=600, .x=0, .y=0 };
auto main_cam = Camera{};
auto other_cam = Camera{};
little_frame.init(&other_cam);
big_frame.init(&main_cam);
auto frames = std::vector{ &big_frame, &little_frame };
active_shader.init("../assets/shaders/basic.vertex.glsl", "../assets/shaders/basic.fragment.glsl");
cube_mesh.init("../assets/models/c000000.obj");
wall_tex.init("../assets/textures/brick-wall.jpg");
auto voxel_space = Voxel::Space{
.space=SomaSolve::STD_SOMA[0],
.dim_x=3,
.dim_y=3,
.dim_z=3
};
Voxel::cullEmptySpace(&voxel_space);
auto polycube1 = create_polycube_from_repr(&voxel_space);
for (auto &entity : entities) {
entity.update_model_mat();
}
while (!glfwWindowShouldClose(window)) {
process_input(window);
rotate_cam_around_centre(big_frame.cam, 10.0f);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
use_default_shader(big_frame.cam);
gl_update_viewport(&window_dims, &big_frame);
for (auto &entity : entities) {
entity.update_model_mat();
auto scale = glm::mat4(1.0f);
entity.world = glm::scale(glm::mat4(1.0f), glm::vec3(1.0f) * abs((float)sin(glfwGetTime()))) * entity.world;
draw_entity(&entity);
}
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}

311
vendor/KHR/khrplatform.h vendored Normal file
View File

@@ -0,0 +1,311 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2018 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* The master copy of khrplatform.h is maintained in the Khronos EGL
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
* The last semantic modification to khrplatform.h was at commit ID:
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by filing pull requests or issues on
* the EGL Registry repository linked above.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__)
# define KHRONOS_APICALL __attribute__((visibility("default")))
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
/*
* To support platform where unsigned long cannot be used interchangeably with
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
* unsigned long long or similar (this results in different C++ name mangling).
* To avoid changes for existing platforms, we restrict usage of intptr_t to
* platforms where the size of a pointer is larger than the size of long.
*/
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
#define KHRONOS_USE_INTPTR_T
#endif
#endif
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef KHRONOS_USE_INTPTR_T
typedef intptr_t khronos_intptr_t;
typedef uintptr_t khronos_uintptr_t;
#elif defined(_WIN64)
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
#endif
#if defined(_WIN64)
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

1833
vendor/glad/glad.c vendored Normal file

File diff suppressed because it is too large Load Diff

3694
vendor/glad/glad.h vendored Normal file

File diff suppressed because it is too large Load Diff

2
vendor/loaders/stb_image.cpp vendored Normal file
View File

@@ -0,0 +1,2 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

7898
vendor/loaders/stb_image.h vendored Normal file

File diff suppressed because it is too large Load Diff

2
vendor/loaders/tinyobj.cpp vendored Normal file
View File

@@ -0,0 +1,2 @@
#define TINYOBJLOADER_IMPLEMENTATION
#include "tinyobj.h"

3455
vendor/loaders/tinyobj.h vendored Normal file

File diff suppressed because it is too large Load Diff