#pragma once #include #include #include "lib_begin.h" namespace cgv { namespace render { /** base class for all drawables, which is independent of the used rendering API. */ class CGV_API drawable : public base::traverse_policy { private: /// store the context context* ctx; public: /// default construction drawable(); /// hide the drawable void hide(); /// show the drawable void show(); /// check whether the drawable is visible bool is_visible() const; /// access the current context. The context will be available latestly in the init method but not in the contructor. context* get_context() const; /// set the current focus context, this should only be called by the context itself void set_context(context* _ctx); /// posts a redraw event to the current context if one is available void post_redraw(); /// forces a redraw right now. This cannot be called from init, init_frame, draw, finish_draw, finish_frame and clear void force_redraw(); /// this method is called after creation or recreation of the context, return whether all necessary functionality is supported virtual bool init(context&); /// callback to anounce resizing of the output window virtual void resize(unsigned int w, unsigned int h); /// this method is called in one pass over all drawables before the draw method virtual void init_frame(context&); /// overload to draw the content of this drawable virtual void draw(context&); /// this method is called when the current drawable is left in a tree traversal that calls the draw method virtual void finish_draw(context&); /// this method is called in one pass over all drawables after drawing virtual void finish_frame(context&); /// this method is called in one pass over all drawables after finish frame virtual void after_finish(cgv::render::context&); /// clear all objects living in the context like textures or display lists virtual void clear(context&); }; } } #include