/* $Id$
This file is part of gldbg
-Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions
+Copyright © 2009-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the GPL
*/
#include <dlfcn.h>
#include <fcntl.h>
#include <signal.h>
+#include "arraysize.h"
#include "breakpoint.h"
#include "functions.h"
+#include "opengl.h"
#include "packet.h"
+#define UNUSED __attribute__((unused))
+
static unsigned char breakpoints[N_FUNCS] = { };
static char break_any = 0;
static char hold = 0;
+static char no_break = 0;
static const char *get_lib_names(void)
{
break_any = flags_set;
}
-static void receive_gldHold(GlPacket *pkt __attribute__((unused)))
+static void receive_gldHold(GlPacket *pkt UNUSED)
{
hold = 1;
}
+static void receive_gldQueryViewport(GlPacket *pkt UNUSED)
+{
+ int viewport[4];
+
+ no_break = 1;
+ glGetIntegerv(GL_VIEWPORT, viewport);
+ no_break = 0;
+}
+
+static void receive_gldReadPixels(GlPacket *pkt)
+{
+ GLint x, y;
+ GLsizei width, height;
+ GLenum format, type;
+ char *data;
+
+ packet_read_int(pkt, &x);
+ packet_read_int(pkt, &y);
+ packet_read_int(pkt, &width);
+ packet_read_int(pkt, &height);
+ packet_read_int(pkt, (int *)&format);
+ packet_read_int(pkt, (int *)&type);
+
+ data = (char *)malloc(width*height*typesize(type)*formatsize(format));
+ no_break = 1;
+ glReadPixels(x, y, width, height, format, type, data);
+ no_break = 0;
+ free(data);
+}
+
static void receive(void)
{
GlPacket *pkt;
{
case FUNC_GLDBREAK: receive_gldBreak(pkt); break;
case FUNC_GLDHOLD: receive_gldHold(pkt); break;
+ case FUNC_GLDQUERYVIEWPORT: receive_gldQueryViewport(pkt); break;
+ case FUNC_GLDREADPIXELS: receive_gldReadPixels(pkt); break;
default:;
}
}
{
int breakpoint;
+ if(no_break)
+ return;
+
receive();
breakpoint = (breakpoints[func]|break_any)&flag;