summaryrefslogtreecommitdiff
path: root/tools/gfx/window.h
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-08-10 22:21:44 -0700
committerGitHub <noreply@github.com>2018-08-10 22:21:44 -0700
commit56d8a752d84e984afab20de5980edf10fe6c06f5 (patch)
treeeb1491b940daebc6afd200202347191d77f76112 /tools/gfx/window.h
parent73ff6907d723003d30e400f661876e7960de574f (diff)
Improve model-viewer support for lights (#626)
* Improve model-viewer support for lights The main visible change here is that the model-viewer example supports multiple light sources, with a basic UI for adding new light sources to the scene, and for manipulating the ones that are there. Along the way I also refactored the `IMaterial` decomposition to be a bit less naive, while still only including a completely naive Blinn-Phong implementation. I also went ahead and spruced up the `cube.obj` file so that it has multiple materials, although it is still a completely uninteresting asset. * Fixup: Windows SDK version
Diffstat (limited to 'tools/gfx/window.h')
-rw-r--r--tools/gfx/window.h54
1 files changed, 49 insertions, 5 deletions
diff --git a/tools/gfx/window.h b/tools/gfx/window.h
index 6e557d26c..e154acec3 100644
--- a/tools/gfx/window.h
+++ b/tools/gfx/window.h
@@ -5,18 +5,62 @@
namespace gfx {
-struct WindowDesc
+typedef struct Window Window;
+
+enum class KeyCode
{
- char const* title;
- int width;
- int height;
+ Unknown,
+
+ // TODO: extend this to cover at least a standard US-English keyboard
+
+ A, B, C, D, E, F, G, H, I, J,
+ K, L, M, N, O, P, Q, R, S, T,
+ U, V, W, X, Y, Z,
+
+ Space,
};
-typedef struct Window Window;
+enum class EventCode : uint32_t
+{
+ MouseDown,
+ MouseUp,
+ MouseMoved,
+ KeyDown,
+ KeyUp,
+};
+
+struct Event
+{
+ EventCode code;
+ Window* window;
+ union
+ {
+ struct
+ {
+ float x;
+ float y;
+ } mouse;
+
+ KeyCode key;
+ } u;
+};
+
+typedef void (*EventHandler)(Event const&);
+
+struct WindowDesc
+{
+ char const* title = nullptr;
+ void* userData = nullptr;
+ int width = 0;
+ int height = 0;
+ EventHandler eventHandler = nullptr;
+};
Window* createWindow(WindowDesc const& desc);
void showWindow(Window* window);
+
void* getPlatformWindowHandle(Window* window);
+void* getUserData(Window* window);
/// Opaque state provided by platform for a running application.
typedef struct ApplicationContext ApplicationContext;