This commit is contained in:
MallocNull 2018-09-11 16:51:27 -05:00
parent d0b13cd459
commit e38b603eb7
3 changed files with 89 additions and 80 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.7)
project(sockscape)
string(COMPARE EQUAL ${CMAKE_BUILD_TYPE} Debug _CMP)
@ -8,17 +8,18 @@ if(_CMP)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
#if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -s USE_SDL=2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\"]'")
#endif()
## CLIENT BUILD ##
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
#find_package(OpenGL REQUIRED)
#find_package(GLEW REQUIRED)
#find_package(SDL2 REQUIRED)
#find_package(SDL2_image REQUIRED)
file(GLOB_RECURSE client_src
"src/common/*.hpp"
@ -28,47 +29,48 @@ file(GLOB_RECURSE client_src
)
add_executable(client ${client_src})
target_include_directories(client
PRIVATE ${PROJECT_SOURCE_DIR}/src/common
PRIVATE ${PROJECT_SOURCE_DIR}/src/client
PRIVATE ${PROJECT_SOURCE_DIR}/include/client
PRIVATE ${OPENGL_INCLUDE_DIR}
PRIVATE ${GLEW_INCLUDE_DIR}
PRIVATE ${SDL2_INCLUDE_DIR}
PRIVATE ${SDL2_IMAGE_INCLUDE_DIR})
target_link_libraries(client
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARIES})
PRIVATE ${PROJECT_SOURCE_DIR}/include/client)
#PRIVATE ${OPENGL_INCLUDE_DIR}
#PRIVATE ${GLEW_INCLUDE_DIR}
#PRIVATE ${SDL2_INCLUDE_DIR}
#PRIVATE ${SDL2_IMAGE_INCLUDE_DIR})
#target_link_libraries(client
# ${OPENGL_LIBRARIES}
# ${GLEW_LIBRARY}
# ${SDL2_LIBRARY}
# ${SDL2_IMAGE_LIBRARIES})
install(TARGETS client RUNTIME DESTINATION bin/client)
## SERVER BUILD ##
file(GLOB_RECURSE server_src
"src/common/*.hpp"
"src/common/*.cpp"
"src/server/*.hpp"
"src/server/*.cpp"
"src/server/*.c"
"src/server/*.h"
)
#file(GLOB_RECURSE server_src
# "src/common/*.hpp"
# "src/common/*.cpp"
# "src/server/*.hpp"
# "src/server/*.cpp"
# "src/server/*.c"
# "src/server/*.h"
#)
add_executable(server ${server_src})
target_include_directories(server
PRIVATE ${PROJECT_SOURCE_DIR}/src/common
PRIVATE ${PROJECT_SOURCE_DIR}/src/server)
install(TARGETS server RUNTIME DESTINATION bin/server)
#add_executable(server ${server_src})
#target_include_directories(server
# PRIVATE ${PROJECT_SOURCE_DIR}/src/common
# PRIVATE ${PROJECT_SOURCE_DIR}/src/server)
#install(TARGETS server RUNTIME DESTINATION bin/server)
## COMMON LIBRARIES ##
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(server wsock32 ws2_32)
target_link_libraries(client wsock32 ws2_32)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(server dl pthread nsl resolv)
target_link_libraries(client dl pthread nsl resolv)
else()
target_link_libraries(server dl pthread socket nsl resolv)
target_link_libraries(client dl pthread socket nsl resolv)
endif()
#if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# target_link_libraries(server wsock32 ws2_32)
# target_link_libraries(client wsock32 ws2_32)
#elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# target_link_libraries(server dl pthread nsl resolv)
# target_link_libraries(client dl pthread nsl resolv)
#else()
# target_link_libraries(server dl pthread socket nsl resolv)
# target_link_libraries(client dl pthread socket nsl resolv)
#endif()

View file

@ -1,8 +1,8 @@
#include <SDL.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#define GLEW_STATIC
#include <GLM/glm.hpp>
#include <GLM/gtc/matrix_transform.hpp>
#include <GL/glew.h>
#include <emscripten.h>
#include "ui/font.hpp"
#include "shaders/test.hpp"
@ -17,6 +17,11 @@ void setupOrthoMode() {
}
void draw();
sosc::ui::Text text;
SDL_Window* window;
int main(int argc, char* argv[]) {
using namespace sosc;
@ -26,7 +31,7 @@ int main(int argc, char* argv[]) {
}
atexit(SDL_Quit);
auto window = SDL_CreateWindow(
window = SDL_CreateWindow(
"SockScape Client",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480,
@ -61,48 +66,50 @@ int main(int argc, char* argv[]) {
);
ui::font_set_default(&scapeFont);
ui::Text text(75, glm::vec4(1, 0, 0, 1),
"test", 100, 100, 400);
text = ui::Text(75, glm::vec4(1, 0, 0, 1), "test", 100, 100, 400);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
bool running = true;
while(running) {
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(.25, .25, .25, 1);
emscripten_set_main_loop(draw, 30, 1);
text.Render();
/*ui::font_deinit_subsystem();
SDL_GL_DeleteContext(ctx);
SDL_DestroyWindow(window);*/
SDL_GL_SwapWindow(window);
return 0;
}
SDL_Event event;
while(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT)
running = false;
void draw() {
using namespace sosc;
if(event.type == SDL_WINDOWEVENT &&
event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{
glViewport(0, 0, event.window.data1, event.window.data2);
ui::font_window_changed(window);
}
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(.25, .25, .25, 1);
if(event.type == SDL_KEYDOWN) {
switch(event.key.keysym.sym) {
case SDLK_ESCAPE:
running = false;
break;
default:
break;
}
text.Render();
SDL_GL_SwapWindow(window);
SDL_Event event;
while(SDL_PollEvent(&event)) {
/*if(event.type == SDL_QUIT)
running = false;*/
if(event.type == SDL_WINDOWEVENT &&
event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{
glViewport(0, 0, event.window.data1, event.window.data2);
ui::font_window_changed(window);
}
if(event.type == SDL_KEYDOWN) {
switch(event.key.keysym.sym) {
/*case SDLK_ESCAPE:
running = false;
break;*/
default:
break;
}
}
}
ui::font_deinit_subsystem();
SDL_GL_DeleteContext(ctx);
SDL_DestroyWindow(window);
return 0;
}

View file

@ -2,8 +2,8 @@
#define SOSC_SHADER_TEST_H
#include <SDL.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <GLM/glm.hpp>
#include <GLM/gtc/type_ptr.hpp>
#include "common.hpp"
#include "_shader.hpp"