6 Commits 33331e2e65 ... 7edadea8e1

Author SHA1 Message Date
  Niels Nesse 7edadea8e1 Support building with MinGW 9 years ago
  Niels Nesse de40aefb39 Removing windows folder 9 years ago
  Niels Nesse a7e04ea75a Use CreateWindowEx instead of CreateWindow 9 years ago
  Niels Nesse 65aa3ad112 Set core profile on windows 9 years ago
  Niels Nesse 5cc4e348bf Dont' expose get/set thread state in headers for windows yet 9 years ago
  Niels Nesse 60237bd77a Merge src and include directories 9 years ago

+ 47 - 14
Makefile.am

@@ -1,18 +1,34 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include \
-	      -I$(top_srcdir)/include/math \
-	      -I$(top_srcdir)/include/glbindings
+AM_CPPFLAGS = -I$(top_srcdir)/src \
+	      -I$(top_srcdir)/src/glbindings
+
+#if WITH_MATH3D
+AM_CPPFLAGS += -I$(top_srcdir)/src/math
+#endif
 
 #if WITH_TEXT
-AM_CPPFLAGS += -I$(top_srcdir)/include/text
-#enif
+AM_CPPFLAGS += -I$(top_srcdir)/src/text
+#endif
 
 lib_LTLIBRARIES = libglplatform.la
 libglplatform_la_LIBADD=$(FREETYPE2_LIBS)
 libglplatform_la_CFLAGS=-std=c99 $(FREETYPE2_CFLAGS)
-libglplatform_la_SOURCES = src/glplatform-linux.c \
-			   src/glbindings/glplatform-glcore.c \
-			   src/glbindings/glplatform-glx.c \
-			   src/math/math3d.c
+libglplatform_la_SOURCES = src/glbindings/glplatform-glcore.c \
+			   src/glbindings/glplatform-wgl.c
+
+if WINDOWS
+libglplatform_la_SOURCES += src/glplatform-win32.c \
+			   src/glbindings/glplatform-wgl.c
+endif
+
+if LINUX_GNU
+libglplatform_la_SOURCES += src/glplatform-linux.c \
+			   src/glbindings/glplatform-glx.c
+endif
+
+if WITH_MATH3D
+libglplatform_la_SOURCES += src/math/math3d.c
+endif
+
 if WITH_TEXT
 libglplatform_la_SOURCES += src/text/gltext.c
 endif
@@ -22,17 +38,34 @@ if WITH_TEXT
 noinst_PROGRAMS += text_render
 endif
 
+if WINDOWS
+WINDOWS_LDADD = -lkernel32 -luser32 -lopengl32 -lgdi32
+endif
+
 simple_window_SOURCES = src/examples/simple_window.c
 simple_window_LDADD = libglplatform.la
 
+if WINDOWS
+simple_window_LDADD += $(WINDOWS_LDADD)
+endif
+
+
 text_render_SOURCES = src/examples/text_render.c
 text_render_CFLAGS = -DTTF_PATH=\"${abs_srcdir}/src/examples/ttf/\"
 text_render_LDADD = libglplatform.la
 
-pkginclude_HEADERS = include/glbindings/glplatform-glcore.h \
-		     include/glbindings/glplatform-glx.h \
-		     include/glplatform.h \
-		     include/math/math3d.h
+if WINDOWS
+text_render_LDADD += $(WINDOWS_LDADD)
+endif
+
+pkginclude_HEADERS = src/glbindings/glplatform-glcore.h \
+		     src/glbindings/glplatform-glx.h \
+		     src/glplatform.h
+
+if WITH_MATH3D
+pkginclude_HEADERS += src/math/math3d.h
+endif
+
 if WITH_TEXT
-pkginclude_HEADERS += include/text/gltext.h
+pkginclude_HEADERS += src/text/gltext.h
 endif

+ 2 - 3
Readme.md

@@ -102,10 +102,9 @@ On GNU/Linux systems `glplatform` can be built with it's autotools build system.
 
 On Windows systems `glplatform` can be built as a static library using the Visual Studio solution found in the `windows` folder.
 
-As a convienence `glplatform` comes with bindings pre-generated by `glbindify`. To rebuild them install `glbindify` and run the following commands:
+As a convienence `glplatform` comes with bindings pre-generated by `glbindify`. To rebuild them install `glbindify` and run the following commands
+in the `src/glbindings` folder:
 
 	glbindify -a gl -n glplatform
 	glbindify -a wgl -n glplatform
 	glbindify -a glx -n glplatform
-
-After the files generated copy them into `src/glbindings` and the generated header files into `include/glbindings`.

+ 15 - 8
configure.ac

@@ -1,24 +1,31 @@
 AC_PREREQ(2.59)
 AC_INIT(glplatform, 0.3)
 
+AC_CANONICAL_SYSTEM
+
+AM_INIT_AUTOMAKE([foreign subdir-objects])
+
 AC_ARG_ENABLE([text], AS_HELP_STRING([--enable-text], [Enables text rendering API]))
+AC_ARG_ENABLE([math3d], AS_HELP_STRING([--enable-math3d], [Enables 3D mathematics API]))
 
 if test x$enable_text = x; then
 	enable_text="yes"
 fi
-echo asfasf $enable_text
-
-if test $enable_text = yes; then
-	PKG_CHECK_MODULES(FREETYPE2,freetype2 >= 2.53, [ enable_text="yes" ], [ enable_text="no" ])
+if test x$enable_math3d = x; then
+	enable_math3d="yes"
 fi
 
-AC_CHECK_LIB([X11],[XOpenDisplay],,AC_MSG_ERROR([Could not find libX11]))
-AC_CHECK_LIB([GL],[glXGetProcAddress],,AC_MSG_ERROR([Could not find libGL]))
+AS_IF([ test $enable_text = yes ],
+	[PKG_CHECK_MODULES(FREETYPE2,freetype2 >= 2.53, [ enable_text="yes" ], [ enable_text="no" ])])
 
-AC_CANONICAL_SYSTEM
-AM_INIT_AUTOMAKE([foreign subdir-objects])
+AS_IF([ test $host_os = 'linux-gnu' ],
+	[AC_CHECK_LIB([X11],[XOpenDisplay],,AC_MSG_ERROR([Could not find libX11]))
+	 AC_CHECK_LIB([GL],[glXGetProcAddress],,AC_MSG_ERROR([Could not find libGL]))])
 
 AM_CONDITIONAL([WITH_TEXT], [ test $enable_text = yes ])
+AM_CONDITIONAL([WITH_MATH3D], [ test $enable_math3d = yes ])
+AM_CONDITIONAL([WINDOWS], [ test $host_os = mingw32 ])
+AM_CONDITIONAL([LINUX_GNU], [ test $host_os = linux-gnu ])
 
 LT_INIT()
 

+ 11 - 11
src/examples/simple_window.c

@@ -2,9 +2,9 @@
 #include "glplatform-glcore.h"
 
 #include <stdlib.h>
-
+#include <string.h>
 #ifdef _WIN32
-#include <Windows.h>
+#include <windows.h>
 #endif
 
 bool fullscreen = false;
@@ -25,20 +25,20 @@ void on_destroy(struct glplatform_win *win)
 	glplatform_destroy_window(win);
 }
 
-#ifdef _WIN32
+#if defined(_WIN32)
 int CALLBACK WinMain(
-	_In_ HINSTANCE hInstance,
-	_In_ HINSTANCE hPrevInstance,
-	_In_ LPSTR     lpCmdLine,
-	_In_ int       nCmdShow)
+	HINSTANCE hInstance,
+	HINSTANCE hPrevInstance,
+	LPSTR     lpCmdLine,
+	int       nCmdShow)
 #else
 int main()
 #endif
 {
-	struct glplatform_win_callbacks cb = {
-		.on_destroy = on_destroy,
-		.on_key_down = on_key_down
-	};
+	struct glplatform_win_callbacks cb;
+	memset(&cb, 0, sizeof(cb));
+	cb.on_destroy = on_destroy;
+	cb.on_key_down = on_key_down;
 	if (!glplatform_init()) {
 		exit(-1);
 	}

+ 1 - 1
src/examples/text_render.c

@@ -6,7 +6,7 @@
 #include "glplatform-glcore.h"
 
 #ifdef _WIN32
-#include <Windows.h>
+#include <windows.h>
 #endif
 
 void on_destroy(struct glplatform_win *win)

include/glbindings/glplatform-glcore.h → src/glbindings/glplatform-glcore.h


include/glbindings/glplatform-glx.h → src/glbindings/glplatform-glx.h


include/glbindings/glplatform-wgl.h → src/glbindings/glplatform-wgl.h


+ 3 - 2
src/glplatform-win32.c

@@ -3,6 +3,7 @@
 #define GLPLATFORM_ENABLE_WGL_ARB_create_context
 #define GLPLATFORM_ENABLE_WGL_ARB_create_context_profile
 #include "glplatform-wgl.h"
+
 #include <wingdi.h>
 
 //
@@ -256,7 +257,7 @@ struct glplatform_win *glplatform_create_window(const char *title,
 	RECT wr = { 0, 0, width, height };
 	AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
 
-	HWND hwnd = CreateWindow("glplatform",
+	HWND hwnd = CreateWindowEx(0, "glplatform",
 		title,
 		WS_OVERLAPPEDWINDOW,
 		CW_USEDEFAULT,
@@ -300,7 +301,7 @@ glplatform_gl_context_t glplatform_create_context(struct glplatform_win *win, in
 	int attribList[] = {
 		WGL_CONTEXT_MAJOR_VERSION_ARB, maj_ver,
 		WGL_CONTEXT_MINOR_VERSION_ARB, min_ver,
-		WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
+		WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
 		0
 	};
 

+ 0 - 0
include/glplatform.h


Some files were not shown because too many files changed in this diff