summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.h4
-rw-r--r--src/example/03_texture/03_texture.c8
-rw-r--r--src/example/example.h17
-rw-r--r--src/extern/wog.c2
-rw-r--r--src/extern/wog.h7
-rw-r--r--src/main.c61
-rw-r--r--src/window.h8
7 files changed, 52 insertions, 55 deletions
diff --git a/src/config.h b/src/config.h
index 43c45af..9173688 100644
--- a/src/config.h
+++ b/src/config.h
@@ -1,8 +1,10 @@
#ifndef _SOFTSHADEROOM_CONFIG_H_
#define _SOFTSHADEROOM_CONFIG_H_
+// ±àÒë¿ØÖÆ
+
#define WIN32 1
-#define PLATFORM WIN32
+#define PLATFORM WIN32
#endif \ No newline at end of file
diff --git a/src/example/03_texture/03_texture.c b/src/example/03_texture/03_texture.c
index b390825..bb9a5ba 100644
--- a/src/example/03_texture/03_texture.c
+++ b/src/example/03_texture/03_texture.c
@@ -40,7 +40,7 @@ static Mesh* yingham_mesh;
static Texture* cyborg_albedo;
static Mesh* cyborg_mesh;
-void onload_texture(void* data) {
+EXAMPLE void onload_texture(void* data) {
CameraConfig* conf = (CameraConfig*)data;
mech_albedo = texture_loadfromfile("res/dieselpunk/mech_basecolor.tga");
@@ -57,11 +57,11 @@ void onload_texture(void* data) {
cyborg_mesh = mesh_loadfromobj("res/cyborg/cyborg.obj");
}
-void onevent_texture(void* data) {
+EXAMPLE void onevent_texture(void* data) {
wog_Event* e = (wog_Event*)data;
}
-void onupdate_texture(void*data) {
+EXAMPLE void onupdate_texture(void*data) {
ssr_matrixmode(MATRIX_MODEL);
ssr_loadidentity();
@@ -74,7 +74,7 @@ void onupdate_texture(void*data) {
ssr_setuniformmat4(0, &world2object);
}
-void ondraw_texture(void*data) {
+EXAMPLE void ondraw_texture(void*data) {
ssr_bindvertices(verts, 8, cube, 12);
ssr_useprogram(&ssr_built_in_shader_pbr);
ssr_enable(ENABLE_BACKFACECULL | ENABLE_DEPTHTEST | ENABLE_WRITEDEPTH | ENABLE_BLEND);
diff --git a/src/example/example.h b/src/example/example.h
index 8e2874d..f99bdc5 100644
--- a/src/example/example.h
+++ b/src/example/example.h
@@ -6,20 +6,7 @@
#include "../extend/camera.h"
#include "../gizmo/gizmo.h"
-#define EXAMPLE(i)\
-extern void onload_##i(void*);\
-extern void onevent_##i(void*);\
-extern void onupdate_##i(void*);\
-extern void ondraw_##i(void*);
-
-#define CURRENT_EXAMPLE texture
-
-/*All examples*/
-
-EXAMPLE(cube);
-EXAMPLE(line);
-EXAMPLE(dot);
-EXAMPLE(texture);
-EXAMPLE(bloom);
+//https://social.msdn.microsoft.com/Forums/vstudio/en-US/65fd5b73-0fb4-40e0-81ec-92d67f9f48ad/how-to-get-function-address-from-current-process?forum=vcgeneral
+#define EXAMPLE __declspec(dllexport)
#endif \ No newline at end of file
diff --git a/src/extern/wog.c b/src/extern/wog.c
index 0578439..ad8f334 100644
--- a/src/extern/wog.c
+++ b/src/extern/wog.c
@@ -620,7 +620,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
int status = console_main(argc, argv);
- return 0;
+ return status;
}
diff --git a/src/extern/wog.h b/src/extern/wog.h
index 35bd51d..6c5bc08 100644
--- a/src/extern/wog.h
+++ b/src/extern/wog.h
@@ -1,8 +1,5 @@
-/**
-* Copyright (c) 2015~2017 chai
-*
-* This library is free software; you can redistribute it and/or modify it
-* under the terms of the MIT license. See LICENSE for details.
+/*
+* Copyright (c) 2015~2020 chai
*/
#ifndef _WOG_H
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 */
diff --git a/src/window.h b/src/window.h
deleted file mode 100644
index 8983a89..0000000
--- a/src/window.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _SOFTSHADEROOM_WINDOW_H_
-#define _SOFTSHADEROOM_WINDOW_H_
-
-typedef struct {
- const char* code;
-} Event;
-
-#endif \ No newline at end of file