]> git.cworth.org Git - apitrace/blob - glretrace.hpp
Windowing system abstraction (WIP).
[apitrace] / glretrace.hpp
1 /**************************************************************************
2  *
3  * Copyright 2011 Jose Fonseca
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 /*
27  * Abstraction for GL window system specific APIs (GLX, WGL).
28  */
29
30 #ifndef _GLRETRACE_HPP_
31 #define _GLRETRACE_HPP_
32
33
34 namespace glretrace {
35
36
37 struct Visual
38 {
39     unsigned long redMask;
40     unsigned long greenMask;
41     unsigned long blueMask;
42     unsigned long alphaMask;
43     bool doubleBuffer;
44 };
45
46
47 struct Context
48 {
49     const Visual *visual;
50 };
51
52
53 struct Drawable
54 {
55     unsigned width;
56     unsigned height;
57 };
58
59
60 class WindowSystem
61 {
62 public:
63     Drawable *currentDrawable;
64     Context *currentContext;
65
66
67     inline WindowSystem() :
68         currentDrawable(NULL),
69         currentContext(NULL)
70     {}
71
72     virtual ~WindowSystem() {}
73
74     //
75     // Drawables
76     //
77
78     virtual Drawable *
79     createDrawable(unsigned width = 0, unsigned height = 0) = 0;
80
81     virtual void
82     resizeDrawable(Drawable *drawable, unsigned width, unsigned height) = 0;
83
84     virtual Void *
85     destroyDrawable(void) = 0;
86
87     // 
88     // Contexts
89     //
90  
91     virtual Context *
92     createContext(const Visual *visual) = 0;
93
94     virtual void
95     deleteContext(Context *) = 0;
96     
97     virtual bool
98     makeCurrent(Drawable *drawable, Context *context) = 0;
99
100     virtual bool
101     processEvents(void) = 0;
102 };
103
104
105 WindowSystem *createNativeWindowSystem(void);
106
107
108 } /* namespace glretrace */
109
110
111 #endif /* _GLRETRACE_HPP_ */