Commit 41da573a authored by Jerry's avatar Jerry
Browse files

added mouse courser

parent ccb41e5d
......@@ -22,9 +22,12 @@ struct NVGLUframebuffer;
namespace gdw {
class ui_system : public ui_widget{
private:
static std::function<void(NVGcontext *context)> default_mouse_render;
NVGcontext *NVGContext_;
NVGLUframebuffer *NVGFrameBuffer_;
engine &engine_;
std::function<void(NVGcontext *context)> mouse_render_;
bool use_mouse_render;
public:
ui_system(engine& engine);
ui_system(ui_system& engine) = delete;
......@@ -38,6 +41,10 @@ namespace gdw {
std::unique_ptr<nanovg_texture> makeTexture(std::string assetname);
void loadFont(std::string assetname);
void mouse_render(std::function<void(NVGcontext *context)> render){
mouse_render_ = render;
}
private:
void renderChilds(ui_widget *widget, float delta_time);
......
......@@ -23,7 +23,19 @@
namespace gdw {
ui_system::ui_system(engine &engine):ui_widget(0,0,0,0),NVGContext_(nullptr),NVGFrameBuffer_(nullptr),engine_(engine) {
std::function<void(NVGcontext *context)> ui_system::default_mouse_render = [](NVGcontext *context){
nvgBeginPath(context);
nvgStrokeColor(context,nvgRGBA(0,81,150,128));
nvgStrokeWidth(context,20.f);
nvgCircle(context,0,0,30);
nvgStroke(context);
nvgClosePath(context);
};
ui_system::ui_system(engine &engine):ui_widget(0,0,0,0),NVGContext_(nullptr)
,NVGFrameBuffer_(nullptr),engine_(engine)
,mouse_render_(default_mouse_render),use_mouse_render(true) {
NVGContext_ = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
if (!NVGContext_) {
log(log_level::error) << "Could not init nanovg." << std::endl;
......@@ -62,6 +74,12 @@ namespace gdw {
}
if(use_mouse_render && mouse_render_){
nvgResetTransform(NVGContext_);
nvgTranslate(NVGContext_,mousex,mousey);
mouse_render_(NVGContext_);
}
//nvgRestore(NVGContext_);
nvgEndFrame(NVGContext_);
glDisable(GL_BLEND);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment