[waffle] [PATCH 04/18] wgl: add skeleton implementation
Emil Velikov
emil.l.velikov at gmail.com
Tue Jul 22 20:31:30 PDT 2014
This commit adds the bare-bone skeleton needed to implement a waffle
platform. All the function that it provides are essentially empty.
Update the documentation, examples and utils to accept
WAFFLE_PLATFORM_WGL as a valid choice.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
cmake/Modules/WaffleDefineCompilerFlags.cmake | 4 +
cmake/Modules/WaffleDefineOS.cmake | 2 +
.../Modules/WafflePrintConfigurationSummary.cmake | 6 +
cmake/Modules/WaffleValidateOptions.cmake | 13 +++
examples/gl_basic.c | 3 +-
include/waffle/waffle.h | 1 +
man/waffle_display.3.xml | 2 +-
man/waffle_enum.3.xml | 1 +
man/waffle_init.3.xml | 8 ++
man/waffle_is_extension_in_string.3.xml | 2 +-
man/wflinfo.1.xml | 1 +
src/utils/wflinfo.c | 3 +-
src/waffle/CMakeLists.txt | 19 +++
src/waffle/api/waffle_init.c | 11 ++
src/waffle/core/wcore_util.c | 1 +
src/waffle/wgl/wgl_config.c | 72 ++++++++++++
src/waffle/wgl/wgl_config.h | 52 +++++++++
src/waffle/wgl/wgl_context.c | 70 +++++++++++
src/waffle/wgl/wgl_context.h | 51 ++++++++
src/waffle/wgl/wgl_display.c | 88 ++++++++++++++
src/waffle/wgl/wgl_display.h | 54 +++++++++
src/waffle/wgl/wgl_dl.c | 78 +++++++++++++
src/waffle/wgl/wgl_dl.h | 43 +++++++
src/waffle/wgl/wgl_error.c | 48 ++++++++
src/waffle/wgl/wgl_error.h | 32 ++++++
src/waffle/wgl/wgl_platform.c | 128 +++++++++++++++++++++
src/waffle/wgl/wgl_platform.h | 49 ++++++++
src/waffle/wgl/wgl_window.c | 87 ++++++++++++++
src/waffle/wgl/wgl_window.h | 63 ++++++++++
29 files changed, 988 insertions(+), 4 deletions(-)
create mode 100644 src/waffle/wgl/wgl_config.c
create mode 100644 src/waffle/wgl/wgl_config.h
create mode 100644 src/waffle/wgl/wgl_context.c
create mode 100644 src/waffle/wgl/wgl_context.h
create mode 100644 src/waffle/wgl/wgl_display.c
create mode 100644 src/waffle/wgl/wgl_display.h
create mode 100644 src/waffle/wgl/wgl_dl.c
create mode 100644 src/waffle/wgl/wgl_dl.h
create mode 100644 src/waffle/wgl/wgl_error.c
create mode 100644 src/waffle/wgl/wgl_error.h
create mode 100644 src/waffle/wgl/wgl_platform.c
create mode 100644 src/waffle/wgl/wgl_platform.h
create mode 100644 src/waffle/wgl/wgl_window.c
create mode 100644 src/waffle/wgl/wgl_window.h
diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake b/cmake/Modules/WaffleDefineCompilerFlags.cmake
index 4d149c8..b802250 100644
--- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
+++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
@@ -79,3 +79,7 @@ endif()
if(waffle_has_gbm)
add_definitions(-DWAFFLE_HAS_GBM)
endif()
+
+if(waffle_on_windows)
+ add_definitions(-DWAFFLE_HAS_WGL)
+endif()
diff --git a/cmake/Modules/WaffleDefineOS.cmake b/cmake/Modules/WaffleDefineOS.cmake
index c3ec3bb..38013a1 100644
--- a/cmake/Modules/WaffleDefineOS.cmake
+++ b/cmake/Modules/WaffleDefineOS.cmake
@@ -27,6 +27,8 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(waffle_on_linux true)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(waffle_on_mac true)
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
+ set(waffle_on_windows true)
else()
message(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME=\"${CMAKE_SYSTEM_NAME}\"")
endif()
diff --git a/cmake/Modules/WafflePrintConfigurationSummary.cmake b/cmake/Modules/WafflePrintConfigurationSummary.cmake
index 2b66fae..6ec5b73 100644
--- a/cmake/Modules/WafflePrintConfigurationSummary.cmake
+++ b/cmake/Modules/WafflePrintConfigurationSummary.cmake
@@ -32,6 +32,9 @@ message("Configuration summary")
message("-----------------------------------------------")
message("")
message("Supported platforms: ")
+if(waffle_on_mac)
+ message(" cgl")
+endif()
if(waffle_has_glx)
message(" glx")
endif()
@@ -44,6 +47,9 @@ endif()
if(waffle_has_gbm)
message(" gbm")
endif()
+if(waffle_on_windows)
+ message(" wgl")
+endif()
message("")
message("Dependencies:")
if(waffle_has_egl)
diff --git a/cmake/Modules/WaffleValidateOptions.cmake b/cmake/Modules/WaffleValidateOptions.cmake
index d9fc299..ea60b0e 100644
--- a/cmake/Modules/WaffleValidateOptions.cmake
+++ b/cmake/Modules/WaffleValidateOptions.cmake
@@ -135,4 +135,17 @@ elseif(waffle_on_mac)
if(waffle_has_x11_egl)
message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_x11_egl.")
endif()
+elseif(waffle_on_windows)
+ if(waffle_has_gbm)
+ message(FATAL_ERROR "Option is not supported on Windows: waffle_has_gbm.")
+ endif()
+ if(waffle_has_glx)
+ message(FATAL_ERROR "Option is not supported on Windows: waffle_has_glx.")
+ endif()
+ if(waffle_has_wayland)
+ message(FATAL_ERROR "Option is not supported on Windows: waffle_has_wayland.")
+ endif()
+ if(waffle_has_x11_egl)
+ message(FATAL_ERROR "Option is not supported on Windows: waffle_has_x11_egl.")
+ endif()
endif()
diff --git a/examples/gl_basic.c b/examples/gl_basic.c
index 8e1a28c..2c87711 100644
--- a/examples/gl_basic.c
+++ b/examples/gl_basic.c
@@ -57,7 +57,7 @@ removeXcodeArgs(int *argc, char **argv);
static const char *usage_message =
"usage:\n"
- " gl_basic --platform=android|cgl|gbm|glx|wayland|x11_egl\n"
+ " gl_basic --platform=android|cgl|gbm|glx|wayland|wgl|x11_egl\n"
" --api=gl|gles1|gles2|gles3\n"
" [--version=MAJOR.MINOR]\n"
" [--profile=core|compat|none]\n"
@@ -220,6 +220,7 @@ static const struct enum_map platform_map[] = {
{WAFFLE_PLATFORM_GBM, "gbm" },
{WAFFLE_PLATFORM_GLX, "glx" },
{WAFFLE_PLATFORM_WAYLAND, "wayland" },
+ {WAFFLE_PLATFORM_WGL, "wgl" },
{WAFFLE_PLATFORM_X11_EGL, "x11_egl" },
{0, 0 },
};
diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
index 91f3434..e04b23f 100644
--- a/include/waffle/waffle.h
+++ b/include/waffle/waffle.h
@@ -103,6 +103,7 @@ enum waffle_enum {
WAFFLE_PLATFORM_WAYLAND = 0x0014,
WAFFLE_PLATFORM_X11_EGL = 0x0015,
WAFFLE_PLATFORM_GBM = 0x0016,
+ WAFFLE_PLATFORM_WGL = 0x0017,
// ------------------------------------------------------------------
// For waffle_config_choose()
diff --git a/man/waffle_display.3.xml b/man/waffle_display.3.xml
index 755c632..824a01a 100644
--- a/man/waffle_display.3.xml
+++ b/man/waffle_display.3.xml
@@ -93,7 +93,7 @@ struct waffle_display;
given to <citerefentry><refentrytitle><function>waffle_init</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
<para>
- On Android and CGL, <parameter>name</parameter> is ignored.
+ On Android, CGL and WGL <parameter>name</parameter> is ignored.
</para>
<para>
On the X11 platforms, GLX and X11/EGL, the function connects to the X11 display with the given
diff --git a/man/waffle_enum.3.xml b/man/waffle_enum.3.xml
index c6ad548..a96bd20 100644
--- a/man/waffle_enum.3.xml
+++ b/man/waffle_enum.3.xml
@@ -100,6 +100,7 @@ enum waffle_enum {
WAFFLE_PLATFORM_WAYLAND = 0x0014,
WAFFLE_PLATFORM_X11_EGL = 0x0015,
WAFFLE_PLATFORM_GBM = 0x0016,
+ WAFFLE_PLATFORM_WGL = 0x0017,
// ------------------------------------------------------------------
// For waffle_config_choose()
diff --git a/man/waffle_init.3.xml b/man/waffle_init.3.xml
index a1b9cd3..a22723d 100644
--- a/man/waffle_init.3.xml
+++ b/man/waffle_init.3.xml
@@ -129,6 +129,14 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><constant>WAFFLE_PLATFORM_WGL</constant></term>
+ <listitem>
+ <para>
+ [Windows] Use WGL on Windows.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><constant>WAFFLE_PLATFORM_X11_EGL</constant></term>
<listitem>
<para>
diff --git a/man/waffle_is_extension_in_string.3.xml b/man/waffle_is_extension_in_string.3.xml
index 2734ea2..2808639 100644
--- a/man/waffle_is_extension_in_string.3.xml
+++ b/man/waffle_is_extension_in_string.3.xml
@@ -69,7 +69,7 @@
Note that this function is not restricted to the OpenGL extension string;
- it can also be used on the GLX and EGL extension strings.
+ it can also be used on the WGL, GLX and EGL extension strings.
</para>
<para>
diff --git a/man/wflinfo.1.xml b/man/wflinfo.1.xml
index 4060f38..c75dcf7 100644
--- a/man/wflinfo.1.xml
+++ b/man/wflinfo.1.xml
@@ -76,6 +76,7 @@
<member>gbm</member>
<member>glx</member>
<member>wayland</member>
+ <member>wgl</member>
<member>x11_egl</member>
</simplelist>
</para>
diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
index 0b03e55..20ff6b9 100644
--- a/src/utils/wflinfo.c
+++ b/src/utils/wflinfo.c
@@ -62,7 +62,7 @@ static const char *usage_message =
"\n"
"Required Parameters:\n"
" -p, --platform\n"
- " One of: android, cgl, gbm, glx, wayland or x11_egl\n"
+ " One of: android, cgl, gbm, glx, wayland, wgl or x11_egl\n"
"\n"
" -a, --api\n"
" One of: gl, gles1, gles2 or gles3\n"
@@ -251,6 +251,7 @@ static const struct enum_map platform_map[] = {
{WAFFLE_PLATFORM_GBM, "gbm" },
{WAFFLE_PLATFORM_GLX, "glx" },
{WAFFLE_PLATFORM_WAYLAND, "wayland" },
+ {WAFFLE_PLATFORM_WGL, "wgl" },
{WAFFLE_PLATFORM_X11_EGL, "x11_egl" },
{0, 0 },
};
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index 4dd2f38..7e4c007 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -16,6 +16,7 @@ include_directories(
glx
linux
wayland
+ wgl
x11
xegl
@@ -144,6 +145,22 @@ if(waffle_has_gbm)
)
endif()
+if(waffle_on_windows)
+ list(APPEND waffle_sources
+ wgl/wgl_config.c
+ wgl/wgl_context.c
+ wgl/wgl_display.c
+ wgl/wgl_dl.c
+ wgl/wgl_error.c
+ wgl/wgl_platform.c
+ wgl/wgl_window.c
+ )
+
+ list(APPEND waffle_libdeps
+ opengl32.lib
+ )
+endif()
+
# CMake will pass to the C compiler only C sources. CMake does not recognize the
# .m extension and ignores any such files in the source lists. To coerce CMake
# to pass .m files to the compiler, we must lie and claim that they are
@@ -181,7 +198,9 @@ endif()
install(
TARGETS ${waffle_libname}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT libraries
)
diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c
index b45c3ba..ebc6cd5 100644
--- a/src/waffle/api/waffle_init.c
+++ b/src/waffle/api/waffle_init.c
@@ -34,6 +34,7 @@ struct wcore_platform* glx_platform_create(void);
struct wcore_platform* wayland_platform_create(void);
struct wcore_platform* xegl_platform_create(void);
struct wcore_platform* wgbm_platform_create(void);
+struct wcore_platform* wgl_platform_create(void);
static bool
waffle_init_parse_attrib_list(
@@ -97,6 +98,12 @@ waffle_init_parse_attrib_list(
CASE_UNDEFINED_PLATFORM(GBM)
#endif
+#ifdef WAFFLE_HAS_WGL
+ CASE_DEFINED_PLATFORM(WGL)
+#else
+ CASE_UNDEFINED_PLATFORM(WGL)
+#endif
+
default:
wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
"WAFFLE_PLATFORM has bad value 0x%x",
@@ -153,6 +160,10 @@ waffle_init_create_platform(int32_t waffle_platform)
case WAFFLE_PLATFORM_GBM:
return wgbm_platform_create();
#endif
+#ifdef WAFFLE_HAS_WGL
+ case WAFFLE_PLATFORM_WGL:
+ return wgl_platform_create();
+#endif
default:
assert(false);
return NULL;
diff --git a/src/waffle/core/wcore_util.c b/src/waffle/core/wcore_util.c
index 2276dde..deee1bf 100644
--- a/src/waffle/core/wcore_util.c
+++ b/src/waffle/core/wcore_util.c
@@ -61,6 +61,7 @@ wcore_enum_to_string(int32_t e)
CASE(WAFFLE_PLATFORM_WAYLAND);
CASE(WAFFLE_PLATFORM_X11_EGL);
CASE(WAFFLE_PLATFORM_GBM);
+ CASE(WAFFLE_PLATFORM_WGL);
CASE(WAFFLE_CONTEXT_API);
CASE(WAFFLE_CONTEXT_OPENGL);
CASE(WAFFLE_CONTEXT_OPENGL_ES1);
diff --git a/src/waffle/wgl/wgl_config.c b/src/waffle/wgl/wgl_config.c
new file mode 100644
index 0000000..3bf8e33
--- /dev/null
+++ b/src/waffle/wgl/wgl_config.c
@@ -0,0 +1,72 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "wcore_config_attrs.h"
+#include "wcore_error.h"
+
+#include "wgl_config.h"
+#include "wgl_error.h"
+#include "wgl_platform.h"
+
+bool
+wgl_config_destroy(struct wcore_config *wc_self)
+{
+ struct wgl_config *self = wgl_config(wc_self);
+ bool ok;
+
+ if (!self)
+ return true;
+
+ ok = wcore_config_teardown(wc_self);
+ free(self);
+ return ok;
+}
+
+struct wcore_config*
+wgl_config_choose(struct wcore_platform *wc_plat,
+ struct wcore_display *wc_dpy,
+ const struct wcore_config_attrs *attrs)
+{
+ struct wgl_config *self;
+ bool ok;
+
+ self = wcore_calloc(sizeof(*self));
+ if (!self)
+ return NULL;
+
+ ok = wcore_config_init(&self->wcore, wc_dpy, attrs);
+ if (!ok)
+ goto error;
+
+ return &self->wcore;
+
+error:
+ wgl_config_destroy(&self->wcore);
+ return NULL;
+}
diff --git a/src/waffle/wgl/wgl_config.h b/src/waffle/wgl/wgl_config.h
new file mode 100644
index 0000000..5b58b42
--- /dev/null
+++ b/src/waffle/wgl/wgl_config.h
@@ -0,0 +1,52 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "wcore_config.h"
+#include "wcore_util.h"
+
+struct wcore_config_attrs;
+struct wcore_platform;
+
+struct wgl_config {
+ struct wcore_config wcore;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(wgl_config,
+ struct wgl_config,
+ struct wcore_config,
+ wcore)
+
+struct wcore_config*
+wgl_config_choose(struct wcore_platform *wc_plat,
+ struct wcore_display *wc_dpy,
+ const struct wcore_config_attrs *attrs);
+
+bool
+wgl_config_destroy(struct wcore_config *wc_self);
diff --git a/src/waffle/wgl/wgl_context.c b/src/waffle/wgl/wgl_context.c
new file mode 100644
index 0000000..a44176c
--- /dev/null
+++ b/src/waffle/wgl/wgl_context.c
@@ -0,0 +1,70 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "wcore_error.h"
+
+#include "wgl_config.h"
+#include "wgl_context.h"
+#include "wgl_error.h"
+
+bool
+wgl_context_destroy(struct wcore_context *wc_self)
+{
+ struct wgl_context *self = wgl_context(wc_self);
+ bool ok;
+
+ if (!self)
+ return true;
+
+ ok = wcore_context_teardown(wc_self);
+ free(self);
+ return ok;
+}
+
+struct wcore_context*
+wgl_context_create(struct wcore_platform *wc_plat,
+ struct wcore_config *wc_config,
+ struct wcore_context *wc_share_ctx)
+{
+ struct wgl_context *self;
+ int error;
+
+ self = wcore_calloc(sizeof(*self));
+ if (!self)
+ return NULL;
+
+ error = !wcore_context_init(&self->wcore, wc_config);
+ if (error)
+ goto fail;
+
+ return &self->wcore;
+
+fail:
+ wgl_context_destroy(&self->wcore);
+ return NULL;
+}
diff --git a/src/waffle/wgl/wgl_context.h b/src/waffle/wgl/wgl_context.h
new file mode 100644
index 0000000..d737a13
--- /dev/null
+++ b/src/waffle/wgl/wgl_context.h
@@ -0,0 +1,51 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#pragma once
+
+#include <stdbool.h>
+
+#include "wcore_context.h"
+#include "wcore_util.h"
+
+struct wcore_config;
+struct wcore_platform;
+
+struct wgl_context {
+ struct wcore_context wcore;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(wgl_context,
+ struct wgl_context,
+ struct wcore_context,
+ wcore)
+
+struct wcore_context*
+wgl_context_create(struct wcore_platform *wc_plat,
+ struct wcore_config *wc_config,
+ struct wcore_context *wc_share_ctx);
+
+bool
+wgl_context_destroy(struct wcore_context *wc_self);
diff --git a/src/waffle/wgl/wgl_display.c b/src/waffle/wgl/wgl_display.c
new file mode 100644
index 0000000..a51e538
--- /dev/null
+++ b/src/waffle/wgl/wgl_display.c
@@ -0,0 +1,88 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+#include <stdlib.h>
+
+#include "wcore_error.h"
+
+#include "wgl_display.h"
+
+bool
+wgl_display_destroy(struct wcore_display *wc_self)
+{
+ struct wgl_display *self = wgl_display(wc_self);
+ bool ok;
+
+ if (!self)
+ return true;
+
+ ok = wcore_display_teardown(wc_self);
+ free(self);
+ return ok;
+}
+
+
+struct wcore_display*
+wgl_display_connect(struct wcore_platform *wc_plat,
+ const char *name)
+{
+ struct wgl_display *self;
+ bool ok;
+
+ self = wcore_calloc(sizeof(*self));
+ if (!self)
+ return NULL;
+
+ ok = wcore_display_init(&self->wcore, wc_plat);
+ if (!ok)
+ goto error;
+
+ return &self->wcore;
+
+error:
+ wgl_display_destroy(&self->wcore);
+ return NULL;
+}
+
+bool
+wgl_display_supports_context_api(struct wcore_display *wc_self,
+ int32_t context_api)
+{
+ switch (context_api) {
+ case WAFFLE_CONTEXT_OPENGL:
+ return true;
+ case WAFFLE_CONTEXT_OPENGL_ES1:
+ return false;
+ case WAFFLE_CONTEXT_OPENGL_ES2:
+ return false;
+ case WAFFLE_CONTEXT_OPENGL_ES3:
+ return false;
+ default:
+ wcore_error_internal("waffle_context_api has bad value %#x",
+ context_api);
+ return false;
+ }
+}
diff --git a/src/waffle/wgl/wgl_display.h b/src/waffle/wgl/wgl_display.h
new file mode 100644
index 0000000..262ab18
--- /dev/null
+++ b/src/waffle/wgl/wgl_display.h
@@ -0,0 +1,54 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "wcore_display.h"
+#include "wcore_util.h"
+
+struct wcore_platform;
+
+struct wgl_display {
+ struct wcore_display wcore;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(wgl_display,
+ struct wgl_display,
+ struct wcore_display,
+ wcore)
+
+struct wcore_display*
+wgl_display_connect(struct wcore_platform *wc_plat,
+ const char *name);
+
+bool
+wgl_display_destroy(struct wcore_display *wc_self);
+
+bool
+wgl_display_supports_context_api(struct wcore_display *wc_self,
+ int32_t context_api);
diff --git a/src/waffle/wgl/wgl_dl.c b/src/waffle/wgl/wgl_dl.c
new file mode 100644
index 0000000..2141f69
--- /dev/null
+++ b/src/waffle/wgl/wgl_dl.c
@@ -0,0 +1,78 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+#include <assert.h>
+#include <windows.h>
+
+#include "wcore_error.h"
+
+#include "wgl_dl.h"
+#include "wgl_platform.h"
+
+static bool
+wgl_dl_check_enum(int32_t waffle_dl)
+{
+ switch (waffle_dl) {
+ case WAFFLE_DL_OPENGL:
+ return false;
+ case WAFFLE_DL_OPENGL_ES1:
+ return false;
+ case WAFFLE_DL_OPENGL_ES2:
+ return false;
+ case WAFFLE_DL_OPENGL_ES3:
+ return false;
+ default:
+ assert(false);
+ return false;
+ }
+}
+
+static bool
+wgl_dl_open(struct wgl_platform *plat)
+{
+ return false;
+}
+
+bool
+wgl_dl_can_open(struct wcore_platform *wc_plat,
+ int32_t waffle_dl)
+{
+ return false;
+}
+
+void*
+wgl_dl_sym(struct wcore_platform *wc_plat,
+ int32_t waffle_dl,
+ const char *name)
+{
+ return NULL;
+}
+
+bool
+wgl_dl_close(struct wcore_platform *wc_plat)
+{
+ return false;
+}
diff --git a/src/waffle/wgl/wgl_dl.h b/src/waffle/wgl/wgl_dl.h
new file mode 100644
index 0000000..6ccd170
--- /dev/null
+++ b/src/waffle/wgl/wgl_dl.h
@@ -0,0 +1,43 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+struct wcore_platform;
+
+bool
+wgl_dl_can_open(struct wcore_platform *wc_plat,
+ int32_t waffle_dl);
+
+void*
+wgl_dl_sym(struct wcore_platform *wc_plat,
+ int32_t waffle_dl,
+ const char *name);
+
+bool
+wgl_dl_close(struct wcore_platform *wc_plat);
diff --git a/src/waffle/wgl/wgl_error.c b/src/waffle/wgl/wgl_error.c
new file mode 100644
index 0000000..679ff43
--- /dev/null
+++ b/src/waffle/wgl/wgl_error.c
@@ -0,0 +1,48 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include "wcore_error.h"
+
+#include "wgl_error.h"
+
+const char*
+wgl_error_to_string(int error_code)
+{
+ return NULL;
+}
+
+void
+wgl_error_failed_func(const char *func_name, int error_code)
+{
+ wcore_errorf(WAFFLE_ERROR_UNKNOWN,
+ "%s failed with %s: %s",
+ func_name,
+ wgl_error_to_string(error_code),
+ NULL);
+}
diff --git a/src/waffle/wgl/wgl_error.h b/src/waffle/wgl/wgl_error.h
new file mode 100644
index 0000000..aca0769
--- /dev/null
+++ b/src/waffle/wgl/wgl_error.h
@@ -0,0 +1,32 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#pragma once
+
+const char*
+wgl_error_to_string(int error_code);
+
+void
+wgl_error_failed_func(const char *func_name, int error_code);
diff --git a/src/waffle/wgl/wgl_platform.c b/src/waffle/wgl/wgl_platform.c
new file mode 100644
index 0000000..6c31c7e
--- /dev/null
+++ b/src/waffle/wgl/wgl_platform.c
@@ -0,0 +1,128 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <stdlib.h>
+
+#include "wcore_error.h"
+
+#include "wgl_config.h"
+#include "wgl_context.h"
+#include "wgl_display.h"
+#include "wgl_dl.h"
+#include "wgl_platform.h"
+#include "wgl_window.h"
+
+static const struct wcore_platform_vtbl wgl_platform_vtbl;
+
+static bool
+wgl_platform_destroy(struct wcore_platform *wc_self)
+{
+ struct wgl_platform *self = wgl_platform(wc_self);
+ bool ok = true;
+
+ if (!self)
+ return true;
+
+ if (self->dl_gl)
+ ok &= wgl_dl_close(wc_self);
+
+ ok &= wcore_platform_teardown(wc_self);
+ free(self);
+ return ok;
+}
+
+struct wcore_platform*
+wgl_platform_create(void)
+{
+ struct wgl_platform *self;
+ bool ok;
+
+ self = wcore_calloc(sizeof(*self));
+ if (!self)
+ return NULL;
+
+ ok = wcore_platform_init(&self->wcore);
+ if (!ok)
+ goto error;
+
+ self->wcore.vtbl = &wgl_platform_vtbl;
+ return &self->wcore;
+
+error:
+ wgl_platform_destroy(&self->wcore);
+ return NULL;
+}
+
+static bool
+wgl_make_current(struct wcore_platform *wc_self,
+ struct wcore_display *wc_dpy,
+ struct wcore_window *wc_window,
+ struct wcore_context *wc_ctx)
+{
+ return false;
+}
+
+static void*
+wgl_get_proc_address(struct wcore_platform *wc_self, const char *name)
+{
+ return NULL;
+}
+
+static const struct wcore_platform_vtbl wgl_platform_vtbl = {
+ .destroy = wgl_platform_destroy,
+
+ .make_current = wgl_make_current,
+ .get_proc_address = wgl_get_proc_address,
+ .dl_can_open = wgl_dl_can_open,
+ .dl_sym = wgl_dl_sym,
+
+ .display = {
+ .connect = wgl_display_connect,
+ .destroy = wgl_display_destroy,
+ .supports_context_api = wgl_display_supports_context_api,
+ .get_native = NULL,
+ },
+
+ .config = {
+ .choose = wgl_config_choose,
+ .destroy = wgl_config_destroy,
+ .get_native = NULL,
+ },
+
+ .context = {
+ .create = wgl_context_create,
+ .destroy = wgl_context_destroy,
+ .get_native = NULL,
+ },
+
+ .window = {
+ .create = wgl_window_create,
+ .destroy = wgl_window_destroy,
+ .show = wgl_window_show,
+ .resize = wgl_window_resize,
+ .swap_buffers = wgl_window_swap_buffers,
+ .get_native = NULL,
+ },
+};
diff --git a/src/waffle/wgl/wgl_platform.h b/src/waffle/wgl/wgl_platform.h
new file mode 100644
index 0000000..9aa3611
--- /dev/null
+++ b/src/waffle/wgl/wgl_platform.h
@@ -0,0 +1,49 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#pragma once
+
+#include "wcore_platform.h"
+#include "wcore_util.h"
+
+struct wgl_platform {
+ struct wcore_platform wcore;
+
+ /// @brief The full system version number - (major << 8) | minor.
+ ///
+ /// For example, 0x0501 indicates Windows XP.
+ int32_t system_version_full;
+
+ /// @brief The OpenGL library obtained with LoadLibraryA().
+ void *dl_gl;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(wgl_platform,
+ struct wgl_platform,
+ struct wcore_platform,
+ wcore)
+
+struct wcore_platform*
+wgl_platform_create(void);
diff --git a/src/waffle/wgl/wgl_window.c b/src/waffle/wgl/wgl_window.c
new file mode 100644
index 0000000..922b835
--- /dev/null
+++ b/src/waffle/wgl/wgl_window.c
@@ -0,0 +1,87 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "wcore_error.h"
+
+#include "wgl_config.h"
+#include "wgl_window.h"
+
+bool
+wgl_window_destroy(struct wcore_window *wc_self)
+{
+ struct wgl_window *self = wgl_window(wc_self);
+ bool ok;
+
+ if (!self)
+ return true;
+
+ ok = wcore_window_teardown(wc_self);
+ free(self);
+ return ok;
+}
+
+struct wcore_window*
+wgl_window_create(struct wcore_platform *wc_plat,
+ struct wcore_config *wc_config,
+ int width,
+ int height)
+{
+ struct wgl_window *self;
+ bool ok;
+
+ self = wcore_calloc(sizeof(*self));
+ if (!self)
+ return NULL;
+
+ ok = wcore_window_init(&self->wcore, wc_config);
+ if (!ok)
+ goto error;
+
+ return &self->wcore;
+
+error:
+ wgl_window_destroy(&self->wcore);
+ return NULL;
+}
+
+bool
+wgl_window_show(struct wcore_window *wc_self)
+{
+ return false;
+}
+
+bool
+wgl_window_resize(struct wcore_window *wc_self,
+ int32_t width, int32_t height)
+{
+ return false;
+}
+
+bool
+wgl_window_swap_buffers(struct wcore_window *wc_self)
+{
+ return false;
+
+}
diff --git a/src/waffle/wgl/wgl_window.h b/src/waffle/wgl/wgl_window.h
new file mode 100644
index 0000000..ff1dbf3
--- /dev/null
+++ b/src/waffle/wgl/wgl_window.h
@@ -0,0 +1,63 @@
+// Copyright 2014 Emil Velikov
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#pragma once
+
+#include <stdbool.h>
+
+#include "wcore_util.h"
+#include "wcore_window.h"
+
+struct wcore_platform;
+
+struct wgl_window {
+ struct wcore_window wcore;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(wgl_window,
+ struct wgl_window,
+ struct wcore_window,
+ wcore)
+struct wcore_window*
+wgl_window_create(struct wcore_platform *wc_plat,
+ struct wcore_config *wc_config,
+ int width,
+ int height);
+
+bool
+wgl_window_destroy(struct wcore_window *wc_self);
+
+bool
+wgl_window_show(struct wcore_window *wc_self);
+
+bool
+wgl_window_resize(struct wcore_window *wc_self,
+ int32_t width, int32_t height);
+
+bool
+wgl_window_swap_buffers(struct wcore_window *wc_self);
+
+union waffle_native_window*
+wgl_window_get_native(struct wcore_window *wc_self);
--
2.0.2
More information about the waffle
mailing list