Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Compatibility #6

Merged
merged 12 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ windows/.vs
windows/x64
windows/enc_temp_folder
windows/packages
linux/build/
racket/lib
racket/modules
third_party/racket/lib/x64
Expand Down
71 changes: 71 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
cmake_minimum_required(VERSION 3.14)
project(tangerine)

if (MSVC)
message(FATAL_ERROR
"Currently CMake is only used on the Linux platform.\
Visual Studio users should open the .sln file directly, instead.")
endif()

option(EMBED_LUA "Embed Lua support" ON)
option(EMBED_RACKET "Embed Racket support" OFF)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)

file(GLOB_RECURSE TANGERINE_FILES "tangerine/*.cpp")

if(EMBED_LUA)
file(GLOB TANGERINE_LUA_FILES "third_party/lua-5.4.4/lua/*.c")
list(FILTER
TANGERINE_LUA_FILES
EXCLUDE REGEX
".*/lua/(onelua|lua|luac)\.c") # these define main
endif()

file(GLOB TANGERINE_IMGUI_FILES
"third_party/imgui/*.cpp")

set(TANGERINE_THIRD_PARTY_FILES
${TANGERINE_IMGUI_FILES}
"third_party/imgui/backends/imgui_impl_opengl3.cpp"
"third_party/imgui/backends/imgui_impl_sdl.cpp"
"third_party/voxwriter/VoxWriter.cpp"
"third_party/fmt/src/format.cc"
"third_party/glad/glad.c"
${TANGERINE_LUA_FILES})

set(TANGERINE_INCLUDE_DIRS
"third_party"
"third_party/fmt/include"
"third_party/imgui"
"third_party/imgui/backends")

if(EMBED_LUA)
list(APPEND TANGERINE_INCLUDE_DIRS "third_party/lua-5.4.4")
endif()
if(EMBED_RACKET)
list(APPEND TANGERINE_INCLUDE_DIRS "third_party/racket/include")
endif()

add_executable(tangerine
${TANGERINE_FILES}
${TANGERINE_THIRD_PARTY_FILES})

find_package(SDL2 REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(
${TANGERINE_INCLUDE_DIRS}
${GTK3_INCLUDE_DIRS})

target_compile_definitions(tangerine PRIVATE
"EMBED_LUA=$<BOOL:${EMBED_LUA}>"
"EMBED_RACKET=$<BOOL:${EMBED_RACKET}>")

target_link_libraries(tangerine
SDL2::SDL2
"$<$<BOOL:${EMBED_RACKET}>:racketcs>"
tinfo
${GTK3_LIBRARIES})
28 changes: 8 additions & 20 deletions linux/build_majuscule.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@
cd `dirname $0`
cd ..

clang++ \
-std=c++17 \
-fPIC \
-U_WIN64 \
-Ithird_party/fmt/include \
-Ithird_party/imgui \
-Ithird_party/imgui/backends \
-Ithird_party \
-I/usr/include/racket \
-L/usr/lib/racket \
-lracket \
`pkg-config --libs --cflags sdl2 gtk+-3.0` \
tangerine/*.cpp \
third_party/imgui/*.cpp \
third_party/imgui/backends/imgui_impl_opengl3.cpp \
third_party/imgui/backends/imgui_impl_sdl.cpp \
third_party/fmt/src/format.cc \
third_party/Glad/glad.c \
third_party/voxwriter/VoxWriter.cpp \
-o package/tangerine/tangerine.out
cmake -B linux/build/Debug -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang
cmake -B linux/build/Release -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang

cmake --build linux/build/Release
3 changes: 3 additions & 0 deletions regen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
raco exe -v -o delete_me --collects-dest racket/collects ++lib tangerine ++lib tangerine/smol ++lib vec ++lib racket/base/lang/reader ++lib s-exp/lang/reader ++lib at-exp/lang/reader ++lib racket/runtime-config ++lib ffi/unsafe models/basic_thing.rkt

rm delete_me
2 changes: 1 addition & 1 deletion tangerine/embedding.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif

#ifndef EMBED_RACKET
#define EMBED_RACKET 1
#define EMBED_RACKET 0
#endif

#define EMBED_MULTI (EMBED_LUA + EMBED_RACKET) > 1
Expand Down
2 changes: 2 additions & 0 deletions tangerine/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
#include <mutex>
#include <thread>
#include <string>
#ifndef MINIMAL_DLL
#if _WIN64
#include <shobjidl.h>
#endif
#endif
#include <fmt/format.h>
#include "threadpool.h"
#include "extern.h"
Expand Down
4 changes: 3 additions & 1 deletion tangerine/gl_boilerplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ StatusCode RouteSource(std::vector<std::string>& BreadCrumbs, std::vector<std::s
}
return StatusCode::PASS;
}
//no match?
return StatusCode::FAIL;
}


Expand Down Expand Up @@ -512,7 +514,7 @@ Buffer::~Buffer()
}


inline void Buffer::Release()
void Buffer::Release()
{
if (BufferID != 0)
{
Expand Down
13 changes: 12 additions & 1 deletion tangerine/tangerine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
#include "gl_debug.h"
#include "../shaders/defines.h"

#ifndef _WIN64
//unsure if you prefer macro or function min/max
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#endif

#define MINIMUM_VERSION_MAJOR 4
#define MINIMUM_VERSION_MINOR 2

Expand Down Expand Up @@ -1361,7 +1367,7 @@ void RenderUI(SDL_Window* Window, bool& Live)
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);

std::string Msg = fmt::format("CSG Leaf Count: {}\n", LeafCount);
ImGui::SetTooltip(Msg.c_str());
ImGui::SetTooltip("%s", Msg.c_str());
}

if (ShowFocusOverlay)
Expand Down Expand Up @@ -1743,6 +1749,10 @@ void Boot(int argc, char* argv[])
BootRacket();
#endif
}
{
std::cout << "Initialize gtk+3.0... ";
gtk_init(&argc, &argv);
}
{
std::cout << "Setting up Dear ImGui... ";
IMGUI_CHECKVERSION();
Expand Down Expand Up @@ -2079,6 +2089,7 @@ void MainLoop()
}
}
EndEvent();
gtk_main_iteration_do(false);
}
}
}
Expand Down