diff options
author | José Fonseca <jose.r.fonseca@gmail.com> | 2011-03-30 11:33:52 +0100 |
---|---|---|
committer | José Fonseca <jose.r.fonseca@gmail.com> | 2011-04-02 17:34:07 +0100 |
commit | 2403f685f5787de3c6e51f26fe866158a05e4bd4 (patch) | |
tree | 67707000ead9a86fe42d96c576a1cad3280c37df /glretrace.hpp | |
parent | aa7d6010a663a8f3f443e4e04358b8804ebc0890 (diff) |
Windowing system abstraction (WIP).
Diffstat (limited to 'glretrace.hpp')
-rw-r--r-- | glretrace.hpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/glretrace.hpp b/glretrace.hpp new file mode 100644 index 0000000..a56606c --- /dev/null +++ b/glretrace.hpp @@ -0,0 +1,111 @@ +/************************************************************************** + * + * Copyright 2011 Jose Fonseca + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + +/* + * Abstraction for GL window system specific APIs (GLX, WGL). + */ + +#ifndef _GLRETRACE_HPP_ +#define _GLRETRACE_HPP_ + + +namespace glretrace { + + +struct Visual +{ + unsigned long redMask; + unsigned long greenMask; + unsigned long blueMask; + unsigned long alphaMask; + bool doubleBuffer; +}; + + +struct Context +{ + const Visual *visual; +}; + + +struct Drawable +{ + unsigned width; + unsigned height; +}; + + +class WindowSystem +{ +public: + Drawable *currentDrawable; + Context *currentContext; + + + inline WindowSystem() : + currentDrawable(NULL), + currentContext(NULL) + {} + + virtual ~WindowSystem() {} + + // + // Drawables + // + + virtual Drawable * + createDrawable(unsigned width = 0, unsigned height = 0) = 0; + + virtual void + resizeDrawable(Drawable *drawable, unsigned width, unsigned height) = 0; + + virtual Void * + destroyDrawable(void) = 0; + + // + // Contexts + // + + virtual Context * + createContext(const Visual *visual) = 0; + + virtual void + deleteContext(Context *) = 0; + + virtual bool + makeCurrent(Drawable *drawable, Context *context) = 0; + + virtual bool + processEvents(void) = 0; +}; + + +WindowSystem *createNativeWindowSystem(void); + + +} /* namespace glretrace */ + + +#endif /* _GLRETRACE_HPP_ */ |