X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglwrap.c;h=cd1c328139e784f2a4bea80d90297e86401d4402;hb=a832996c884a0e0acc9a38ba4dd258edb75ec7af;hp=c70b308384b339888dc4ab4527fc7a86df4fa4dc;hpb=ea3d851aa52e999b1c5a5fa52c97ff5019756c0e;p=gldbg.git diff --git a/source/glwrap.c b/source/glwrap.c index c70b308..cd1c328 100644 --- a/source/glwrap.c +++ b/source/glwrap.c @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of gldbg -Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions -Distributed under the GPL -*/ - #include #include #include @@ -12,13 +5,18 @@ Distributed under the GPL #include #include #include +#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) { @@ -146,11 +144,41 @@ static void receive_gldBreak(GlPacket *pkt) 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; @@ -164,6 +192,8 @@ static void receive(void) { 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:; } } @@ -171,15 +201,25 @@ static void receive(void) void tracepoint(unsigned short func, int flag) { + int breakpoint; + + if(no_break) + return; + receive(); - if((breakpoints[func]|break_any)&flag) + breakpoint = (breakpoints[func]|break_any)&flag; + if(breakpoint || hold) { GlPacket *pkt; - pkt = packet_begin(FUNC_GLDBREAK); - packet_write_short(pkt, func); - packet_send(pkt, get_out_fd()); + if(breakpoint) + { + pkt = packet_begin(FUNC_GLDBREAK); + packet_write_short(pkt, func); + packet_write_char(pkt, flag); + packet_send(pkt, get_out_fd()); + } break_any = 0;