Skip to content

Commit

Permalink
Support building for wayland using USE_WAYLAND=1
Browse files Browse the repository at this point in the history
  • Loading branch information
kcleal committed Aug 30, 2024
1 parent ee0ec45 commit 348b96a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ else
endif
endif
endif

ifneq ($(PLATFORM),"Emscripten")
# try and add conda environment
ifdef CONDA_PREFIX
Expand Down Expand Up @@ -81,39 +82,37 @@ LIBGW_INCLUDE=
shared: LIBGW_INCLUDE=-I./libgw
CPPFLAGS += -I./lib/libBigWig -I./include -I. $(LIBGW_INCLUDE) -I./src
LDLIBS += -lskia -lm -ljpeg -lpng -lpthread

ifeq ($(PLATFORM),"Linux") # set platform flags and libs
ifeq (${XDG_SESSION_TYPE},"wayland") # wayland is untested!
LDLIBS += -lwayland-client
else
LDLIBS += -lX11
endif
CPPFLAGS += -I/usr/local/include
CXXFLAGS += -D LINUX -D __STDC_FORMAT_MACROS
LDFLAGS += -L/usr/local/lib
# If installed from conda, glfw3 is named glfw, therefore if glfw3 is installed by another means use this:
# LDLIBS += -lGL -lfreetype -lfontconfig -luuid -lzlib -licu -ldl $(shell pkg-config --static --libs x11 xrandr xi xxf86vm glfw3)
# LDLIBS += -lEGL -lGLESv2 -lfreetype -lfontconfig -luuid -lz -lcurl -licu -ldl -lglfw #$(shell pkg-config --static --libs x11 xrandr xi xxf86vm glfw3)
ifeq ($(USE_GL),"1")
LDLIBS += -lGL
else
LDLIBS += -lEGL -lGLESv2
LDLIBS += -lX11
ifeq ($(USE_WAYLAND),1)
LDLIBS += -lwayland-client -lwayland-egl
endif
LDLIBS += -lGL -lEGL
ifneq ($(USE_GL),1)
LDLIBS += -lGLESv2
endif
LDLIBS += -lhts -lfreetype -luuid -lz -lcurl -licu -ldl -lglfw -lsvg -lfontconfig

else ifeq ($(PLATFORM),"Darwin")
CPPFLAGS += -I/usr/local/include
CXXFLAGS += -D OSX -stdlib=libc++ -arch x86_64 -fvisibility=hidden -mmacosx-version-min=11 -Wno-deprecated-declarations
LDFLAGS += -undefined dynamic_lookup -framework OpenGL -framework AppKit -framework ApplicationServices -mmacosx-version-min=10.15 -L/usr/local/lib
LDLIBS += -lhts -lglfw -lzlib -lcurl -licu -ldl -lsvg -lfontconfig

else ifeq ($(PLATFORM),"Arm64")
CPPFLAGS += -I/usr/local/include
CXXFLAGS += -D OSX -stdlib=libc++ -arch arm64 -fvisibility=hidden -mmacosx-version-min=11 -Wno-deprecated-declarations
LDFLAGS += -undefined dynamic_lookup -framework OpenGL -framework AppKit -framework ApplicationServices -mmacosx-version-min=10.15 -L/usr/local/lib
LDLIBS += -lhts -lglfw -lzlib -lcurl -licu -ldl -lsvg -lfontconfig

else ifeq ($(PLATFORM),"Windows")
CXXFLAGS += -D WIN32
CPPFLAGS += $(shell pkgconf -cflags skia) $(shell ncursesw6-config --cflags)
LDLIBS += $(shell pkgconf -libs skia)
LDLIBS += -lhts -lharfbuzz-subset -lglfw3 -lcurl -lsvg -lfontconfig

else ifeq ($(PLATFORM),"Emscripten")
CPPFLAGS += -v --use-port=contrib.glfw3 -sUSE_ZLIB=1 -sUSE_FREETYPE=1 -sUSE_ICU=1 -I/usr/local/include
CFLAGS += -fPIC
Expand All @@ -128,6 +127,7 @@ OBJECTS += $(patsubst %.c, %.o, $(wildcard ./include/*.c))

debug: LDFLAGS += -fsanitize=address -fsanitize=undefined


$(TARGET): $(OBJECTS) # line 131
$(CXX) $(CXXFLAGS) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@

Expand Down
16 changes: 13 additions & 3 deletions src/plot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ namespace Manager {
}
bool opengl_es_loader = false;
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);

#ifndef __APPLE__ // linux, windows, termux
#ifdef USE_GL
Expand All @@ -255,7 +256,7 @@ namespace Manager {
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, (major_v == -1) ? 2 : major_v);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, (minor_v == -1) ? 0 : major_v);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, (minor_v == -1) ? 0 : minor_v);

opengl_es_loader = true;
#endif
Expand Down Expand Up @@ -348,6 +349,15 @@ namespace Manager {
std::cerr << "OpenGL renderer: " << rend << std::endl;
std::cerr << "OpenGL version: " << ver << std::endl;
std::cerr << "OpenGL vendor: " << ven << std::endl;
float xscale;
float yscale;
int windX, windY;
glfwGetWindowContentScale(window, &xscale, &yscale);
glfwGetFramebufferSize(window, &fb_width, &fb_height);
glfwGetWindowSize(window, &windX, &windY);
std::cerr << "Content x-scale=" << xscale << " y-scale=" << yscale << std::endl;
std::cerr << "Window width=" << windX << " height=" << windY << std::endl;
std::cerr << "Framebuffer width=" << width << " height=" << height << std::endl;
}

if (rasterSurfacePtr == nullptr) {
Expand Down Expand Up @@ -1773,12 +1783,12 @@ namespace Manager {

if (!cl.skipDrawingReads) {
if (opts.threads == 1) {
std::chrono::high_resolution_clock::time_point initial = std::chrono::high_resolution_clock::now();
// std::chrono::high_resolution_clock::time_point initial = std::chrono::high_resolution_clock::now();
HGW::iterDraw(cl, bams[cl.bamIdx], headers[cl.bamIdx], indexes[cl.bamIdx],
&regions[cl.regionIdx], (bool) opts.max_coverage,
filters, opts, canvas, trackY, yScaling, fonts, refSpace, pointSlop,
textDrop, pH, monitorScale);
std::cerr << " time runDrawNoBufferOnCanvas " << (std::chrono::duration_cast<std::chrono::milliseconds >(std::chrono::high_resolution_clock::now() - initial).count()) << std::endl;
// std::cerr << " time runDrawNoBufferOnCanvas " << (std::chrono::duration_cast<std::chrono::milliseconds >(std::chrono::high_resolution_clock::now() - initial).count()) << std::endl;
} else {
HGW::iterDrawParallel(cl, bams[cl.bamIdx], headers[cl.bamIdx], indexes[cl.bamIdx],
opts.threads, &regions[cl.regionIdx], (bool) opts.max_coverage,
Expand Down

0 comments on commit 348b96a

Please sign in to comment.