summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-03-04 21:12:16 +0800
committerchai <chaifix@163.com>2020-03-04 21:12:16 +0800
commit38f0535e00f12ea7da30c39423fc39f6f92cca50 (patch)
tree6bee7806f2f83d2b821cd97031dc37afc554c393 /src/main.c
parentb04283601451185ee8d95b281e7bd53d62fce4d4 (diff)
*misc
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/main.c b/src/main.c
index 4645ad7..0cb5ef1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -9,44 +9,63 @@
#include "extend/camera.h"
#include "extend/scene.h"
+#define SETTING_IMPLEMENT
+#include "settings.h"
+
#define TITLE "Soft Shade Room"
#define SCREEN_WIDTH 600.f
#define SCREEN_HEIGHT 480.f
static char* instruction =
-"/*********************************************/\n"
-"/* SoftShadeRoom */\n"
-"/* chai */\n"
-"/*********************************************/\n"
-"Instructions:\n"
-"RightMouseButton+MouseMove: look around\n"
-"MiddleMouseButton+MouseMove: move around\n"
-"MouseScroll: zoom in\\zoom out\n"
-"Shift+Above Operation: speed up\n"
-"key-g: show\\hide grid\n"
-"----------------------------------------------\n";
+"/***********************************************/\n"
+"/* SoftShadeRoom */\n"
+"/* chai */\n"
+"/***********************************************/\n"
+"Instructions: \n"
+" RightMouseButton+MouseMove look around \n"
+" MiddleMouseButton+MouseMove move around \n"
+" MouseScroll move forward\\backward\n"
+" Shift+Above Operation speed up \n"
+" key-g show\\hide grid \n"
+" key-b bake scene and save to png file(require -b option)\n"
+"Usage: \n"
+" SoftShadeRoom <options> <example> \n"
+"Options: \n"
+" -b <image> set baking target image\n"
+"Examples: \n"
+" \n"
+"-------------------------------------------------\n";
typedef void(*F)(void*);
+// Example entry
F onload;
F onupdate;
F onevent;
F ondraw;
-#define SET_EXAMPLE_FUNC(f, e) \
- f = f##_##e;
-
-#define SET_EXAMPLE(i) \
- SET_EXAMPLE_FUNC(onload, i)\
- SET_EXAMPLE_FUNC(ondraw, i)\
- SET_EXAMPLE_FUNC(onevent, i)\
- SET_EXAMPLE_FUNC(onupdate, i)
+bool setup(const char* name) {
+ HMODULE module = GetModuleHandle(NULL);
+ char func[32] = {0};
+#define _setup(p)\
+ memset(func, 0, sizeof(func)); \
+ sprintf(func, "%s_%s", #p, name); \
+ p = (F)GetProcAddress(module, func);
+ _setup(onload);
+ _setup(onupdate);
+ _setup(onevent);
+ _setup(ondraw);
+#undef _set
+ return onload && onupdate && onevent && ondraw;
+}
int main(int argc, char* argv[]) {
printf(instruction);
-
- SET_EXAMPLE(CURRENT_EXAMPLE);
+ if (!setup("texture")) {
+ printf("no such example");
+ return 0;
+ }
wog_Window* wnd = wog_createWindow(TITLE, SCREEN_WIDTH, SCREEN_HEIGHT, 500, 500, 0);
wog_Surface* surface = wog_getsurface(wnd); // ARGB format
/* init ssr */