--- /dev/null
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+#ifndef _GLSTATE_HPP_
+#define _GLSTATE_HPP_
+
+
+#include <ostream>
+
+
+namespace glstate {
+
+
+void state_dump(std::ostream &os);
+
+
+} /* namespace glretrace */
+
+
+#endif /* _GLSTATE_HPP_ */
print '#include "glimports.hpp"'
print '#include "glproc.hpp"'
print '#include "glsize.hpp"'
- print '#include "glretrace.hpp"'
+ print '#include "glstate.hpp"'
print
print 'static const char *'
}
}
+
+static bool
+getDrawableBounds(GLint *width, GLint *height) {
+#if defined(_WIN32)
+
+ HDC hDC = wglGetCurrentDC();
+ if (!hDC) {
+ return false;
+ }
+
+ HWND hWnd = WindowFromDC(hDC);
+ RECT rect;
+
+ if (!GetClientRect(hWnd, &rect)) {
+ return false;
+ }
+
+ *width = rect.right - rect.left;
+ *height = rect.bottom - rect.top;
+
+#elif 0 /* __APPLE__ */
+
+ CGLError CGLGetSurface(CGLContextObj, CGSConnectionID*, CGSWindowID*, CGSSurfaceID*);
+ CGError CGSGetWindowBounds(CGSConnectionID, CGWindowID, CGRect *ret);
+
+#else
+
+ Display *display;
+ Drawable drawable;
+ Window root;
+ int x, y;
+ unsigned int w, h, bw, depth;
+
+ display = glXGetCurrentDisplay();
+ if (!display) {
+ return false;
+ }
+
+ drawable = glXGetCurrentDrawable();
+ if (drawable == None) {
+ return false;
+ }
+
+ if (!XGetGeometry(display, drawable, &root, &x, &y, &w, &h, &bw, &depth)) {
+ return false;
+ }
+
+ *width = w;
+ *height = h;
+
+#endif
+
+ return true;
+}
+
+
static inline void
writeDrawBufferImage(JSONWriter &json, GLenum format)
{
GLint channels = __gl_format_channels(format);
- if (!glretrace::drawable) {
+ GLint width, height;
+
+ if (!getDrawableBounds(&width, &height)) {
json.writeNull();
} else {
- GLint width = glretrace::drawable->width;
- GLint height = glretrace::drawable->height;
-
json.beginObject();
// Tell the GUI this is no ordinary object, but an image
GLubyte *pixels = new GLubyte[width*height*channels];
- GLint drawbuffer = glretrace::double_buffer ? GL_BACK : GL_FRONT;
- GLint readbuffer = glretrace::double_buffer ? GL_BACK : GL_FRONT;
+ GLint drawbuffer = GL_NONE;
+ GLint readbuffer = GL_NONE;
glGetIntegerv(GL_DRAW_BUFFER, &drawbuffer);
glGetIntegerv(GL_READ_BUFFER, &readbuffer);
glReadBuffer(drawbuffer);
print '}'
print
- print 'void glretrace::state_dump(std::ostream &os)'
+ print 'void glstate::state_dump(std::ostream &os)'
print '{'
print ' JSONWriter json(os);'
self.dump_parameters()
print ' GLint colorRb, stencilRb, depthRb;'
print ' GLint boundRb;'
print ' glGetIntegerv(GL_RENDERBUFFER_BINDING, &boundRb);'
- print ' GLint drawbuffer = glretrace::double_buffer ? GL_BACK : GL_FRONT;'
+ print ' GLint drawbuffer = GL_NONE;'
print ' glGetIntegerv(GL_DRAW_BUFFER, &drawbuffer);'
print
print ' glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,'