Graphics Animations & Renaming
This commit is contained in:
parent
1e2ca13a15
commit
41f7d978a9
15 changed files with 718 additions and 318 deletions
53
Graphics/public/Animations.hpp
Normal file
53
Graphics/public/Animations.hpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#pragma once
|
||||
|
||||
#include "GraphicsCommon.hpp"
|
||||
|
||||
namespace tp {
|
||||
|
||||
class AnimValue {
|
||||
halnf mValPrev = 0;
|
||||
halnf mVal = 0;
|
||||
time_ms mTimeStart = 0;
|
||||
halni mTimeAnim = 250;
|
||||
|
||||
static bool gInTransition;
|
||||
|
||||
private:
|
||||
[[nodiscard]] halnf interpolate() const;
|
||||
|
||||
public:
|
||||
AnimValue();
|
||||
explicit AnimValue(halnf val);
|
||||
|
||||
[[nodiscard]] halnf prev() const { return mValPrev; }
|
||||
void set(halnf val);
|
||||
void setNoTransition(halnf);
|
||||
void setAnimTime(halni time);
|
||||
[[nodiscard]] halnf get() const;
|
||||
[[nodiscard]] halnf getTarget() const;
|
||||
[[nodiscard]] bool inTransition() const;
|
||||
explicit operator halnf() const;
|
||||
void operator=(halnf val);
|
||||
};
|
||||
|
||||
class AnimRect : Rect<AnimValue> {
|
||||
public:
|
||||
AnimRect() {
|
||||
set({ 0, 0, 0, 0 });
|
||||
setAnimTime(450);
|
||||
}
|
||||
|
||||
[[nodiscard]] RectF get() const;
|
||||
[[nodiscard]] RectF getTarget() const;
|
||||
void setNoTransition(RectF);
|
||||
void set(const RectF&);
|
||||
void setAnimTime(halni time_ms);
|
||||
};
|
||||
|
||||
class AnimColor {
|
||||
AnimRect mColor;
|
||||
public:
|
||||
[[nodiscard]] RGBA get() const;
|
||||
void set(const RGBA&);
|
||||
};
|
||||
};
|
||||
|
|
@ -1,77 +1,76 @@
|
|||
#include "Strings.hpp"
|
||||
#pragma once
|
||||
|
||||
#include "GraphicsCommon.hpp"
|
||||
|
||||
namespace tp {
|
||||
|
||||
class ShowoffGlContext;
|
||||
class ShowoffGUIContext;
|
||||
class ShowoffCanvasContext;
|
||||
|
||||
class Window;
|
||||
class WindowContext;
|
||||
|
||||
class Showoff {
|
||||
class Graphics {
|
||||
public:
|
||||
class GL {
|
||||
ShowoffGlContext* mContext;
|
||||
public:
|
||||
class Context;
|
||||
Context* mContext;
|
||||
private:
|
||||
friend Graphics;
|
||||
|
||||
GL();
|
||||
~GL();
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
static void beginDraw();
|
||||
static void endDraw();
|
||||
static void proc();
|
||||
static void draw();
|
||||
public:
|
||||
// TODO : API
|
||||
};
|
||||
|
||||
class GUI {
|
||||
ShowoffGUIContext* mContext;
|
||||
public:
|
||||
class Context;
|
||||
Context* mContext;
|
||||
private:
|
||||
friend Graphics;
|
||||
|
||||
GUI();
|
||||
~GUI();
|
||||
|
||||
void init(Window* window);
|
||||
void deinit();
|
||||
void beginDraw();
|
||||
void endDraw();
|
||||
void proc();
|
||||
void draw();
|
||||
|
||||
public:
|
||||
// TODO : API
|
||||
};
|
||||
|
||||
class Canvas {
|
||||
ShowoffCanvasContext* mContext;
|
||||
public:
|
||||
class Context;
|
||||
Context* mContext;
|
||||
private:
|
||||
friend Graphics;
|
||||
|
||||
Canvas();
|
||||
~Canvas();
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
void beginDraw();
|
||||
void endDraw();
|
||||
void proc();
|
||||
void draw();
|
||||
|
||||
public:
|
||||
// TODO : API
|
||||
};
|
||||
|
||||
public:
|
||||
Showoff() = default;
|
||||
private:
|
||||
friend Window;
|
||||
|
||||
Graphics() = default;
|
||||
void init(Window* window);
|
||||
void deinit();
|
||||
void draw();
|
||||
|
||||
private:
|
||||
GUI gui;
|
||||
GL gl;
|
||||
Canvas canvas;
|
||||
};
|
||||
|
||||
class Window {
|
||||
Window(int width, int height, const char* title);
|
||||
~Window();
|
||||
|
||||
public:
|
||||
static Window* createWindow(int width, int height, const char* title);
|
||||
static void destroyWindow(Window* window);
|
||||
|
||||
public:
|
||||
void renderLoop();
|
||||
WindowContext* getContext();
|
||||
private:
|
||||
WindowContext* mContext;
|
||||
Showoff showoff;
|
||||
GUI mGui;
|
||||
GL mGl;
|
||||
Canvas mCanvas;
|
||||
};
|
||||
}
|
||||
10
Graphics/public/GraphicsCommon.hpp
Normal file
10
Graphics/public/GraphicsCommon.hpp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "Strings.hpp"
|
||||
#include "Rect.hpp"
|
||||
#include "Color.hpp"
|
||||
#include "Timing.hpp"
|
||||
|
||||
namespace tp {
|
||||
extern ModuleManifest gModuleGraphics;
|
||||
}
|
||||
166
Graphics/public/Keycodes.hpp
Normal file
166
Graphics/public/Keycodes.hpp
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace tp {
|
||||
|
||||
// basically copy of glfw keys
|
||||
enum class Keycode {
|
||||
|
||||
/* Printable keys */
|
||||
SPACE = 32,
|
||||
APOSTROPHE = 39, /* ' */
|
||||
COMMA = 44, /* , */
|
||||
MINUS = 45, /* - */
|
||||
PERIOD = 46, /* . */
|
||||
SLASH = 0xBF, /* \ */
|
||||
N0 = 48,
|
||||
N1 = 49,
|
||||
N2 = 50,
|
||||
N3 = 51,
|
||||
N4 = 52,
|
||||
N5 = 53,
|
||||
N6 = 54,
|
||||
N7 = 55,
|
||||
N8 = 56,
|
||||
N9 = 57,
|
||||
SEMICOLON = 59, /* ; */
|
||||
EQUAL = 61, /* = */
|
||||
A = 65,
|
||||
B = 66,
|
||||
C = 67,
|
||||
D = 68,
|
||||
E = 69,
|
||||
F = 70,
|
||||
G = 71,
|
||||
H = 72,
|
||||
I = 73,
|
||||
J = 74,
|
||||
K = 75,
|
||||
L = 76,
|
||||
M = 77,
|
||||
N = 78,
|
||||
O = 79,
|
||||
P = 80,
|
||||
Q = 81,
|
||||
R = 82,
|
||||
S = 83,
|
||||
T = 84,
|
||||
U = 85,
|
||||
V = 86,
|
||||
W = 87,
|
||||
X = 88,
|
||||
Y = 89,
|
||||
Z = 90,
|
||||
LEFT_BRACKET = 91, /* [ */
|
||||
BACKSLASH = 92, /* \ */
|
||||
RIGHT_BRACKET = 93, /* ] */
|
||||
GRAVE_ACCENT = 96, /* ` */
|
||||
WORLD_1 = 161, /* non-US #1 */
|
||||
WORLD_2 = 162, /* non-US #2 */
|
||||
|
||||
/* function keys */
|
||||
|
||||
ESCAPE = 256,
|
||||
ENTER = 257,
|
||||
TAB = 258,
|
||||
BACKSPACE = 259,
|
||||
INSERT = 260,
|
||||
DELETE = 261,
|
||||
RIGHT = 262,
|
||||
LEFT = 263,
|
||||
DOWN = 264,
|
||||
UP = 265,
|
||||
PAGE_UP = 266,
|
||||
PAGE_DOWN = 267,
|
||||
HOME = 268,
|
||||
END = 269,
|
||||
CAPS_LOCK = 280,
|
||||
SCROLL_LOCK = 281,
|
||||
NUM_LOCK = 282,
|
||||
PRINT_SCREEN = 283,
|
||||
PAUSE = 284,
|
||||
F1 = 290,
|
||||
F2 = 291,
|
||||
F3 = 292,
|
||||
F4 = 293,
|
||||
F5 = 294,
|
||||
F6 = 295,
|
||||
F7 = 296,
|
||||
F8 = 297,
|
||||
F9 = 298,
|
||||
F10 = 299,
|
||||
F11 = 300,
|
||||
F12 = 301,
|
||||
F13 = 302,
|
||||
F14 = 303,
|
||||
F15 = 304,
|
||||
F16 = 305,
|
||||
F17 = 306,
|
||||
F18 = 307,
|
||||
F19 = 308,
|
||||
F20 = 309,
|
||||
F21 = 310,
|
||||
F22 = 311,
|
||||
F23 = 312,
|
||||
F24 = 313,
|
||||
F25 = 314,
|
||||
KP_0 = 320,
|
||||
KP_1 = 321,
|
||||
KP_2 = 322,
|
||||
KP_3 = 323,
|
||||
KP_4 = 324,
|
||||
KP_5 = 325,
|
||||
KP_6 = 326,
|
||||
KP_7 = 327,
|
||||
KP_8 = 328,
|
||||
KP_9 = 329,
|
||||
KP_DECIMAL = 330,
|
||||
KP_DIVIDE = 331,
|
||||
KP_MULTIPLY = 332,
|
||||
KP_SUBTRACT = 333,
|
||||
KP_ADD = 334,
|
||||
KP_ENTER = 335,
|
||||
KP_EQUAL = 336,
|
||||
LEFT_SHIFT = 340,
|
||||
LEFT_CONTROL = 341,
|
||||
LEFT_ALT = 342,
|
||||
LEFT_SUPER = 343,
|
||||
RIGHT_SHIFT = 344,
|
||||
RIGHT_CONTROL = 345,
|
||||
RIGHT_ALT = 346,
|
||||
RIGHT_SUPER = 347,
|
||||
MENU = 348,
|
||||
|
||||
INV_SLASH = 0xDC,
|
||||
BRA = 0xDB,
|
||||
KET = 0xDD,
|
||||
TILDA = 0xC0,
|
||||
DOUBLE_DOT = 0xBA,
|
||||
QUOTES = 0xDE,
|
||||
|
||||
MOUSE1 = 501,
|
||||
MOUSE2 = 502,
|
||||
MOUSE3 = 503,
|
||||
MOUSE4 = 504,
|
||||
MOUSE5 = 505,
|
||||
MOUSE_UP = 506,
|
||||
MOUSE_DOWN = 507,
|
||||
};
|
||||
|
||||
enum class KeyState {
|
||||
PRESSED,
|
||||
RELEASED,
|
||||
HOLD,
|
||||
REPEAT,
|
||||
NONE,
|
||||
};
|
||||
|
||||
struct KeyEvent {
|
||||
Keycode code;
|
||||
enum class EventState {
|
||||
RELEASED = 0,
|
||||
PRESSED = 1,
|
||||
REPEAT = 2,
|
||||
} event_state;
|
||||
};
|
||||
};
|
||||
39
Graphics/public/Window.hpp
Normal file
39
Graphics/public/Window.hpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
|
||||
#include "Graphics.hpp"
|
||||
#include "Buffer.hpp"
|
||||
#include "Keycodes.hpp"
|
||||
|
||||
namespace tp {
|
||||
|
||||
class Window {
|
||||
class Context;
|
||||
|
||||
public:
|
||||
struct Event {
|
||||
enum Type {
|
||||
KEY,
|
||||
MOUSE,
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
private:
|
||||
Window(int width, int height, const char* title);
|
||||
~Window();
|
||||
|
||||
public:
|
||||
static Window* createWindow(int width, int height, const char* title);
|
||||
static void destroyWindow(Window* window);
|
||||
|
||||
public:
|
||||
void renderLoop();
|
||||
auto getContext() -> Context*;
|
||||
|
||||
private:
|
||||
Context* mContext;
|
||||
Graphics mGraphics;
|
||||
|
||||
Buffer<Event> mEvents;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue