X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glws.hpp;h=47fdc7f40729f24e4a7905a2a914b3877ffbe8e3;hb=9b42f061b37a00a0bcd314a830924803a956e17d;hp=7f4b52d9db9526bc9e8d8b78321d86be6751b4a8;hpb=ce6bcdd4395c9efec37a26f6c1caf8944d75f6d0;p=apitrace diff --git a/glws.hpp b/glws.hpp index 7f4b52d..47fdc7f 100644 --- a/glws.hpp +++ b/glws.hpp @@ -31,9 +31,48 @@ #define _GLWS_HPP_ +#include + + namespace glws { +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(void) { + add(0); + } + + operator T * (void) { + return &attribs[0]; + } + + operator const T * (void) const { + return &attribs[0]; + } +}; + + class Visual { public: @@ -51,21 +90,30 @@ class Drawable { public: const Visual *visual; - unsigned width; - unsigned height; - - Drawable(const Visual *vis) : - visual(vis) + int width; + int height; + bool visible; + + Drawable(const Visual *vis, int w, int h) : + visual(vis), + width(w), + height(h), + visible(false) {} virtual ~Drawable() {} virtual void - resize(unsigned w, unsigned h) { + resize(int w, int h) { width = w; height = h; } + virtual void + show(void) { + visible = true; + } + virtual void swapBuffers(void) = 0; }; @@ -83,29 +131,26 @@ public: }; -class WindowSystem -{ -public: - virtual ~WindowSystem() {} +void +init(void); - virtual Visual * - createVisual(bool doubleBuffer = false) = 0; - - virtual Drawable * - createDrawable(const Visual *visual) = 0; +void +cleanup(void); - virtual Context * - createContext(const Visual *visual) = 0; - - virtual bool - makeCurrent(Drawable *drawable, Context *context) = 0; +Visual * +createVisual(bool doubleBuffer = false); - virtual bool - processEvents(void) = 0; -}; +Drawable * +createDrawable(const Visual *visual, int width = 32, int height = 32); + +Context * +createContext(const Visual *visual, Context *shareContext = 0); +bool +makeCurrent(Drawable *drawable, Context *context); -WindowSystem *createNativeWindowSystem(void); +bool +processEvents(void); } /* namespace glws */