]> git.cworth.org Git - apitrace/blob - retrace/glretrace.hpp
Kill currentDrawable.
[apitrace] / retrace / 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 #ifndef _GLRETRACE_HPP_
27 #define _GLRETRACE_HPP_
28
29 #include "glws.hpp"
30 #include "retrace.hpp"
31
32
33 namespace glretrace {
34
35 struct Context {
36     Context(glws::Context* context)
37         : wsContext(context),
38           drawable(0),
39           activeProgram(0),
40           used(false)
41     {
42     }
43
44     ~Context()
45     {
46         delete wsContext;
47     }
48
49     glws::Context* wsContext;
50
51     // Bound drawable
52     glws::Drawable *drawable;
53
54     GLuint activeProgram;
55     bool used;
56     
57     // Context must be current
58     inline bool
59     hasExtension(const char *extension) const {
60         return wsContext->hasExtension(extension);
61     }
62 };
63
64 extern bool insideList;
65 extern bool insideGlBeginEnd;
66
67
68 extern Context *currentContext;
69
70
71 int
72 parseAttrib(const trace::Value *attribs, int param, int default_);
73
74
75 glws::Drawable *
76 createDrawable(glws::Profile profile);
77
78 glws::Drawable *
79 createDrawable(void);
80
81 Context *
82 createContext(Context *shareContext, glws::Profile profile);
83
84 Context *
85 createContext(Context *shareContext = 0);
86
87 bool
88 makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context);
89
90
91 void
92 checkGlError(trace::Call &call);
93
94 extern const retrace::Entry gl_callbacks[];
95 extern const retrace::Entry cgl_callbacks[];
96 extern const retrace::Entry glx_callbacks[];
97 extern const retrace::Entry wgl_callbacks[];
98 extern const retrace::Entry egl_callbacks[];
99
100 void frame_complete(trace::Call &call);
101 void initContext();
102
103
104 void updateDrawable(int width, int height);
105
106 void flushQueries();
107 void beginProfile(trace::Call &call, bool isDraw);
108 void endProfile(trace::Call &call, bool isDraw);
109
110 } /* namespace glretrace */
111
112
113 #endif /* _GLRETRACE_HPP_ */