Skip to content

Commit 4a5dc00

Browse files
committed
vendors
1 parent cca8984 commit 4a5dc00

File tree

12 files changed

+201
-22
lines changed

12 files changed

+201
-22
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4

.gitmodules

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[submodule "src/vendor/assimp"]
2+
path = src/vendor/assimp
3+
url = https://github.com/assimp/assimp.git
4+
branch = master
5+
[submodule "src/vendor/glad"]
6+
path = src/vendor/glad
7+
url = https://github.com/Dav1dde/glad.git
8+
branch = c
9+
[submodule "src/vendor/glfw"]
10+
path = src/vendor/glfw
11+
url = https://github.com/glfw/glfw.git
12+
branch = master
13+
[submodule "src/vendor/glm"]
14+
path = src/vendor/glm
15+
url = https://github.com/g-truc/glm.git
16+
branch = master
17+
[submodule "src/vendor/stb"]
18+
path = src/vendor/stb
19+
url = https://github.com/nothings/stb.git
20+
branch = master
21+
[submodule "src/vendor/bullet3"]
22+
path = src/vendor/bullet3
23+
url = https://github.com/bulletphysics/bullet3.git
24+
branch = master

CMakeLists.txt

Lines changed: 93 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,94 @@
11
# This is only for compiling for native usage and test, not to be used to port WebAssembly
2-
cmake_minimum_required(VERSION 2.8)
3-
project(webassembly_opengl)
4-
5-
# Not sure if this is correct, but fixes c++ x64 arch issues with std
6-
set (CMAKE_CXX_STANDARD 11)
7-
# includes cmake/FindSDL2.cmake
8-
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
9-
10-
find_package (OpenGL REQUIRED)
11-
# @TODO switch SDL to GLFW
12-
find_package(SDL2 REQUIRED)
13-
find_package(GLEW REQUIRED)
14-
include_directories(${SDL2_INCLUDE_DIR})
15-
include_directories(${OPENGL_INCLUDE_DIR})
16-
include_directories(${GLEW_INCLUDE_DIR})
17-
include_directories(deps/include)
18-
19-
file(GLOB SOURCE_FILES src/*.cpp)
20-
21-
add_executable(webassembly_opengl ${SOURCE_FILES})
22-
target_link_libraries(webassembly_opengl ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLM_LIBRARIES})
23-
target_compile_features(webassembly_opengl PRIVATE cxx_range_for)
2+
cmake_minimum_required(VERSION 3.0)
3+
project(opie)
4+
5+
# GLFW Vendor
6+
option(GLFW_BUILD_DOCS OFF)
7+
option(GLFW_BUILD_EXAMPLES OFF)
8+
option(GLFW_BUILD_TESTS OFF)
9+
add_subdirectory(src/vendor/glfw)
10+
11+
# ASSIMP Vendor
12+
option(ASSIMP_BUILD_ASSIMP_TOOLS OFF)
13+
option(ASSIMP_BUILD_SAMPLES OFF)
14+
option(ASSIMP_BUILD_TESTS OFF)
15+
add_subdirectory(src/vendor/assimp)
16+
17+
# Bullet
18+
option(BUILD_BULLET2_DEMOS OFF)
19+
option(BUILD_CPU_DEMOS OFF)
20+
option(BUILD_EXTRAS OFF)
21+
option(BUILD_OPENGL3_DEMOS OFF)
22+
option(BUILD_UNIT_TESTS OFF)
23+
add_subdirectory(src/vendor/bullet3)
24+
25+
# Platform check
26+
if(MSVC)
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
28+
else()
29+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -std=c++11")
30+
if(NOT WIN32)
31+
set(GLAD_LIBRARIES dl)
32+
endif()
33+
endif()
34+
35+
## Include other vendors
36+
include_directories(src/headers/
37+
src/vendor/assimp/include/
38+
src/vendor/bullet/src/
39+
src/vendor/glad/include/
40+
src/vendor/glfw/include/
41+
src/vendor/glm/
42+
src/vendor/stb/)
43+
44+
# Glob together files
45+
file(GLOB VENDORS_SOURCES src/vendor/glad/src/glad.c)
46+
file(GLOB PROJECT_HEADERS src/headers/*.h)
47+
file(GLOB PROJECT_SOURCES src/*.cpp)
48+
file(GLOB PROJECT_SHADERS src/shaders/*.comp
49+
src/shaders/*.frag
50+
src/shaders/*.geom
51+
src/shaders/*.vert)
52+
file(GLOB PROJECT_CONFIGS CMakeLists.txt
53+
Readme.md
54+
.gitattributes
55+
.gitignore
56+
.gitmodules)
57+
58+
# Include sources
59+
source_group("Headers" FILES ${PROJECT_HEADERS})
60+
source_group("Shaders" FILES ${PROJECT_SHADERS})
61+
source_group("Sources" FILES ${PROJECT_SOURCES})
62+
source_group("Vendors" FILES ${VENDORS_SOURCES})
63+
64+
add_definitions(-DGLFW_INCLUDE_NONE
65+
-DPROJECT_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\")
66+
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ${PROJECT_HEADERS}
67+
${PROJECT_SHADERS} ${PROJECT_CONFIGS}
68+
${VENDORS_SOURCES})
69+
target_link_libraries(${PROJECT_NAME} assimp glfw
70+
${GLFW_LIBRARIES} ${GLAD_LIBRARIES}
71+
BulletDynamics BulletCollision LinearMath)
72+
set_target_properties(${PROJECT_NAME} PROPERTIES
73+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
74+
75+
#
76+
## Not sure if this is correct, but fixes c++ x64 arch issues with std
77+
#set (CMAKE_CXX_STANDARD 11)
78+
## includes cmake/FindSDL2.cmake
79+
#set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
80+
#
81+
#find_package (OpenGL REQUIRED)
82+
## @TODO switch SDL to GLFW
83+
#find_package(SDL2 REQUIRED)
84+
#find_package(GLEW REQUIRED)
85+
#include_directories(${SDL2_INCLUDE_DIR})
86+
#include_directories(${OPENGL_INCLUDE_DIR})
87+
#include_directories(${GLEW_INCLUDE_DIR})
88+
#include_directories(deps/include)
89+
#
90+
#file(GLOB SOURCE_FILES src/*.cpp)
91+
#
92+
#add_executable(webassembly_opengl ${SOURCE_FILES} src/main.cpp)
93+
#target_link_libraries(webassembly_opengl ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLM_LIBRARIES})
94+
#target_compile_features(webassembly_opengl PRIVATE cxx_range_for)

app/worker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// Post data to parent thread
2+
3+
/**
4+
* Sample worker
5+
* Good for including intense processes
6+
*/
27
postMessage({foo: 'foo'});
38

49
onmessage = (event) => {

src/headers/project.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Preprocessor Directives
2+
#ifndef OPIE
3+
#define OPIE
4+
#pragma once
5+
6+
// System Headers
7+
#include <assimp/Importer.hpp>
8+
#include <assimp/postprocess.h>
9+
#include <assimp/scene.h>
10+
#include <btBulletDynamicsCommon.h>
11+
#include <glad/glad.h>
12+
#include <glm/glm.hpp>
13+
#include <glm/gtc/type_ptr.hpp>
14+
15+
// Reference: https://github.com/nothings/stb/blob/master/stb_image.h#L4
16+
// To use stb_image, add this in *one* C++ source file.
17+
// #define STB_IMAGE_IMPLEMENTATION
18+
#include <stb_image.h>
19+
20+
// Define Some Constants
21+
const int mWidth = 1280;
22+
const int mHeight = 800;
23+
24+
#endif //~ Opie Header

src/main.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Local Headers
2+
#include "project.h"
3+
4+
// System Headers
5+
#include <glad/glad.h>
6+
#include <GLFW/glfw3.h>
7+
8+
// Standard Headers
9+
#include <cstdio>
10+
#include <cstdlib>
11+
12+
int main(int argc, char * argv[]) {
13+
14+
// Load GLFW and Create a Window
15+
glfwInit();
16+
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
17+
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
18+
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
19+
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
20+
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
21+
auto mWindow = glfwCreateWindow(mWidth, mHeight, "OpenGL", nullptr, nullptr);
22+
23+
// Check for Valid Context
24+
if (mWindow == nullptr) {
25+
fprintf(stderr, "Failed to Create OpenGL Context");
26+
return EXIT_FAILURE;
27+
}
28+
29+
// Create Context and Load OpenGL Functions
30+
glfwMakeContextCurrent(mWindow);
31+
gladLoadGL();
32+
fprintf(stderr, "OpenGL %s\n", glGetString(GL_VERSION));
33+
34+
// Rendering Loop
35+
while (glfwWindowShouldClose(mWindow) == false) {
36+
if (glfwGetKey(mWindow, GLFW_KEY_ESCAPE) == GLFW_PRESS)
37+
glfwSetWindowShouldClose(mWindow, true);
38+
39+
// Background Fill Color
40+
glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
41+
glClear(GL_COLOR_BUFFER_BIT);
42+
43+
// Flip Buffers and Draw
44+
glfwSwapBuffers(mWindow);
45+
glfwPollEvents();
46+
} glfwTerminate();
47+
return EXIT_SUCCESS;
48+
}

src/vendor/assimp

Submodule assimp added at b38ba23

src/vendor/bullet3

Submodule bullet3 added at afd6db7

src/vendor/glad

Submodule glad added at 5bf3eda

src/vendor/glfw

Submodule glfw added at be51c20

src/vendor/glm

Submodule glm added at 26b3e3e

src/vendor/stb

Submodule stb added at c711058

0 commit comments

Comments
 (0)