X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glws.hpp;h=9afebf4b878a4b639863bb08d8bf12927fbd0495;hb=452d3256a3ba7f249222ef857d69c8caaaa753f3;hp=23de839da1260681e8fa42c7ed563291327065cc;hpb=7497c130f98f33f41437678835f4b2eb2abce750;p=apitrace diff --git a/glws.hpp b/glws.hpp index 23de839..9afebf4 100644 --- a/glws.hpp +++ b/glws.hpp @@ -31,9 +31,57 @@ #define _GLWS_HPP_ +#include + + namespace glws { +enum Profile { + PROFILE_COMPAT = 0, + PROFILE_CORE, + PROFILE_ES1, + PROFILE_ES2, + PROFILE_MAX +}; + + +extern bool debug; + + +bool +checkExtension(const char *extName, const char *extString); + + +template< class T > +class Attributes { +protected: + std::vector attribs; + +public: + void add(T param) { + attribs.push_back(param); + } + + void add(T pname, T pvalue) { + add(pname); + add(pvalue); + } + + void end(T terminator = 0) { + add(terminator); + } + + operator T * (void) { + return &attribs[0]; + } + + operator const T * (void) const { + return &attribs[0]; + } +}; + + class Visual { public: @@ -53,11 +101,13 @@ public: const Visual *visual; int width; int height; + bool visible; Drawable(const Visual *vis, int w, int h) : visual(vis), width(w), - height(h) + height(h), + visible(false) {} virtual ~Drawable() {} @@ -68,6 +118,11 @@ public: height = h; } + virtual void + show(void) { + visible = true; + } + virtual void swapBuffers(void) = 0; }; @@ -76,38 +131,37 @@ class Context { public: const Visual *visual; + Profile profile; - Context(const Visual *vis) : - visual(vis) + Context(const Visual *vis, Profile prof) : + visual(vis), + profile(prof) {} virtual ~Context() {} }; -class WindowSystem -{ -public: - virtual ~WindowSystem() {} +void +init(void); - virtual Visual * - createVisual(bool doubleBuffer = false) = 0; - - virtual Drawable * - createDrawable(const Visual *visual, int width = 256, int height = 256) = 0; +void +cleanup(void); - virtual Context * - createContext(const Visual *visual) = 0; - - virtual bool - makeCurrent(Drawable *drawable, Context *context) = 0; +Visual * +createVisual(bool doubleBuffer = false, Profile profile = PROFILE_COMPAT); - virtual bool - processEvents(void) = 0; -}; +Drawable * +createDrawable(const Visual *visual, int width = 32, int height = 32); + +Context * +createContext(const Visual *visual, Context *shareContext = 0, Profile profile = PROFILE_COMPAT); +bool +makeCurrent(Drawable *drawable, Context *context); -WindowSystem *createNativeWindowSystem(void); +bool +processEvents(void); } /* namespace glws */