diff --git a/.gitmodules b/.gitmodules index 33128f3..a1a9dcd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "src/server/db/sqlite"] path = src/server/db/sqlite url = https://github.com/MallocNull/sqlite-amalgam.git +[submodule "include/server/sqlite"] + path = include/server/sqlite + url = https://github.com/MallocNull/sqlite-amalgam.git diff --git a/CMakeLists.txt b/CMakeLists.txt index e33f50f..1a70892 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,37 +4,38 @@ project(sockscape) string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} Debug _CMP) if(_CMP) set(CMAKE_VERBOSE_MAKEFILE ON) - add_definitions("-DSOSC_DEBUG") + add_definitions("-DCSC_DEBUG") endif() -string(COMPARE EQUAL ${SOSC_BUILD_TARGET} CLIENT _CMP) +string(COMPARE EQUAL ${CSC_BUILD_TARGET} CLIENT _CMP) if(_CMP) ################## ## CLIENT BUILD ## ################## - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -s USE_SDL=2 --preload-file ../resources/client") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} --shell-file ../src/client/shell.html") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\"]'") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_main\", \"_resize_context\"]'") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\"]'") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -s USE_SDL=2 --preload-file ../resources/client") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} --shell-file ../src/client/shell.html") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\"]'") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -s EXPORTED_FUNCTIONS='[\"_main\", \"_resize_context\"]'") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\"]'") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") set(CMAKE_EXECUTABLE_SUFFIX ".html") file(GLOB_RECURSE client_src - "src/common/*.hpp" - "src/common/*.cpp" - "src/client/*.hpp" - "src/client/*.cpp" + "src/common/*.h" + "src/common/*.c" + "src/client/*.h" + "src/client/*.c" + "include/client/*.h" + "include/client/*.c" ) add_executable(client ${client_src}) @@ -67,12 +68,12 @@ else() endif() file(GLOB_RECURSE server_src - "src/common/*.hpp" - "src/common/*.cpp" - "src/server/*.hpp" - "src/server/*.cpp" - "src/server/*.c" + "src/common/*.h" + "src/common/*.c" "src/server/*.h" + "src/server/*.c" + "include/server/*.h" + "include/server/*.c" ) find_package(OpenSSL) diff --git a/include/client/okuu/okuu.c b/include/client/okuu/okuu.c new file mode 100644 index 0000000..a67ef63 --- /dev/null +++ b/include/client/okuu/okuu.c @@ -0,0 +1,2 @@ +#include "okuu.h" + diff --git a/include/client/okuu/okuu.h b/include/client/okuu/okuu.h new file mode 100644 index 0000000..770cab7 --- /dev/null +++ b/include/client/okuu/okuu.h @@ -0,0 +1,67 @@ +#ifndef CSC_OKUU_H +#define CSC_OKUU_H + +#include + +/** PRIMITIVES **/ + +#define OKUU_MTYPE(T, R, C) \ + typedef union { \ + T mat[R][C]; \ + T gl[R*C]; \ + } + +#define OKUU_MTALL(R, C, N) \ + OKUU_MTYPE(GLint, R, C) N##i_t; \ + OKUU_MTYPE(GLuint, R, C) N##ui_t; \ + OKUU_MTYPE(GLfloat, R, C) N##f_t; + +OKUU_MTALL(4, 4, mat4); +OKUU_MTALL(3, 3, mat3); +OKUU_MTALL(2, 2, mat2); + +OKUU_MTALL(4, 1, vec4); +OKUU_MTALL(3, 1, vec3); +OKUU_MTALL(2, 1, vec2); + +/** END PRIMITIVES **/ + +/** MATRIX GEN FUNCS **/ + +#define OKUU_MGALL(M) \ + M(mat4i_t, i) \ + M(mat4ui_t, ui) \ + M(mat4f_t, f) + +#define OKUU_IDENT(T, S) \ + inline T okuu_ident##S(void) { \ + return (T) {{ \ + {1, 0, 0, 0}, \ + {0, 1, 0, 0}, \ + {0, 0, 1, 0}, \ + {0, 0, 0, 1}, \ + }}; \ + } + +OKUU_MGALL(OKUU_IDENT) + +mat4f_t okuu_ortho_ex + (GLfloat left, GLfloat right, + GLfloat top, GLfloat bottom, + GLfloat near, GLfloat far); + +inline mat4f_t okuu_ortho + (GLfloat left, GLfloat right, + GLfloat top, GLfloat bottom) +{ + return okuu_ortho_ex(left, right,top, bottom, -1, 1); +} + + +/** END MATRIX GEN FUNCS **/ + +/** MATRIX OPERATIONS **/ + +/** END MATRIX OPERATIONS **/ + +#endif diff --git a/include/server/orin/orin.c b/include/server/orin/orin.c new file mode 100644 index 0000000..3dfef1a --- /dev/null +++ b/include/server/orin/orin.c @@ -0,0 +1 @@ +#include "orin.h" diff --git a/include/server/orin/orin.h b/include/server/orin/orin.h new file mode 100644 index 0000000..9bc4df3 --- /dev/null +++ b/include/server/orin/orin.h @@ -0,0 +1,6 @@ +#ifndef CSC_ORIN_H +#define CSC_ORIN_H + + + +#endif diff --git a/include/server/sqlite b/include/server/sqlite new file mode 160000 index 0000000..24cc363 --- /dev/null +++ b/include/server/sqlite @@ -0,0 +1 @@ +Subproject commit 24cc3639a7a16f99fb12bbd6b0d0d835b3bfcda1 diff --git a/src/client/main.c b/src/client/main.c new file mode 100644 index 0000000..34006a5 --- /dev/null +++ b/src/client/main.c @@ -0,0 +1,74 @@ +#include +#include + +#include +#include +#include + +static struct { + SDL_Window* hwnd; + SDL_GLContext gl; +} _ctx; + +void draw(); + +int main(int argc, char** argv) { + if(argc != 3) + return -1; + + int client_width = atoi(argv[1]), + client_height = atoi(argv[2]); + + printf("VERSION 1: %i \r\n" + "%s\r\n%s\r\n%s\r\n", + argc, argv[0], argv[1], argv[2]); + + if(SDL_Init(SDL_INIT_VIDEO) < 0) { + printf("%s\r\n", SDL_GetError()); + return -1; + } + + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + _ctx.hwnd = SDL_CreateWindow( + "SockScape Client", + 0, 0, + client_width, client_height, + SDL_WINDOW_OPENGL + ); + + _ctx.gl = SDL_GL_CreateContext(_ctx.hwnd); + if(_ctx.gl == NULL) + return -1; + + if(glewInit() != GLEW_OK) + return -1; + + EM_ASM(setup_resize_event()); + + emscripten_set_main_loop(draw, 0, 1); + + SDL_GL_DeleteContext(_ctx.gl); + SDL_DestroyWindow(_ctx.hwnd); + return 0; +} + +void draw() { + glClear(GL_COLOR_BUFFER_BIT); + glClearColor(.25, .25, .25, 1); + + SDL_GL_SwapWindow(_ctx.hwnd); + + SDL_Event event; + while(SDL_PollEvent(&event)) { + if(event.type == SDL_WINDOWEVENT && + event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) + { + glViewport(0, 0, event.window.data1, event.window.data2); + } + } +} + +void resize_context(int width, int height) { + SDL_SetWindowSize(_ctx.hwnd, width, height); +} \ No newline at end of file diff --git a/src/server/main.c b/src/server/main.c new file mode 100644 index 0000000..e57294b --- /dev/null +++ b/src/server/main.c @@ -0,0 +1,5 @@ +#include + +int main(int argc, char** argv) { + return 0; +} \ No newline at end of file diff --git a/src/web/style.css b/src/web/style.css index c0a355b..0ca3b63 100644 --- a/src/web/style.css +++ b/src/web/style.css @@ -1,13 +1,6 @@ :root { - /**/ - --foreground-color: #000; - --background-color: #fff; - /**/ - - /* --foreground-color: #fff; --background-color: #000; - /**/ } body {