Graphics Animations & Renaming
This commit is contained in:
parent
1e2ca13a15
commit
41f7d978a9
15 changed files with 718 additions and 318 deletions
59
Graphics/private/bindings/Canvas.cpp
Normal file
59
Graphics/private/bindings/Canvas.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#include "Window.hpp"
|
||||
|
||||
// -------- OpenGL -------- //
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "WindowContext.hpp"
|
||||
|
||||
// -------- Canvas -------- //
|
||||
#define NANOVG_GL3_IMPLEMENTATION
|
||||
#include <nanovg.h>
|
||||
#include <nanovg_gl.h>
|
||||
|
||||
namespace tp {
|
||||
class Graphics::Canvas::Context {
|
||||
public:
|
||||
NVGcontext* vg;
|
||||
};
|
||||
}
|
||||
|
||||
using namespace tp;
|
||||
|
||||
Graphics::Canvas::Canvas() {
|
||||
mContext = new Context();
|
||||
}
|
||||
|
||||
Graphics::Canvas::~Canvas() {
|
||||
delete mContext;
|
||||
}
|
||||
|
||||
void Graphics::Canvas::init() {
|
||||
mContext->vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
|
||||
}
|
||||
|
||||
void Graphics::Canvas::deinit() {
|
||||
// Cleanup
|
||||
nvgDeleteGL3(mContext->vg);
|
||||
}
|
||||
|
||||
void Graphics::Canvas::proc() {
|
||||
auto width = 600;
|
||||
auto height = 600;
|
||||
|
||||
// Start NanoVG rendering
|
||||
nvgBeginFrame(mContext->vg, width, height, 1.0);
|
||||
|
||||
// Draw a rectangle
|
||||
nvgBeginPath(mContext->vg);
|
||||
nvgRect(mContext->vg, 50, 50, 50, 50);
|
||||
nvgFillColor(mContext->vg, nvgRGBf(0.8f, 0.4f, 0.1f));
|
||||
nvgFill(mContext->vg);
|
||||
|
||||
// End NanoVG rendering
|
||||
nvgEndFrame(mContext->vg);
|
||||
}
|
||||
|
||||
void Graphics::Canvas::draw() {
|
||||
// End NanoVG rendering
|
||||
nvgEndFrame(mContext->vg);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue