Add Wayland build option

This commit is contained in:
Stone Tickle 2020-09-29 11:00:06 +09:00
parent a9a09ab094
commit a4f83c55a6
No known key found for this signature in database
GPG Key ID: 4DF34BD9C2622309
3 changed files with 22 additions and 1 deletions

View File

@ -3,6 +3,15 @@ CXXFLAGS := $(CFLAGS) -std=c++17
DEFINES += -DIMGUI_IMPL_OPENGL_LOADER_GL3W
INCLUDES := $(shell pkg-config --cflags glfw3 freetype2 capstone) -I../../../imgui -I../../libs/gl3w
LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl
DISPLAY_SERVER := X11
libwayland_client := $(shell pkg-config --libs --silence-errors wayland-client)
ifeq ($(.SHELLSTATUS),0)
DISPLAY_SERVER := WAYLAND
LIBS += $(libwayland_client)
endif
CXXFLAGS += -D"DISPLAY_SERVER_$(DISPLAY_SERVER)"
PROJECT := Tracy
IMAGE := $(PROJECT)-$(BUILD)

View File

@ -6,7 +6,13 @@
# define GLFW_EXPOSE_NATIVE_WIN32
# include <GLFW/glfw3native.h>
#elif defined __linux__
# define GLFW_EXPOSE_NATIVE_X11
# ifdef DISPLAY_SERVER_X11
# define GLFW_EXPOSE_NATIVE_X11
# elif defined DISPLAY_SERVER_WAYLAND
# define GLFW_EXPOSE_NATIVE_WAYLAND
# else
# error "unsupported linux display server"
# endif
# include <GLFW/glfw3native.h>
#endif
@ -17,7 +23,11 @@ void* GetMainWindowNative()
#ifdef _WIN32
return (void*)glfwGetWin32Window( s_glfwWindow );
#elif defined __linux__
# ifdef DISPLAY_SERVER_X11
return (void*)glfwGetX11Window( s_glfwWindow );
# elif defined DISPLAY_SERVER_WAYLAND
return (void*)glfwGetWaylandWindow( s_glfwWindow );
# endif
#else
return nullptr;
#endif

View File

@ -244,7 +244,9 @@ int main( int argc, char** argv )
// Setup window
glfwSetErrorCallback(glfw_error_callback);
if( !glfwInit() ) return 1;
#ifndef DISPLAY_SERVER_WAYLAND
glfwWindowHint(GLFW_VISIBLE, 0);
#endif
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);