extreme macros
This commit is contained in:
parent
b6d1ed7904
commit
67796685ac
10 changed files with 184 additions and 31 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
||||||
[submodule "src/server/db/sqlite"]
|
[submodule "src/server/db/sqlite"]
|
||||||
path = src/server/db/sqlite
|
path = src/server/db/sqlite
|
||||||
url = https://github.com/MallocNull/sqlite-amalgam.git
|
url = https://github.com/MallocNull/sqlite-amalgam.git
|
||||||
|
[submodule "include/server/sqlite"]
|
||||||
|
path = include/server/sqlite
|
||||||
|
url = https://github.com/MallocNull/sqlite-amalgam.git
|
||||||
|
|
|
@ -4,37 +4,38 @@ project(sockscape)
|
||||||
string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} Debug _CMP)
|
string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} Debug _CMP)
|
||||||
if(_CMP)
|
if(_CMP)
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
add_definitions("-DSOSC_DEBUG")
|
add_definitions("-DCSC_DEBUG")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
string(COMPARE EQUAL ${SOSC_BUILD_TARGET} CLIENT _CMP)
|
string(COMPARE EQUAL ${CSC_BUILD_TARGET} CLIENT _CMP)
|
||||||
if(_CMP)
|
if(_CMP)
|
||||||
|
|
||||||
##################
|
##################
|
||||||
## CLIENT BUILD ##
|
## CLIENT BUILD ##
|
||||||
##################
|
##################
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_C_FLAGS
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
"${CMAKE_C_FLAGS} -s USE_SDL=2 --preload-file ../resources/client")
|
||||||
|
set(CMAKE_C_FLAGS
|
||||||
set(CMAKE_CXX_FLAGS
|
"${CMAKE_C_FLAGS} --shell-file ../src/client/shell.html")
|
||||||
"${CMAKE_CXX_FLAGS} -s USE_SDL=2 --preload-file ../resources/client")
|
set(CMAKE_C_FLAGS
|
||||||
set(CMAKE_CXX_FLAGS
|
"${CMAKE_C_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\"]'")
|
||||||
"${CMAKE_CXX_FLAGS} --shell-file ../src/client/shell.html")
|
set(CMAKE_C_FLAGS
|
||||||
set(CMAKE_CXX_FLAGS
|
"${CMAKE_C_FLAGS} -s EXPORTED_FUNCTIONS='[\"_main\", \"_resize_context\"]'")
|
||||||
"${CMAKE_CXX_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\"]'")
|
set(CMAKE_C_FLAGS
|
||||||
set(CMAKE_CXX_FLAGS
|
"${CMAKE_C_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\"]'")
|
||||||
"${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_main\", \"_resize_context\"]'")
|
set(CMAKE_C_FLAGS
|
||||||
set(CMAKE_CXX_FLAGS
|
"${CMAKE_C_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
|
||||||
"${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\"]'")
|
|
||||||
|
|
||||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
|
|
||||||
file(GLOB_RECURSE client_src
|
file(GLOB_RECURSE client_src
|
||||||
"src/common/*.hpp"
|
"src/common/*.h"
|
||||||
"src/common/*.cpp"
|
"src/common/*.c"
|
||||||
"src/client/*.hpp"
|
"src/client/*.h"
|
||||||
"src/client/*.cpp"
|
"src/client/*.c"
|
||||||
|
"include/client/*.h"
|
||||||
|
"include/client/*.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(client ${client_src})
|
add_executable(client ${client_src})
|
||||||
|
@ -67,12 +68,12 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(GLOB_RECURSE server_src
|
file(GLOB_RECURSE server_src
|
||||||
"src/common/*.hpp"
|
"src/common/*.h"
|
||||||
"src/common/*.cpp"
|
"src/common/*.c"
|
||||||
"src/server/*.hpp"
|
|
||||||
"src/server/*.cpp"
|
|
||||||
"src/server/*.c"
|
|
||||||
"src/server/*.h"
|
"src/server/*.h"
|
||||||
|
"src/server/*.c"
|
||||||
|
"include/server/*.h"
|
||||||
|
"include/server/*.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(OpenSSL)
|
find_package(OpenSSL)
|
||||||
|
|
2
include/client/okuu/okuu.c
Normal file
2
include/client/okuu/okuu.c
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#include "okuu.h"
|
||||||
|
|
67
include/client/okuu/okuu.h
Normal file
67
include/client/okuu/okuu.h
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#ifndef CSC_OKUU_H
|
||||||
|
#define CSC_OKUU_H
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
/** 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
|
1
include/server/orin/orin.c
Normal file
1
include/server/orin/orin.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "orin.h"
|
6
include/server/orin/orin.h
Normal file
6
include/server/orin/orin.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef CSC_ORIN_H
|
||||||
|
#define CSC_ORIN_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
1
include/server/sqlite
Submodule
1
include/server/sqlite
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 24cc3639a7a16f99fb12bbd6b0d0d835b3bfcda1
|
74
src/client/main.c
Normal file
74
src/client/main.c
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <emscripten.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
5
src/server/main.c
Normal file
5
src/server/main.c
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,13 +1,6 @@
|
||||||
:root {
|
:root {
|
||||||
/**/
|
|
||||||
--foreground-color: #000;
|
|
||||||
--background-color: #fff;
|
|
||||||
/**/
|
|
||||||
|
|
||||||
/*
|
|
||||||
--foreground-color: #fff;
|
--foreground-color: #fff;
|
||||||
--background-color: #000;
|
--background-color: #000;
|
||||||
/**/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
Loading…
Reference in a new issue