summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2019-06-04 19:46:10 +0200
committerGitHub <noreply@github.com>2019-06-04 19:46:10 +0200
commitde7241f95e7146571dd51dacaba5a26103258f54 (patch)
tree6381dc61bd1381ada324e3b440accb53f1fa092d /util
parent144ee31c2eced52f0c1f5e2c17e931d8a45e5483 (diff)
Add SOKOL_DLL support to all headers. (#163)
On Windows, this adds __declspec(dllexport) or __declspec(dllimport) to all function declarations so that the sokol headers can be compiled into a DLL. Fixes #160 .
Diffstat (limited to 'util')
-rw-r--r--util/sokol_cimgui.h14
-rw-r--r--util/sokol_gfx_cimgui.h22
-rw-r--r--util/sokol_gfx_imgui.h14
-rw-r--r--util/sokol_gl.h18
-rw-r--r--util/sokol_imgui.h14
5 files changed, 76 insertions, 6 deletions
diff --git a/util/sokol_cimgui.h b/util/sokol_cimgui.h
index 2cd46b4d..9235971d 100644
--- a/util/sokol_cimgui.h
+++ b/util/sokol_cimgui.h
@@ -29,6 +29,14 @@
SOKOL_API_DECL - public function declaration prefix (default: extern)
SOKOL_API_IMPL - public function implementation prefix (default: -)
+ If sokol_cimgui.h is compiled as a DLL, define the following before
+ including the declaration or implementation:
+
+ SOKOL_DLL
+
+ On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport)
+ or __declspec(dllimport) as needed.
+
Include the following headers before sokol_imgui.h (both before including
the declaration and implementation):
@@ -173,8 +181,14 @@
#endif
#ifndef SOKOL_API_DECL
+#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMPL)
+#define SOKOL_API_DECL __declspec(dllexport)
+#elif defined(_WIN32) && defined(SOKOL_DLL)
+#define SOKOL_API_DECL __declspec(dllimport)
+#else
#define SOKOL_API_DECL extern
#endif
+#endif
typedef struct scimgui_desc_t {
int max_vertices;
diff --git a/util/sokol_gfx_cimgui.h b/util/sokol_gfx_cimgui.h
index b346ad2e..45f3a934 100644
--- a/util/sokol_gfx_cimgui.h
+++ b/util/sokol_gfx_cimgui.h
@@ -27,7 +27,7 @@
...before including the sokol_gfx.h implementation.
- Before including the sokol_gfx_imgui.h implementation, optionally
+ Before including the sokol_gfx_cimgui.h implementation, optionally
override the following macros:
SOKOL_ASSERT(c) -- your own assert macro, default: assert(c)
@@ -38,6 +38,14 @@
SOKOL_API_DECL - public function declaration prefix (default: extern)
SOKOL_API_IMPL - public function implementation prefix (default: -)
+ If sokol_gfx_cimgui.h is compiled as a DLL, define the following before
+ including the declaration or implementation:
+
+ SOKOL_DLL
+
+ On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport)
+ or __declspec(dllimport) as needed.
+
STEP BY STEP:
=============
--- create an sg_cimgui_t struct (which must be preserved between frames)
@@ -148,8 +156,14 @@
#endif
#ifndef SOKOL_API_DECL
+#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMPL)
+#define SOKOL_API_DECL __declspec(dllexport)
+#elif defined(_WIN32) && defined(SOKOL_DLL)
+#define SOKOL_API_DECL __declspec(dllimport)
+#else
#define SOKOL_API_DECL extern
#endif
+#endif
#if defined(__cplusplus)
extern "C" {
@@ -690,7 +704,7 @@ _SOKOL_PRIVATE void _sg_cimgui_snprintf(sg_cimgui_str_t* dst, const char* fmt, .
SOKOL_ASSERT(dst);
va_list args;
va_start(args, fmt);
- vsnprintf(dst->buf, sizeof(dst->buf), fmt, args);
+ vsnprintf(dst->buf, sizeof(dst->buf), fmt, args);
dst->buf[sizeof(dst->buf)-1] = 0;
va_end(args);
}
@@ -1282,7 +1296,7 @@ _SOKOL_PRIVATE sg_cimgui_str_t _sg_cimgui_capture_item_string(sg_cimgui_t* ctx,
_sg_cimgui_feature_string(item->args.query_feature.feature),
_sg_cimgui_bool_string(item->args.query_feature.result));
break;
-
+
case sg_cimgui_CMD_RESET_STATE_CACHE:
_sg_cimgui_snprintf(&str, "%d: sg_reset_state_cache()", index);
break;
@@ -2817,7 +2831,7 @@ _SOKOL_PRIVATE void _sg_cimgui_draw_pipeline_panel(sg_cimgui_t* ctx, sg_pipeline
if (igTreeNodeStr("Vertex Layout")) {
_sg_cimgui_draw_vertex_layout(&pip_ui->desc.layout);
igTreePop();
- }
+ }
if (igTreeNodeStr("Depth Stencil State")) {
_sg_cimgui_draw_depth_stencil_state(&pip_ui->desc.depth_stencil);
igTreePop();
diff --git a/util/sokol_gfx_imgui.h b/util/sokol_gfx_imgui.h
index 9a45b86b..87138e60 100644
--- a/util/sokol_gfx_imgui.h
+++ b/util/sokol_gfx_imgui.h
@@ -40,6 +40,14 @@
SOKOL_API_DECL - public function declaration prefix (default: extern)
SOKOL_API_IMPL - public function implementation prefix (default: -)
+ If sokol_gfx_imgui.h is compiled as a DLL, define the following before
+ including the declaration or implementation:
+
+ SOKOL_DLL
+
+ On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport)
+ or __declspec(dllimport) as needed.
+
STEP BY STEP:
=============
--- create an sg_imgui_t struct (which must be preserved between frames)
@@ -150,8 +158,14 @@
#endif
#ifndef SOKOL_API_DECL
+#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMPL)
+#define SOKOL_API_DECL __declspec(dllexport)
+#elif defined(_WIN32) && defined(SOKOL_DLL)
+#define SOKOL_API_DECL __declspec(dllimport)
+#else
#define SOKOL_API_DECL extern
#endif
+#endif
#if defined(__cplusplus)
extern "C" {
diff --git a/util/sokol_gl.h b/util/sokol_gl.h
index 7a448406..8d36975c 100644
--- a/util/sokol_gl.h
+++ b/util/sokol_gl.h
@@ -29,11 +29,19 @@
SOKOL_LOG(msg) - your own logging function (default: puts(msg))
SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false))
+ If sokol_gl.h is compiled as a DLL, define the following before
+ including the declaration or implementation:
+
+ SOKOL_DLL
+
+ On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport)
+ or __declspec(dllimport) as needed.
+
Include the following headers before including sokol_gl.h:
sokol_gfx.h
- Matrix functions are taken from MESA and Regal.
+ Matrix functions have been taken from MESA and Regal.
FEATURE OVERVIEW:
=================
@@ -416,7 +424,13 @@
#endif
#ifndef SOKOL_API_DECL
- #define SOKOL_API_DECL extern
+#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMPL)
+#define SOKOL_API_DECL __declspec(dllexport)
+#elif defined(_WIN32) && defined(SOKOL_DLL)
+#define SOKOL_API_DECL __declspec(dllimport)
+#else
+#define SOKOL_API_DECL extern
+#endif
#endif
/* sokol_gl pipeline handle (created with sgl_make_pipeline()) */
diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h
index 78fab8af..da3dc21b 100644
--- a/util/sokol_imgui.h
+++ b/util/sokol_imgui.h
@@ -31,6 +31,14 @@
SOKOL_API_DECL - public function declaration prefix (default: extern)
SOKOL_API_IMPL - public function implementation prefix (default: -)
+ If sokol_imgui.h is compiled as a DLL, define the following before
+ including the declaration or implementation:
+
+ SOKOL_DLL
+
+ On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport)
+ or __declspec(dllimport) as needed.
+
Include the following headers before sokol_imgui.h (both before including
the declaration and implementation):
@@ -180,8 +188,14 @@
#endif
#ifndef SOKOL_API_DECL
+#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMPL)
+#define SOKOL_API_DECL __declspec(dllexport)
+#elif defined(_WIN32) && defined(SOKOL_DLL)
+#define SOKOL_API_DECL __declspec(dllimport)
+#else
#define SOKOL_API_DECL extern
#endif
+#endif
#ifdef __cplusplus
extern "C" {