summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-09-26 23:45:31 +0200
committerTor Andersson <tor.andersson@artifex.com>2017-11-08 17:57:09 +0100
commit896830e23e8f94b17bdf386c191a885c972ea8a8 (patch)
tree061feda4707c8cc989df39e2440550a6ca1a2f7d
parent94a5846502cd1f05ec4127872ef06dcd8606f34b (diff)
downloadmupdf-896830e23e8f94b17bdf386c191a885c972ea8a8.tar.xz
gl: Remove GLFW and reinstate FreeGLUT.
GLFW doesn't build on Visual Studio 2005 anymore, and I don't have time to keep up with the changes. So, we're switching back to FreeGLUT, which is more stable. I've added the two missing features that made us switch to GLFW in the first place: input methods and system clipboard support. If MuPDF is compiled with our version of FreeGLUT, we now use these functions: * glutKeyboardExtFunc * glutSetClipboard * glutGetClipboard
-rw-r--r--.gitmodules12
-rw-r--r--Makefile18
-rw-r--r--Makerules6
-rw-r--r--Makethird157
-rw-r--r--platform/gl/gl-app.h8
-rw-r--r--platform/gl/gl-input.c30
-rw-r--r--platform/gl/gl-main.c357
-rw-r--r--platform/win32/libfreeglut.vcproj (renamed from platform/win32/libglfw.vcproj)180
-rw-r--r--platform/win32/mupdf-gl.vcproj58
-rw-r--r--platform/win32/mupdf.sln2
m---------thirdparty/freeglut0
m---------thirdparty/glfw0
12 files changed, 478 insertions, 350 deletions
diff --git a/.gitmodules b/.gitmodules
index 8d5899c4..acbc914b 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -13,18 +13,18 @@
[submodule "thirdparty/jpeg"]
path = thirdparty/libjpeg
url = ../thirdparty-libjpeg.git
+[submodule "thirdparty/lcms2"]
+ path = thirdparty/lcms2
+ url = ../thirdparty-lcms2.git
[submodule "thirdparty/openjpeg"]
path = thirdparty/openjpeg
url = ../thirdparty-openjpeg.git
[submodule "thirdparty/zlib"]
path = thirdparty/zlib
url = ../thirdparty-zlib.git
-[submodule "thirdparty/glfw"]
- path = thirdparty/glfw
- url = ../thirdparty-glfw.git
[submodule "thirdparty/curl"]
path = thirdparty/curl
url = ../thirdparty-curl.git
-[submodule "thirdparty/lcms2"]
- path = thirdparty/lcms2
- url = ../thirdparty-lcms2.git
+[submodule "thirdparty/freeglut"]
+ path = thirdparty/freeglut
+ url = ../thirdparty-freeglut.git
diff --git a/Makefile b/Makefile
index f444ab5a..7c5ea532 100644
--- a/Makefile
+++ b/Makefile
@@ -112,7 +112,7 @@ $(OUT)/platform/x11/curl/%.o : platform/x11/%.c | $(ALL_DIR)
$(CC_CMD) $(X11_CFLAGS) $(CURL_CFLAGS) -DHAVE_CURL
$(OUT)/platform/gl/%.o : platform/gl/%.c | $(ALL_DIR)
- $(CC_CMD) $(GLFW_CFLAGS)
+ $(CC_CMD) $(GLUT_CFLAGS)
$(OUT)/%.o : %.c | $(ALL_DIR)
$(CC_CMD)
@@ -392,12 +392,12 @@ $(MUVIEW_X11_CURL_EXE) : $(MUVIEW_X11_CURL_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(CURL
endif
endif
-ifeq "$(HAVE_GLFW)" "yes"
-MUVIEW_GLFW_EXE := $(OUT)/mupdf-gl
-MUVIEW_GLFW_OBJ := $(addprefix $(OUT)/platform/gl/, gl-font.o gl-input.o gl-main.o)
-$(MUVIEW_GLFW_OBJ) : $(FITZ_HDR) $(PDF_HDR) platform/gl/gl-app.h
-$(MUVIEW_GLFW_EXE) : $(MUVIEW_GLFW_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(GLFW_LIB)
- $(LINK_CMD) $(GLFW_LIBS)
+ifeq "$(HAVE_GLUT)" "yes"
+MUVIEW_GLUT_EXE := $(OUT)/mupdf-gl
+MUVIEW_GLUT_OBJ := $(addprefix $(OUT)/platform/gl/, gl-font.o gl-input.o gl-main.o)
+$(MUVIEW_GLUT_OBJ) : $(FITZ_HDR) $(PDF_HDR) platform/gl/gl-app.h
+$(MUVIEW_GLUT_EXE) : $(MUVIEW_GLUT_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(GLUT_LIB)
+ $(LINK_CMD) $(GLUT_LIB) $(GLUT_LIBS)
endif
ifeq "$(HAVE_WIN32)" "yes"
@@ -408,7 +408,7 @@ $(MUVIEW_WIN32_EXE) : $(MUVIEW_WIN32_OBJ) $(MUPDF_LIB) $(THIRD_LIB)
$(LINK_CMD) $(WIN32_LIBS)
endif
-MUVIEW_EXE := $(MUVIEW_X11_EXE) $(MUVIEW_WIN32_EXE) $(MUVIEW_GLFW_EXE)
+MUVIEW_EXE := $(MUVIEW_X11_EXE) $(MUVIEW_WIN32_EXE) $(MUVIEW_GLUT_EXE)
MUVIEW_CURL_EXE := $(MUVIEW_X11_CURL_EXE) $(MUVIEW_WIN32_CURL_EXE)
INSTALL_APPS := $(MUTOOL_EXE) $(MUVIEW_EXE)
@@ -453,7 +453,7 @@ mandir ?= $(prefix)/share/man
docdir ?= $(prefix)/share/doc/mupdf
third: $(THIRD_LIB)
-extra: $(CURL_LIB) $(GLFW_LIB)
+extra: $(CURL_LIB) $(GLUT_LIB)
libs: $(INSTALL_LIBS)
apps: $(INSTALL_APPS)
diff --git a/Makerules b/Makerules
index 56ba6ef4..41624178 100644
--- a/Makerules
+++ b/Makerules
@@ -114,6 +114,10 @@ HAVE_PTHREAD := yes
SYS_PTHREAD_CFLAGS :=
SYS_PTHREAD_LIBS := -lpthread
+HAVE_GLUT := yes
+SYS_GLUT_CFLAGS :=
+SYS_GLUT_LIBS := -lglut -lGL
+
ifeq "$(shell pkg-config --exists 'libcrypto <= 1.0.1t' && echo yes)" "yes"
HAVE_LIBCRYPTO := yes
SYS_LIBCRYPTO_CFLAGS := -DHAVE_LIBCRYPTO $(shell pkg-config --cflags libcrypto)
@@ -280,5 +284,5 @@ endif
# TODO: If crosscompiling, why not just call "make libs" instead of this exception?
ifeq "$(CROSSCOMPILE)" "yes"
HAVE_X11 ?= no
-HAVE_GLFW ?= no
+HAVE_GLUT ?= no
endif
diff --git a/Makethird b/Makethird
index a226249c..f83be6cc 100644
--- a/Makethird
+++ b/Makethird
@@ -18,7 +18,7 @@ OPENJPEG_DIR := thirdparty/openjpeg/src/lib/openjp2
ZLIB_DIR := thirdparty/zlib
CURL_DIR := thirdparty/curl
-GLFW_DIR := thirdparty/glfw
+GLUT_DIR := thirdparty/freeglut
# --- MuJS ---
@@ -659,92 +659,77 @@ CURL_CFLAGS := $(SYS_CURL_CFLAGS)
CURL_LIBS := $(SYS_CURL_LIBS)
endif
-# --- GLFW ---
-
-ifneq "$(wildcard $(GLFW_DIR)/README.md)" ""
-
-GLFW_LIB := $(OUT)/libglfw.a
-GLFW_OUT := $(OUT)/thirdparty/glfw
-
-ifeq "$(OS)" "MACOS"
-
-GLFW_SRC := \
- cocoa_init.m \
- cocoa_joystick.m \
- cocoa_monitor.m \
- cocoa_time.c \
- cocoa_window.m \
- context.c \
- init.c \
- input.c \
- monitor.c \
- nsgl_context.m \
- posix_tls.c \
- vulkan.c \
- window.c
-
-$(GLFW_OUT)/%.o: $(GLFW_DIR)/src/%.m | $(GLFW_OUT)
- $(CC_CMD) -D_GLFW_COCOA -D_GLFW_USE_MENUBAR -D_GLFW_USE_RETINA -Wno-deprecated-declarations
-$(GLFW_OUT)/%.o: $(GLFW_DIR)/src/%.c | $(GLFW_OUT)
- $(CC_CMD) -D_GLFW_COCOA -D_GLFW_USE_MENUBAR -D_GLFW_USE_RETINA
-
-GLFW_OBJ := $(addprefix $(GLFW_OUT)/, $(GLFW_SRC))
-GLFW_OBJ := $(GLFW_OBJ:%.c=%.o)
-GLFW_OBJ := $(GLFW_OBJ:%.m=%.o)
-
-$(GLFW_LIB): $(GLFW_OBJ)
-GLFW_LIBS := -framework OpenGL -framework IOKit -framework CoreVideo -framework Cocoa
-
-else
-
-GLFW_SRC := \
- context.c \
- egl_context.c \
- glx_context.c \
- init.c \
- input.c \
- linux_joystick.c \
- monitor.c \
- posix_time.c \
- posix_tls.c \
- vulkan.c \
- window.c \
- x11_init.c \
- x11_monitor.c \
- x11_window.c \
- xkb_unicode.c
-
-$(GLFW_OUT)/%.o: $(GLFW_DIR)/src/%.c | $(GLFW_OUT)
- $(CC_CMD) -D_GLFW_X11
-$(GLFW_LIB): $(addprefix $(GLFW_OUT)/, $(GLFW_SRC:%.c=%.o))
-GLFW_LIBS := -lGL -ldl -lX11 -lXcursor -lXrandr -lXinerama -lpthread
-
-endif
-
-GLFW_CFLAGS := -I$(GLFW_DIR)/include
-$(GLFW_OUT):
+# --- FreeGLUT ---
+
+ifneq "$(wildcard $(GLUT_DIR)/README)" ""
+
+HAVE_GLUT := yes
+
+GLUT_LIB := $(OUT)/libfreeglut.a
+GLUT_OUT := $(OUT)/freeglut
+GLUT_SRC := \
+ fg_callbacks.c \
+ fg_cursor.c \
+ fg_display.c \
+ fg_ext.c \
+ fg_font.c \
+ fg_font_data.c \
+ fg_gamemode.c \
+ fg_geometry.c \
+ fg_gl2.c \
+ fg_init.c \
+ fg_input_devices.c \
+ fg_joystick.c \
+ fg_main.c \
+ fg_menu.c \
+ fg_misc.c \
+ fg_overlay.c \
+ fg_spaceball.c \
+ fg_state.c \
+ fg_stroke_mono_roman.c \
+ fg_stroke_roman.c \
+ fg_structure.c \
+ fg_teapot.c \
+ fg_videoresize.c \
+ fg_window.c
+
+GLUT_X11_SRC := \
+ fg_cursor_x11.c \
+ fg_display_x11_glx.c \
+ fg_ext_x11.c \
+ fg_gamemode_x11.c \
+ fg_glutfont_definitions_x11.c \
+ fg_init_x11.c \
+ fg_input_devices_x11.c \
+ fg_joystick_x11.c \
+ fg_main_x11.c \
+ fg_menu_x11.c \
+ fg_spaceball_x11.c \
+ fg_state_x11.c \
+ fg_state_x11_glx.c \
+ fg_structure_x11.c \
+ fg_window_x11.c \
+ fg_window_x11_glx.c \
+ fg_xinput_x11.c
+
+GLUT_OBJ := $(addprefix $(GLUT_OUT)/, $(GLUT_SRC:%.c=%.o))
+GLUT_OBJ += $(addprefix $(GLUT_OUT)/, $(GLUT_X11_SRC:%.c=%.o))
+
+$(GLUT_LIB): $(GLUT_OBJ)
+$(GLUT_OUT):
$(MKDIR_CMD)
-
-GLFW_SRC_UNUSED := \
- mir_init.c \
- mir_monitor.c \
- mir_window.c \
- wgl_context.c \
- win32_init.c \
- win32_joystick.c \
- win32_monitor.c \
- win32_time.c \
- win32_tls.c \
- win32_window.c \
- wl_init.c \
- wl_monitor.c \
- wl_window.c \
-
-HAVE_GLFW := yes
-
-else ifeq "$(HAVE_GLFW)" "yes"
-GLFW_CFLAGS := $(SYS_GLFW_CFLAGS)
-GLFW_LIBS := $(SYS_GLFW_LIBS)
+$(GLUT_OUT)/%.o: $(GLUT_DIR)/src/%.c | $(GLUT_OUT)
+ $(CC_CMD) -I$(GLUT_DIR)/include -I$(GLUT_DIR)/src -Wno-unused-const-variable \
+ -DHAVE_UNISTD_H -DHAVE_STDINT_H -DHAVE_X11_EXTENSIONS_XRANDR_H
+$(GLUT_OUT)/%.o: $(GLUT_DIR)/src/x11/%.c | $(GLUT_OUT)
+ $(CC_CMD) -I$(GLUT_DIR)/include -I$(GLUT_DIR)/src \
+ -DHAVE_UNISTD_H -DHAVE_STDINT_H -DHAVE_X11_EXTENSIONS_XRANDR_H
+
+GLUT_CFLAGS := -I$(GLUT_DIR)/include
+GLUT_LIBS := -lGL -lX11 -lXrandr
+else
+GLUT_CFLAGS := $(SYS_GLUT_CFLAGS)
+GLUT_LIBS := $(SYS_GLUT_LIBS)
endif
# --- X11 ---
diff --git a/platform/gl/gl-app.h b/platform/gl/gl-app.h
index 7bff257b..a43654cf 100644
--- a/platform/gl/gl-app.h
+++ b/platform/gl/gl-app.h
@@ -7,10 +7,9 @@ int win_open_file(char *buf, int len);
#include "mupdf/fitz.h"
#include "mupdf/ucdn.h"
-#include <GLFW/glfw3.h>
+#include <GL/freeglut.h>
extern fz_context *ctx;
-extern GLFWwindow *window;
enum
{
@@ -57,7 +56,7 @@ struct ui
int x, y;
int down, middle, right;
int scroll_x, scroll_y;
- int key, mod;
+ int key, mod, plain;
void *hot, *active, *focus;
@@ -68,6 +67,9 @@ struct ui
extern struct ui ui;
+void ui_set_clipboard(const char *buf);
+const char *ui_get_clipboard(void);
+
void ui_init_fonts(fz_context *ctx, float pixelsize);
void ui_finish_fonts(fz_context *ctx);
float ui_measure_character(fz_context *ctx, int ucs);
diff --git a/platform/gl/gl-input.c b/platform/gl/gl-input.c
index 7ea9bafa..db42cace 100644
--- a/platform/gl/gl-input.c
+++ b/platform/gl/gl-input.c
@@ -112,18 +112,18 @@ static int ui_input_key(struct input *input)
switch (ui.key)
{
case KEY_LEFT:
- if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
+ if (ui.mod == GLUT_ACTIVE_CTRL + GLUT_ACTIVE_SHIFT)
{
input->q = prev_word(input->q, input->text);
}
- else if (ui.mod == GLFW_MOD_CONTROL)
+ else if (ui.mod == GLUT_ACTIVE_CTRL)
{
if (input->p != input->q)
input->p = input->q = input->p < input->q ? input->p : input->q;
else
input->p = input->q = prev_word(input->q, input->text);
}
- else if (ui.mod == GLFW_MOD_SHIFT)
+ else if (ui.mod == GLUT_ACTIVE_SHIFT)
{
if (input->q > input->text)
input->q = prev_char(input->q, input->text);
@@ -137,18 +137,18 @@ static int ui_input_key(struct input *input)
}
break;
case KEY_RIGHT:
- if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
+ if (ui.mod == GLUT_ACTIVE_CTRL + GLUT_ACTIVE_SHIFT)
{
input->q = next_word(input->q, input->end);
}
- else if (ui.mod == GLFW_MOD_CONTROL)
+ else if (ui.mod == GLUT_ACTIVE_CTRL)
{
if (input->p != input->q)
input->p = input->q = input->p > input->q ? input->p : input->q;
else
input->p = input->q = next_word(input->q, input->end);
}
- else if (ui.mod == GLFW_MOD_SHIFT)
+ else if (ui.mod == GLUT_ACTIVE_SHIFT)
{
if (input->q < input->end)
input->q = next_char(input->q);
@@ -163,15 +163,15 @@ static int ui_input_key(struct input *input)
break;
case KEY_UP:
case KEY_HOME:
- if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
+ if (ui.mod == GLUT_ACTIVE_CTRL + GLUT_ACTIVE_SHIFT)
{
input->q = input->text;
}
- else if (ui.mod == GLFW_MOD_CONTROL)
+ else if (ui.mod == GLUT_ACTIVE_CTRL)
{
input->p = input->q = input->text;
}
- else if (ui.mod == GLFW_MOD_SHIFT)
+ else if (ui.mod == GLUT_ACTIVE_SHIFT)
{
input->q = input->text;
}
@@ -182,15 +182,15 @@ static int ui_input_key(struct input *input)
break;
case KEY_DOWN:
case KEY_END:
- if (ui.mod == GLFW_MOD_CONTROL + GLFW_MOD_SHIFT)
+ if (ui.mod == GLUT_ACTIVE_CTRL + GLUT_ACTIVE_SHIFT)
{
input->q = input->end;
}
- else if (ui.mod == GLFW_MOD_CONTROL)
+ else if (ui.mod == GLUT_ACTIVE_CTRL)
{
input->p = input->q = input->end;
}
- else if (ui.mod == GLFW_MOD_SHIFT)
+ else if (ui.mod == GLUT_ACTIVE_SHIFT)
{
input->q = input->end;
}
@@ -254,20 +254,20 @@ static int ui_input_key(struct input *input)
char *q = input->p > input->q ? input->p : input->q;
memmove(buf, p, q - p);
buf[q-p] = 0;
- glfwSetClipboardString(window, buf);
+ ui_set_clipboard(buf);
if (ui.key == KEY_CTL_X)
ui_input_delete_selection(input);
}
break;
case KEY_CTL_V:
{
- const char *buf = glfwGetClipboardString(window);
+ const char *buf = ui_get_clipboard();
if (buf)
ui_input_paste(input, buf, (int)strlen(buf));
}
break;
default:
- if (ui.key >= 32)
+ if (ui.key >= 32 && ui.plain)
{
int cat = ucdn_get_general_category(ui.key);
if (ui.key == ' ' || (cat >= UCDN_GENERAL_CATEGORY_LL && cat < UCDN_GENERAL_CATEGORY_ZL))
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 5fc8d9b2..58b19d87 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -27,22 +27,15 @@ enum
DEFAULT_UI_LINEHEIGHT = 18,
};
-#define DEFAULT_WINDOW_W (612 * currentzoom / 72)
-#define DEFAULT_WINDOW_H (792 * currentzoom / 72)
-
struct ui ui;
fz_context *ctx = NULL;
-GLFWwindow *window = NULL;
/* OpenGL capabilities */
static int has_ARB_texture_non_power_of_two = 1;
static GLint max_texture_size = 8192;
-static int ui_needs_update = 0;
-
static void ui_begin(void)
{
- ui_needs_update = 0;
ui.hot = NULL;
}
@@ -50,8 +43,6 @@ static void ui_end(void)
{
if (!ui.down && !ui.middle && !ui.right)
ui.active = NULL;
- if (ui_needs_update)
- glfwPostEmptyEvent();
}
static void open_browser(const char *uri)
@@ -159,7 +150,6 @@ static float layout_em = DEFAULT_LAYOUT_EM;
static char *layout_css = NULL;
static int layout_use_doc_css = 1;
-static const char *fix_title = "MuPDFGL";
static const char *title = "MuPDF/GL";
static fz_document *doc = NULL;
static fz_page *page = NULL;
@@ -177,7 +167,6 @@ static int canvas_y = 0, canvas_h = 100;
static struct texture annot_tex[256];
static int annot_count = 0;
-static int screen_w = 1280, screen_h = 720;
static int window_w = 1, window_h = 1;
static int oldinvert = 0, currentinvert = 0;
@@ -185,6 +174,7 @@ static int oldpage = 0, currentpage = 0;
static float oldzoom = DEFRES, currentzoom = DEFRES;
static float oldrotate = 0, currentrotate = 0;
static fz_matrix page_ctm, page_inv_ctm;
+static int loaded = 0;
static int isfullscreen = 0;
static int showoutline = 0;
@@ -192,6 +182,7 @@ static int showlinks = 0;
static int showsearch = 0;
static int showinfo = 0;
static int showhelp = 0;
+static int doquit = 0;
struct mark
{
@@ -233,7 +224,8 @@ static void update_title(void)
sprintf(buf, "...%s - %d / %d", title + n - 50, currentpage + 1, fz_count_pages(ctx, doc));
else
sprintf(buf, "%s - %d / %d", title, currentpage + 1, fz_count_pages(ctx, doc));
- glfwSetWindowTitle(window, buf);
+ glutSetWindowTitle(buf);
+ glutSetIconTitle(buf);
}
void texture_from_pixmap(struct texture *tex, fz_pixmap *pix)
@@ -272,10 +264,10 @@ void texture_from_pixmap(struct texture *tex, fz_pixmap *pix)
}
}
-void render_page(void)
+void load_page(void)
{
- fz_annot *annot;
- fz_pixmap *pix;
+ fz_rect rect;
+ fz_irect irect;
fz_scale(&page_ctm, currentzoom / 72, currentzoom / 72);
fz_pre_rotate(&page_ctm, -currentrotate);
@@ -285,16 +277,35 @@ void render_page(void)
page = fz_load_page(ctx, doc, currentpage);
+ /* compute bounds here for initial window size */
+ fz_bound_page(ctx, page, &rect);
+ fz_transform_rect(&rect, &page_ctm);
+ fz_round_rect(&irect, &rect);
+ page_tex.w = irect.x1 - irect.x0;
+ page_tex.h = irect.y1 - irect.y0;
+
fz_drop_link(ctx, links);
links = NULL;
links = fz_load_links(ctx, page);
+ loaded = 1;
+}
+
+void render_page(void)
+{
+ fz_annot *annot;
+ fz_pixmap *pix;
+
+ if (!loaded)
+ load_page();
+
pix = fz_new_pixmap_from_page_contents(ctx, page, &page_ctm, fz_device_rgb(ctx), 0);
if (currentinvert)
{
fz_invert_pixmap(ctx, pix);
fz_gamma_pixmap(ctx, pix, 1 / 1.4f);
}
+
texture_from_pixmap(&page_tex, pix);
fz_drop_pixmap(ctx, pix);
@@ -310,6 +321,8 @@ void render_page(void)
break;
}
}
+
+ loaded = 0;
}
static struct mark save_mark()
@@ -420,7 +433,7 @@ static void do_copy_region(fz_rect *screen_sel, int xofs, int yofs)
#else
buf = fz_new_buffer_from_page(ctx, page, &page_sel, 0, NULL);
#endif
- glfwSetClipboardString(window, fz_string_from_buffer(ctx, buf));
+ ui_set_clipboard(fz_string_from_buffer(ctx, buf));
fz_drop_buffer(ctx, buf);
}
@@ -527,7 +540,7 @@ static int do_outline_imp(fz_outline *node, int end, int x0, int x1, int x, int
{
ui.active = node;
jump_to_page_xy(p, node->x, node->y);
- ui_needs_update = 1; /* we changed the current page, so force a redraw */
+ glutPostRedisplay(); /* we changed the current page, so force a redraw */
}
}
@@ -649,7 +662,7 @@ static void do_links(fz_link *link, int xofs, int yofs)
jump_to_page_xy(p, link_x, link_y);
else
fz_warn(ctx, "cannot find link destination '%s'", link->uri);
- ui_needs_update = 1;
+ glutPostRedisplay(); /* we changed the current page, so force a redraw */
}
}
}
@@ -692,7 +705,7 @@ static void do_page_selection(int x0, int y0, int x1, int y1)
if (ui.active == &sel && !ui.right)
{
do_copy_region(&sel, x0, y0);
- ui_needs_update = 1;
+ glutPostRedisplay();
}
}
@@ -748,7 +761,7 @@ static void do_forms(float xofs, float yofs)
ui.active = &do_forms_tag;
pdf_update_page(ctx, (pdf_page*)page);
render_page();
- ui_needs_update = 1;
+ glutPostRedisplay();
}
}
else if (ui.active == &do_forms_tag && !ui.down)
@@ -761,43 +774,48 @@ static void do_forms(float xofs, float yofs)
{
pdf_update_page(ctx, (pdf_page*)page);
render_page();
- ui_needs_update = 1;
+ glutPostRedisplay();
}
}
}
static void toggle_fullscreen(void)
{
- GLFWmonitor *monitor = glfwGetPrimaryMonitor();
static int win_x = 0, win_y = 0;
static int win_w = 100, win_h = 100;
- static int win_rr = 60;
if (!isfullscreen)
{
- const GLFWvidmode *mode = glfwGetVideoMode(monitor);
- glfwGetWindowPos(window, &win_x, &win_y);
- glfwGetWindowSize(window, &win_w, &win_h);
- win_rr = mode->refreshRate;
- glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
+ win_w = glutGet(GLUT_WINDOW_WIDTH);
+ win_h = glutGet(GLUT_WINDOW_HEIGHT);
+ win_x = glutGet(GLUT_WINDOW_X);
+ win_y = glutGet(GLUT_WINDOW_Y);
+ glutFullScreen();
isfullscreen = 1;
}
else
{
- glfwSetWindowMonitor(window, NULL, win_x, win_y, win_w, win_h, win_rr);
+ glutPositionWindow(win_x, win_y);
+ glutReshapeWindow(win_w, win_h);
isfullscreen = 0;
}
}
static void shrinkwrap(void)
{
- int w = fz_mini(page_tex.w + canvas_x, screen_w - SCREEN_FURNITURE_W);
- int h = fz_mini(page_tex.h + canvas_y, screen_h - SCREEN_FURNITURE_H);
+ int screen_w = glutGet(GLUT_SCREEN_WIDTH) - SCREEN_FURNITURE_W;
+ int screen_h = glutGet(GLUT_SCREEN_HEIGHT) - SCREEN_FURNITURE_H;
+ int w = page_tex.w + canvas_x;
+ int h = page_tex.h + canvas_y;
+ if (screen_w > 0 && w > screen_w)
+ w = screen_w;
+ if (screen_h > 0 && h > screen_h)
+ h = screen_h;
if (isfullscreen)
toggle_fullscreen();
- glfwSetWindowSize(window, w, h);
+ glutReshapeWindow(w, h);
}
-static void reload(void)
+static void load_document(void)
{
fz_drop_outline(ctx, outline);
fz_drop_document(ctx, doc);
@@ -834,7 +852,11 @@ static void reload(void)
anchor = NULL;
currentpage = fz_clampi(currentpage, 0, fz_count_pages(ctx, doc) - 1);
+}
+static void reload(void)
+{
+ load_document();
render_page();
update_title();
}
@@ -925,18 +947,18 @@ static void smart_move_forward(void)
static void quit(void)
{
- glfwSetWindowShouldClose(window, 1);
+ doquit = 1;
}
static void do_app(void)
{
- if (ui.key == KEY_F4 && ui.mod == GLFW_MOD_ALT)
+ if (ui.key == KEY_F4 && ui.mod == GLUT_ACTIVE_ALT)
quit();
if (ui.down || ui.middle || ui.right || ui.key)
showinfo = showhelp = 0;
- if (!ui.focus && ui.key)
+ if (!ui.focus && ui.key && ui.plain)
{
switch (ui.key)
{
@@ -1023,6 +1045,7 @@ static void do_app(void)
if (search_needle)
search_active = 1;
}
+ glutPostRedisplay();
break;
case 'n':
search_dir = 1;
@@ -1036,6 +1059,7 @@ static void do_app(void)
if (search_needle)
search_active = 1;
}
+ glutPostRedisplay();
break;
}
@@ -1052,8 +1076,6 @@ static void do_app(void)
if (search_hit_page != currentpage)
search_hit_page = -1; /* clear highlights when navigating */
- ui_needs_update = 1;
-
ui.key = 0; /* we ate the key event, so zap it */
}
}
@@ -1282,16 +1304,16 @@ static void run_main_loop(void)
if (search_active)
{
- float start_time = glfwGetTime();
+ int start_time = glutGet(GLUT_ELAPSED_TIME);
if (ui.key == KEY_ESCAPE)
search_active = 0;
/* ignore events during search */
- ui.key = ui.mod = 0;
+ ui.key = ui.mod = ui.plain = 0;
ui.down = ui.middle = ui.right = 0;
- while (glfwGetTime() < start_time + 0.2f)
+ while (glutGet(GLUT_ELAPSED_TIME) < start_time + 200)
{
search_hit_count = fz_search_page_number(ctx, doc, search_page, search_needle,
search_hit_bbox, nelem(search_hit_bbox));
@@ -1315,7 +1337,7 @@ static void run_main_loop(void)
/* keep searching later */
if (search_active)
- ui_needs_update = 1;
+ glutPostRedisplay();
}
do_app();
@@ -1340,6 +1362,7 @@ static void run_main_loop(void)
{
ui.focus = NULL;
showsearch = 0;
+ glutPostRedisplay();
}
else if (state == 1)
{
@@ -1357,8 +1380,8 @@ static void run_main_loop(void)
search_active = 1;
search_page = currentpage;
}
+ glutPostRedisplay();
}
- ui_needs_update = 1;
}
if (search_active)
@@ -1370,117 +1393,141 @@ static void run_main_loop(void)
ui_end();
- glfwSwapBuffers(window);
+ glutSwapBuffers();
ogl_assert(ctx, "swap buffers");
}
-static void on_char(GLFWwindow *window, unsigned int key, int mod)
+static void on_keyboard_ext(int key, int x, int y)
{
ui.key = key;
- ui.mod = mod;
+ ui.mod = glutGetModifiers();
+ ui.plain = !(ui.mod & ~GLUT_ACTIVE_SHIFT);
run_main_loop();
- ui.key = ui.mod = 0;
+ ui.key = ui.mod = ui.plain = 0;
}
-static void on_key(GLFWwindow *window, int special, int scan, int action, int mod)
+#if GLUT_API_VERSION < 5
+static void on_keyboard(unsigned char key, int x, int y)
{
- if (action == GLFW_PRESS || action == GLFW_REPEAT)
+ on_keyboard_ext(key, x, y);
+}
+#endif
+
+static void on_special(int key, int x, int y)
+{
+ ui.key = 0;
+
+ switch (key)
{
- ui.key = 0;
- switch (special)
- {
-#ifndef GLFW_MUPDF_FIXES
- /* regular control characters: ^A, ^B, etc. */
- default:
- if (special >= 'A' && special <= 'Z' && mod == GLFW_MOD_CONTROL)
- ui.key = KEY_CTL_A + special - 'A';
- break;
+ case GLUT_KEY_INSERT: ui.key = KEY_INSERT; break;
+ case GLUT_KEY_DELETE: ui.key = KEY_DELETE; break;
+ case GLUT_KEY_RIGHT: ui.key = KEY_RIGHT; break;
+ case GLUT_KEY_LEFT: ui.key = KEY_LEFT; break;
+ case GLUT_KEY_DOWN: ui.key = KEY_DOWN; break;
+ case GLUT_KEY_UP: ui.key = KEY_UP; break;
+ case GLUT_KEY_PAGE_UP: ui.key = KEY_PAGE_UP; break;
+ case GLUT_KEY_PAGE_DOWN: ui.key = KEY_PAGE_DOWN; break;
+ case GLUT_KEY_HOME: ui.key = KEY_HOME; break;
+ case GLUT_KEY_END: ui.key = KEY_END; break;
+ case GLUT_KEY_F1: ui.key = KEY_F1; break;
+ case GLUT_KEY_F2: ui.key = KEY_F2; break;
+ case GLUT_KEY_F3: ui.key = KEY_F3; break;
+ case GLUT_KEY_F4: ui.key = KEY_F4; break;
+ case GLUT_KEY_F5: ui.key = KEY_F5; break;
+ case GLUT_KEY_F6: ui.key = KEY_F6; break;
+ case GLUT_KEY_F7: ui.key = KEY_F7; break;
+ case GLUT_KEY_F8: ui.key = KEY_F8; break;
+ case GLUT_KEY_F9: ui.key = KEY_F9; break;
+ case GLUT_KEY_F10: ui.key = KEY_F10; break;
+ case GLUT_KEY_F11: ui.key = KEY_F11; break;
+ case GLUT_KEY_F12: ui.key = KEY_F12; break;
+ }
- /* regular control characters: escape, enter, backspace, tab */
- case GLFW_KEY_ESCAPE: ui.key = KEY_ESCAPE; break;
- case GLFW_KEY_ENTER: ui.key = KEY_ENTER; break;
- case GLFW_KEY_BACKSPACE: ui.key = KEY_BACKSPACE; break;
- case GLFW_KEY_TAB: ui.key = KEY_TAB; break;
-#endif
- case GLFW_KEY_INSERT: ui.key = KEY_INSERT; break;
- case GLFW_KEY_DELETE: ui.key = KEY_DELETE; break;
- case GLFW_KEY_RIGHT: ui.key = KEY_RIGHT; break;
- case GLFW_KEY_LEFT: ui.key = KEY_LEFT; break;
- case GLFW_KEY_DOWN: ui.key = KEY_DOWN; break;
- case GLFW_KEY_UP: ui.key = KEY_UP; break;
- case GLFW_KEY_PAGE_UP: ui.key = KEY_PAGE_UP; break;
- case GLFW_KEY_PAGE_DOWN: ui.key = KEY_PAGE_DOWN; break;
- case GLFW_KEY_HOME: ui.key = KEY_HOME; break;
- case GLFW_KEY_END: ui.key = KEY_END; break;
- case GLFW_KEY_F1: ui.key = KEY_F1; break;
- case GLFW_KEY_F2: ui.key = KEY_F2; break;
- case GLFW_KEY_F3: ui.key = KEY_F3; break;
- case GLFW_KEY_F4: ui.key = KEY_F4; break;
- case GLFW_KEY_F5: ui.key = KEY_F5; break;
- case GLFW_KEY_F6: ui.key = KEY_F6; break;
- case GLFW_KEY_F7: ui.key = KEY_F7; break;
- case GLFW_KEY_F8: ui.key = KEY_F8; break;
- case GLFW_KEY_F9: ui.key = KEY_F9; break;
- case GLFW_KEY_F10: ui.key = KEY_F10; break;
- case GLFW_KEY_F11: ui.key = KEY_F11; break;
- case GLFW_KEY_F12: ui.key = KEY_F12; break;
- }
- if (ui.key)
- {
- ui.mod = mod;
- run_main_loop();
- ui.key = ui.mod = 0;
- }
+ if (ui.key)
+ {
+ ui.mod = glutGetModifiers();
+ ui.plain = !(ui.mod & ~GLUT_ACTIVE_SHIFT);
+ run_main_loop();
+ ui.key = ui.mod = ui.plain = 0;
}
}
-static void on_mouse_button(GLFWwindow *window, int button, int action, int mod)
+static void on_mouse(int button, int action, int x, int y)
{
+ ui.x = x;
+ ui.y = y;
switch (button)
{
- case GLFW_MOUSE_BUTTON_LEFT: ui.down = (action == GLFW_PRESS); break;
- case GLFW_MOUSE_BUTTON_MIDDLE: ui.middle = (action == GLFW_PRESS); break;
- case GLFW_MOUSE_BUTTON_RIGHT: ui.right = (action == GLFW_PRESS); break;
+ case GLUT_LEFT_BUTTON: ui.down = (action == GLUT_DOWN); break;
+ case GLUT_MIDDLE_BUTTON: ui.middle = (action == GLUT_DOWN); break;
+ case GLUT_RIGHT_BUTTON: ui.right = (action == GLUT_DOWN); break;
}
-
run_main_loop();
}
-static void on_mouse_motion(GLFWwindow *window, double x, double y)
+static void on_motion(int x, int y)
{
ui.x = x;
ui.y = y;
- ui_needs_update = 1;
+ glutPostRedisplay();
}
-static void on_scroll(GLFWwindow *window, double x, double y)
+static void on_wheel(int wheel, int direction, int x, int y)
{
- ui.scroll_x = x;
- ui.scroll_y = y;
+ ui.scroll_x = wheel == 1 ? direction * 10 : 0;
+ ui.scroll_y = wheel == 0 ? direction * 10 : 0;
run_main_loop();
ui.scroll_x = ui.scroll_y = 0;
}
-static void on_reshape(GLFWwindow *window, int w, int h)
+static void on_reshape(int w, int h)
{
showinfo = 0;
+ showhelp = 0;
window_w = w;
window_h = h;
- ui_needs_update = 1;
}
-static void on_display(GLFWwindow *window)
+static void on_display(void)
{
- ui_needs_update = 1;
+ run_main_loop();
}
-static void on_error(int error, const char *msg)
+static void on_error(const char *fmt, va_list ap)
{
#ifdef _WIN32
- MessageBoxA(NULL, msg, "MuPDF GLFW Error", MB_ICONERROR);
+ char buf[1000];
+ fz_vsnprintf(buf, sizeof buf, fmt, ap);
+ MessageBoxA(NULL, buf, "MuPDF GLUT Error", MB_ICONERROR);
#else
- fprintf(stderr, "gl error %d: %s\n", error, msg);
+ fprintf(stderr, "GLUT error: ");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+#endif
+}
+
+static void on_warning(const char *fmt, va_list ap)
+{
+ fprintf(stderr, "GLUT warning: ");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+}
+
+// TODO: use native win32/x11 to get/set clipboard
+void ui_set_clipboard(const char *buf)
+{
+#if GLUT_API_VERSION >= 5
+ glutSetClipboard(GLUT_CLIPBOARD, buf);
+#endif
+}
+
+const char *ui_get_clipboard(void)
+{
+#if GLUT_API_VERSION >= 5
+ return glutGetClipboard(GLUT_CLIPBOARD);
+#else
+ return NULL;
#endif
}
@@ -1505,9 +1552,9 @@ int main_utf8(int argc, char **argv)
int main(int argc, char **argv)
#endif
{
- const GLFWvidmode *video_mode;
int c;
+ glutInit(&argc, argv);
while ((c = fz_getopt(argc, argv, "p:r:IW:H:S:U:X")) != -1)
{
switch (c)
@@ -1550,30 +1597,7 @@ int main(int argc, char **argv)
else
title = filename;
- memset(&ui, 0, sizeof ui);
-
- search_input.p = search_input.text;
- search_input.q = search_input.p;
- search_input.end = search_input.p;
-
- glfwSetErrorCallback(on_error);
-
- if (!glfwInit()) {
- fprintf(stderr, "cannot initialize glfw\n");
- exit(1);
- }
-
- video_mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
- screen_w = video_mode->width;
- screen_h = video_mode->height;
-
- window = glfwCreateWindow(DEFAULT_WINDOW_W, DEFAULT_WINDOW_H, fix_title, NULL, NULL);
- if (!window) {
- fprintf(stderr, "cannot create glfw window\n");
- exit(1);
- }
-
- glfwMakeContextCurrent(window);
+ /* Init MuPDF */
ctx = fz_new_context(NULL, NULL, 0);
fz_register_document_handlers(ctx);
@@ -1587,7 +1611,39 @@ int main(int argc, char **argv)
fz_set_use_document_css(ctx, layout_use_doc_css);
- has_ARB_texture_non_power_of_two = glfwExtensionSupported("GL_ARB_texture_non_power_of_two");
+ load_document();
+ load_page();
+
+ /* Init IMGUI */
+
+ memset(&ui, 0, sizeof ui);
+
+ search_input.p = search_input.text;
+ search_input.q = search_input.p;
+ search_input.end = search_input.p;
+
+ /* Init GLUT */
+
+ glutInitErrorFunc(on_error);
+ glutInitWarningFunc(on_warning);
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
+ glutInitWindowSize(page_tex.w, page_tex.h);
+ glutCreateWindow(title);
+
+ glutReshapeFunc(on_reshape);
+ glutDisplayFunc(on_display);
+#if GLUT_API_VERSION >= 5
+ glutKeyboardExtFunc(on_keyboard_ext);
+#else
+ glutKeyboardFunc(on_keyboard);
+#endif
+ glutSpecialFunc(on_special);
+ glutMouseFunc(on_mouse);
+ glutMotionFunc(on_motion);
+ glutPassiveMotionFunc(on_motion);
+ glutMouseWheelFunc(on_wheel);
+
+ has_ARB_texture_non_power_of_two = glutExtensionSupported("GL_ARB_texture_non_power_of_two");
if (!has_ARB_texture_non_power_of_two)
fz_warn(ctx, "OpenGL implementation does not support non-power of two texture sizes");
@@ -1599,31 +1655,16 @@ int main(int argc, char **argv)
ui_init_fonts(ctx, ui.fontsize);
- reload();
-
- shrinkwrap();
-
- glfwSetFramebufferSizeCallback(window, on_reshape);
- glfwSetCursorPosCallback(window, on_mouse_motion);
- glfwSetMouseButtonCallback(window, on_mouse_button);
- glfwSetScrollCallback(window, on_scroll);
- glfwSetCharModsCallback(window, on_char);
- glfwSetKeyCallback(window, on_key);
- glfwSetWindowRefreshCallback(window, on_display);
-
- glfwGetFramebufferSize(window, &window_w, &window_h);
-
- ui_needs_update = 1;
+ render_page();
+ update_title();
- while (!glfwWindowShouldClose(window))
- {
- glfwWaitEvents();
- if (ui_needs_update)
- run_main_loop();
- }
+ while (!doquit)
+ glutMainLoopEvent();
ui_finish_fonts(ctx);
+ glutExit();
+
#ifndef NDEBUG
if (fz_atoi(getenv("FZ_DEBUG_STORE")))
fz_debug_store(ctx);
@@ -1635,8 +1676,6 @@ int main(int argc, char **argv)
fz_drop_document(ctx, doc);
fz_drop_context(ctx);
- glfwTerminate();
-
return 0;
}
diff --git a/platform/win32/libglfw.vcproj b/platform/win32/libfreeglut.vcproj
index e63f99c3..9fb0c2b5 100644
--- a/platform/win32/libglfw.vcproj
+++ b/platform/win32/libfreeglut.vcproj
@@ -2,7 +2,7 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
- Name="libglfw"
+ Name="libfreeglut"
ProjectGUID="{A1B75D29-9F5C-4A0F-B368-322A10477D0C}"
RootNamespace="libglfw"
Keyword="Win32Proj"
@@ -23,7 +23,7 @@
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
- CharacterSet="1"
+ CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
@@ -43,8 +43,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\thirdparty\glfw\deps\mingw"
- PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_GLFW_WIN32;_GLFW_WGL;_GLFW_USE_OPENGL"
+ AdditionalIncludeDirectories="&quot;C:\Documents and Settings\admin\src\mupdf\thirdparty\freeglut\include&quot;"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;HAVE_U__INT64;NEED_XPARSEGEOMETRY_IMPL;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -86,7 +86,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
- CharacterSet="1"
+ CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
@@ -107,8 +107,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\thirdparty\glfw\deps\mingw"
- PreprocessorDefinitions="WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_GLFW_WIN32;_GLFW_WGL;_GLFW_USE_OPENGL"
+ AdditionalIncludeDirectories="&quot;C:\Documents and Settings\admin\src\mupdf\thirdparty\freeglut\include&quot;"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;HAVE_U__INT64;NEED_XPARSEGEOMETRY_IMPL;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -150,7 +150,7 @@
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
- CharacterSet="1"
+ CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
@@ -170,8 +170,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\thirdparty\glfw\deps\mingw"
- PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_GLFW_WIN32;_GLFW_WGL;_GLFW_USE_OPENGL;MEMENTO"
+ AdditionalIncludeDirectories="&quot;C:\Documents and Settings\admin\src\mupdf\thirdparty\freeglut\include&quot;"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;HAVE_U__INT64;NEED_XPARSEGEOMETRY_IMPL;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -213,7 +213,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
- CharacterSet="1"
+ CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
@@ -234,8 +234,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\thirdparty\glfw\deps\mingw"
- PreprocessorDefinitions="WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_GLFW_WIN32;_GLFW_WGL;_GLFW_USE_OPENGL;MEMENTO"
+ AdditionalIncludeDirectories="&quot;C:\Documents and Settings\admin\src\mupdf\thirdparty\freeglut\include&quot;"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;HAVE_U__INT64;NEED_XPARSEGEOMETRY_IMPL;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -277,7 +277,7 @@
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
- CharacterSet="1"
+ CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
@@ -297,8 +297,8 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\thirdparty\glfw\deps\mingw"
- PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_GLFW_WIN32;_GLFW_WGL;_GLFW_USE_OPENGL"
+ AdditionalIncludeDirectories="&quot;C:\Documents and Settings\admin\src\mupdf\thirdparty\freeglut\include&quot;"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;HAVE_U__INT64;NEED_XPARSEGEOMETRY_IMPL;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@@ -339,7 +339,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
- CharacterSet="1"
+ CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
@@ -360,8 +360,8 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\thirdparty\glfw\deps\mingw"
- PreprocessorDefinitions="WIN64;NDEBUG;_CRT_SECURE_NO_WARNINGS;_GLFW_WIN32;_GLFW_WGL;_GLFW_USE_OPENGL"
+ AdditionalIncludeDirectories="&quot;C:\Documents and Settings\admin\src\mupdf\thirdparty\freeglut\include&quot;"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;HAVE_U__INT64;NEED_XPARSEGEOMETRY_IMPL;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -401,14 +401,62 @@
</References>
<Files>
<Filter
- Name="include"
+ Name="mswin"
>
<File
- RelativePath="..\..\thirdparty\glfw\include\GLFW\glfw3.h"
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_cursor_mswin.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\include\GLFW\glfw3native.h"
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_display_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_ext_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_gamemode_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_init_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_input_devices_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_internal_mswin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_joystick_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_main_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_menu_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_spaceball_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_state_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_structure_mswin.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\mswin\fg_window_mswin.c"
>
</File>
</Filter>
@@ -416,83 +464,131 @@
Name="src"
>
<File
- RelativePath="..\..\thirdparty\glfw\src\context.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_callbacks.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\egl_context.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_cursor.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\egl_context.h"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_display.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\init.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_ext.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\input.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_font.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\internal.h"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_font_data.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\monitor.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_gamemode.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\vulkan.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_geometry.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\wgl_context.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_gl2.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\wgl_context.h"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_gl2.h"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_init.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_init.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_joystick.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_init.h"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_joystick.h"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_input_devices.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_monitor.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_internal.h"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_platform.h"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_joystick.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_time.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_main.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_tls.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_menu.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_tls.h"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_misc.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\win32_window.c"
+ RelativePath="..\..\thirdparty\freeglut\src\fg_overlay.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_spaceball.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_state.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_stroke_mono_roman.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_stroke_roman.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_structure.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_teapot.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_teapot_data.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_version.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_videoresize.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\fg_window.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="util"
+ >
+ <File
+ RelativePath="..\..\thirdparty\freeglut\src\util\xparsegeometry_repl.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\glfw\src\window.c"
+ RelativePath="..\..\thirdparty\freeglut\src\util\xparsegeometry_repl.h"
>
</File>
</Filter>
diff --git a/platform/win32/mupdf-gl.vcproj b/platform/win32/mupdf-gl.vcproj
index 8d25a8e8..f374aa4a 100644
--- a/platform/win32/mupdf-gl.vcproj
+++ b/platform/win32/mupdf-gl.vcproj
@@ -43,8 +43,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
- PreprocessorDefinitions="WIN32;_DEBUG"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;WIN32;_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -121,7 +121,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
PreprocessorDefinitions="WIN64;_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -142,7 +142,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -198,8 +198,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
- PreprocessorDefinitions="WIN32;_DEBUG;MEMENTO"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;WIN32;_DEBUG;MEMENTO"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -219,7 +219,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -273,7 +273,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
PreprocessorDefinitions="WIN64;_DEBUG;MEMENTO=1"
RuntimeLibrary="1"
/>
@@ -288,6 +288,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="opengl32.lib winmm.lib"
/>
<Tool
Name="VCALinkTool"
@@ -339,8 +340,8 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
- PreprocessorDefinitions="WIN32;NDEBUG"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;WIN32;NDEBUG"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@@ -359,7 +360,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -418,7 +419,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
PreprocessorDefinitions="WIN64;NDEBUG"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@@ -437,7 +438,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -495,8 +496,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
- PreprocessorDefinitions="WIN32;_DEBUG;MEMENTO"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;WIN32;_DEBUG;MEMENTO"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -516,7 +517,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -571,7 +572,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
PreprocessorDefinitions="WIN64;_DEBUG;MEMENTO"
RuntimeLibrary="1"
/>
@@ -586,6 +587,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="opengl32.lib winmm.lib"
TargetMachine="17"
/>
<Tool
@@ -638,8 +640,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
- PreprocessorDefinitions="WIN32;_DEBUG"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;WIN32;_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -659,7 +661,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -716,7 +718,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
PreprocessorDefinitions="WIN64;_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -737,7 +739,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -793,8 +795,8 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
- PreprocessorDefinitions="WIN32;NDEBUG"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ PreprocessorDefinitions="FREEGLUT_LIB_PRAGMAS=0;FREEGLUT_STATIC;WIN32;NDEBUG"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@@ -813,7 +815,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
@@ -872,7 +874,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\glfw\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\thirdparty\freeglut\include;..\..\scripts\freetype;..\..\thirdparty\freetype\include"
PreprocessorDefinitions="WIN64;NDEBUG"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@@ -891,7 +893,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="opengl32.lib"
+ AdditionalOptions="opengl32.lib winmm.lib"
LinkIncremental="0"
GenerateDebugInformation="true"
SubSystem="2"
diff --git a/platform/win32/mupdf.sln b/platform/win32/mupdf.sln
index 91bc3705..95ba2c1b 100644
--- a/platform/win32/mupdf.sln
+++ b/platform/win32/mupdf.sln
@@ -41,7 +41,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mujstest", "mujstest.vcproj
{5F615F91-DFF8-4F05-BF48-6222B7D86519} = {5F615F91-DFF8-4F05-BF48-6222B7D86519}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libglfw", "libglfw.vcproj", "{A1B75D29-9F5C-4A0F-B368-322A10477D0C}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfreeglut", "libfreeglut.vcproj", "{A1B75D29-9F5C-4A0F-B368-322A10477D0C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mupdf-gl", "mupdf-gl.vcproj", "{CE3A76A8-A28F-4991-8FB9-C9453D922037}"
ProjectSection(ProjectDependencies) = postProject
diff --git a/thirdparty/freeglut b/thirdparty/freeglut
new file mode 160000
+Subproject 850d2102eb302bdd03fd81af6b6becdb1f3ae2e
diff --git a/thirdparty/glfw b/thirdparty/glfw
deleted file mode 160000
-Subproject 0ab0c5a5b9edf0fd0e1ecbee0c777b9a837564b