summaryrefslogtreecommitdiff
path: root/src/extern/wog.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-02-22 18:17:06 +0800
committerchai <chaifix@163.com>2020-02-22 18:17:06 +0800
commit9c89460e136ed6c6c43704d9a3a15105e0f006b0 (patch)
treecd56f1dfc10650cfbfe7007ee3432ee32227edc3 /src/extern/wog.h
parentd49f3d3f73709a9a7c0bce53aa13ed28a2bd27cb (diff)
*wog
Diffstat (limited to 'src/extern/wog.h')
-rw-r--r--src/extern/wog.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/extern/wog.h b/src/extern/wog.h
new file mode 100644
index 0000000..f616d82
--- /dev/null
+++ b/src/extern/wog.h
@@ -0,0 +1,140 @@
+/**
+* Copyright (c) 2015~2017 chai(neonum)
+*
+* This library is free software; you can redistribute it and/or modify it
+* under the terms of the MIT license. See LICENSE for details.
+*/
+
+#ifndef _WOG_H
+#define _WOG_H
+#include <Windows.h> // for virtual key value
+
+#define WOG_GL 1
+#define WOG_GDI 2
+
+#define WOG_API WOG_GDI
+
+typedef unsigned int uint32;
+typedef unsigned short uint16;
+
+enum // event type
+{
+ WOG_EUNKNOWN = 0, // unknown event
+
+ WOG_EKEYDOWN, // key pressed
+ WOG_EKEYUP, // key released
+
+ WOG_EMOUSEMOTION, // mouse motion
+ WOG_EMOUSEWHEEL, // mouse wheel scrolling
+ WOG_EMOUSEBUTTONDOWN, // mosue button down
+ WOG_EMOUSEBUTTONUP, // mosue button down
+
+ WOG_ECLOSE, // close window
+};
+
+enum // mouse button event, e.button value
+{
+ WOG_MOUSE_LBUTTON, // left mouse button
+ WOG_MOUSE_RBUTTON, // right mouse button
+ WOG_MOUSE_MIDDLE, // middle button
+};
+
+typedef struct wog_Event
+{
+ int type;
+ union // event value
+ {
+ int key; // for key, simply use windows virtual key value
+ // see https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
+ struct // for mouse motion
+ {
+ int x, y; // mouse position
+ }pos;
+ int wheel; // 1 indicate scroll up and -1 indicate scrool down
+ int button; // mouse button
+ };
+}wog_Event;
+
+typedef struct {
+ int width, height, channels;
+ unsigned char* buffer;
+} wog_Surface;
+
+/**
+* Entry of user program which defined in user project. You need provide
+* this function's defination.
+*/
+#define main wog_main
+extern int wog_main(int argc, char* argv[]);
+
+typedef struct wog_Window wog_Window;
+
+#if WOG_API == WOG_GL
+/**
+* Struct that hold opengl context generated by wglCreateContext() which
+* defined in opengl32.lib
+*/
+typedef struct wog_GLContext wog_GLContext;
+#endif
+
+enum // window style flag
+{
+ WOG_HIDDEN = 4,
+ WOG_RESIZABLE = 8,
+ WOG_DISABLE = 16,
+};
+
+/**
+* Create window with given configures.
+* flag would be:
+* WOG_HIDDEN
+* WOG_RESIZABLE
+* WOG_DISABLE
+* or just 0;
+*/
+wog_Window* wog_createWindow(const char* title, int width, int height, int x, int y, uint32 flags);
+
+#if WOG_API == WOG_GL
+wog_GLContext* wog_createGLContext(wog_Window* wnd);
+
+int wog_makeCurrent(wog_Window* wnd, wog_GLContext* cxt);
+
+void wog_destroyGLContext(wog_GLContext* cxt);
+#endif
+
+void wog_destroyWindow(wog_Window* wnd);
+
+#if WOG_API == WOG_GL
+void wog_swapBuffers(wog_Window* wnd);
+#endif
+
+#if WOG_API == WOG_GDI
+void wog_updateSurface(wog_Window* wnd);
+#endif
+
+int wog_pollEvent(wog_Window* wnd, wog_Event* e);
+
+void wog_getMouse(wog_Window* wnd, int *x, int *y);
+
+// get current ticks
+int wog_tick();
+
+void wog_sleep(int ms);
+
+void wog_getwindowsize(wog_Window* wnd, int* width, int* height);
+
+void wog_show(wog_Window* wnd);
+
+void wog_hide(wog_Window* wnd);
+
+typedef void(*wog_Callback)(wog_Window* wnd) ;
+
+/**
+* Register callback functions.
+*/
+void wog_registerResizeCallback(wog_Callback cal);
+void wog_registerQuitCallback(wog_Callback cal);
+
+wog_Surface* wog_getsurface(wog_Window* wnd);
+
+#endif \ No newline at end of file