Graphics Refactor Initial
This commit is contained in:
parent
e0f92b32dc
commit
e331fc1a34
14 changed files with 378 additions and 555 deletions
|
|
@ -1,119 +1,83 @@
|
|||
#pragma once
|
||||
|
||||
#include "GraphicsCommon.hpp"
|
||||
#include "Color.hpp"
|
||||
#include "Rect.hpp"
|
||||
|
||||
// TODO : ugly
|
||||
#include "Buffer.hpp"
|
||||
|
||||
namespace tp {
|
||||
class Window;
|
||||
|
||||
class Graphics {
|
||||
class DebugGUI {
|
||||
class Context;
|
||||
Context* mContext;
|
||||
|
||||
public:
|
||||
class GL {
|
||||
class Context;
|
||||
Context* mContext;
|
||||
explicit DebugGUI(Window* window);
|
||||
~DebugGUI();
|
||||
|
||||
private:
|
||||
friend Graphics;
|
||||
friend Window;
|
||||
|
||||
GL();
|
||||
~GL();
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
void proc();
|
||||
void draw();
|
||||
|
||||
public:
|
||||
// TODO : API
|
||||
|
||||
private:
|
||||
halnf mWidth = 100;
|
||||
halnf mHeight = 100;
|
||||
};
|
||||
|
||||
class GUI {
|
||||
class Context;
|
||||
Context* mContext;
|
||||
|
||||
private:
|
||||
friend Graphics;
|
||||
|
||||
GUI();
|
||||
~GUI();
|
||||
|
||||
void init(Window* window);
|
||||
void deinit();
|
||||
void proc();
|
||||
void draw();
|
||||
|
||||
public:
|
||||
// TODO : API
|
||||
};
|
||||
|
||||
class Canvas {
|
||||
class Context;
|
||||
Context* mContext;
|
||||
|
||||
private:
|
||||
friend Graphics;
|
||||
friend Window;
|
||||
|
||||
Canvas();
|
||||
~Canvas();
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
void proc();
|
||||
void draw();
|
||||
|
||||
public:
|
||||
enum Align : int2 {
|
||||
CC = 0x0000,
|
||||
CT = 0x0001,
|
||||
CB = 0x0002,
|
||||
LC = 0x0100,
|
||||
LT = 0x0101,
|
||||
LB = 0x0102,
|
||||
RC = 0x0200,
|
||||
RT = 0x0201,
|
||||
RB = 0x0202,
|
||||
};
|
||||
|
||||
struct ImageHandle {
|
||||
ualni id = 0;
|
||||
};
|
||||
|
||||
RectF getAvaliableArea();
|
||||
void pushClamp(const RectF& rec);
|
||||
void popClamp();
|
||||
void rect(const RectF& rec, const RGBA& col, halnf round = 0);
|
||||
void text(const char*, const RectF&, halnf size, Align, halnf marging, const RGBA&);
|
||||
|
||||
ImageHandle createImageFromTextId(ualni id, Vec2F size);
|
||||
void deleteImageHandle(ImageHandle image);
|
||||
void drawImage(const RectF& rec, ImageHandle* image, halnf angle, halnf alpha, halnf rounding);
|
||||
|
||||
private:
|
||||
halnf mWidth = 600;
|
||||
halnf mHeight = 600;
|
||||
Buffer<RectF> mScissors;
|
||||
bool mIsClamping = false;
|
||||
};
|
||||
|
||||
private:
|
||||
friend Window;
|
||||
|
||||
Graphics() = default;
|
||||
void init(Window* window);
|
||||
void deinit();
|
||||
void draw();
|
||||
void proc();
|
||||
void draw();
|
||||
};
|
||||
|
||||
class Canvas {
|
||||
class Context;
|
||||
Context* mContext;
|
||||
|
||||
public:
|
||||
explicit Canvas(Window* window);
|
||||
~Canvas();
|
||||
|
||||
void proc();
|
||||
void draw();
|
||||
|
||||
public:
|
||||
enum Align : int2 {
|
||||
CC = 0x0000,
|
||||
CT = 0x0001,
|
||||
CB = 0x0002,
|
||||
LC = 0x0100,
|
||||
LT = 0x0101,
|
||||
LB = 0x0102,
|
||||
RC = 0x0200,
|
||||
RT = 0x0201,
|
||||
RB = 0x0202,
|
||||
};
|
||||
|
||||
struct ImageHandle {
|
||||
ualni id = 0;
|
||||
};
|
||||
|
||||
void pushClamp(const RectF& rec);
|
||||
void popClamp();
|
||||
void rect(const RectF& rec, const RGBA& col, halnf round = 0);
|
||||
void text(const char*, const RectF&, halnf size, Align, halnf padding, const RGBA&);
|
||||
|
||||
ImageHandle createImageFromTextId(ualni id, Vec2F size);
|
||||
void deleteImageHandle(ImageHandle image);
|
||||
void drawImage(const RectF& rec, ImageHandle* image, halnf angle, halnf alpha, halnf rounding);
|
||||
|
||||
private:
|
||||
Buffer<RectF> mScissors;
|
||||
bool mIsClamping = false;
|
||||
};
|
||||
|
||||
class Graphics {
|
||||
private:
|
||||
explicit Graphics(Window* window) : mGui(window), mCanvas(window) {}
|
||||
|
||||
void proc() {
|
||||
mCanvas.proc();
|
||||
mGui.proc();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
mCanvas.draw();
|
||||
mGui.draw();
|
||||
}
|
||||
|
||||
private:
|
||||
GUI mGui;
|
||||
GL mGl;
|
||||
Canvas mCanvas;
|
||||
DebugGUI mGui;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue