1 /**************************************************************************
3 * Copyright 2011 Jose Fonseca
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
24 **************************************************************************/
29 #include "retrace.hpp"
31 #include "glstate.hpp"
32 #include "glretrace.hpp"
37 bool insideGlBeginEnd = false;
41 checkGlError(trace::Call &call) {
42 GLenum error = glGetError();
43 if (error == GL_NO_ERROR) {
47 std::ostream & os = retrace::warning(call);
55 os << "GL_INVALID_ENUM";
57 case GL_INVALID_VALUE:
58 os << "GL_INVALID_VALUE";
60 case GL_INVALID_OPERATION:
61 os << "GL_INVALID_OPERATION";
63 case GL_STACK_OVERFLOW:
64 os << "GL_STACK_OVERFLOW";
66 case GL_STACK_UNDERFLOW:
67 os << "GL_STACK_UNDERFLOW";
69 case GL_OUT_OF_MEMORY:
70 os << "GL_OUT_OF_MEMORY";
72 case GL_INVALID_FRAMEBUFFER_OPERATION:
73 os << "GL_INVALID_FRAMEBUFFER_OPERATION";
75 case GL_TABLE_TOO_LARGE:
76 os << "GL_TABLE_TOO_LARGE";
86 void frame_complete(trace::Call &call) {
87 retrace::frameComplete(call);
89 if (!currentDrawable) {
93 if (retrace::debug && !currentDrawable->visible) {
94 retrace::warning(call) << "could not infer drawable size (glViewport never called)\n";
99 } /* namespace glretrace */
103 retrace::setUp(void) {
109 retrace::addCallbacks(retrace::Retracer &retracer)
111 retracer.addCallbacks(glretrace::gl_callbacks);
112 retracer.addCallbacks(glretrace::glx_callbacks);
113 retracer.addCallbacks(glretrace::wgl_callbacks);
114 retracer.addCallbacks(glretrace::cgl_callbacks);
115 retracer.addCallbacks(glretrace::egl_callbacks);
120 retrace::getSnapshot(void) {
121 if (!glretrace::currentDrawable) {
125 return glstate::getDrawBufferImage();
130 retrace::dumpState(std::ostream &os)
132 if (glretrace::insideGlBeginEnd ||
133 !glretrace::currentDrawable ||
134 !glretrace::currentContext) {
138 glstate::dumpCurrentContext(os);
144 retrace::flushRendering(void) {
149 retrace::waitForInput(void) {
150 while (glws::processEvents()) {
155 retrace::cleanUp(void) {