]> git.tdb.fi Git - gldbg.git/blob - source/glwrap.funcs.t
Send as much of a packet as possible before calling the original function
[gldbg.git] / source / glwrap.funcs.t
1 # $Id$
2 !handcode glBegin
3 !handcode glEnd
4 !handcode glGetError
5 !handcode glXGetProcAddress
6 !handcode glXGetProcAddressARB
7 wl('%s APIENTRY %s(%s)', ret.ctype, func.name, ", ".join([p.ctype+" "+p.name for p in params]))
8 wl('{')
9 wl('    static %s (*orig)(%s);', ret.ctype, ", ".join([p.ctype for p in params]))
10 if ret.ctype!='void':
11         wl('    %s ret;', ret.ctype)
12 wl('    if(!orig)')
13 wl('            orig = glsym("%s");', func.name)
14 wl('    begin_packet(FUNC_%s);', func.name.upper())
15 head_sent = False
16 for p in params:
17         if p.direction=="out" and not head_sent:
18                 wl('    send_partial_packet();')
19                 w('     ')
20                 if ret.ctype!='void':
21                         w('ret = ')
22                 wl('orig(%s);', ", ".join([q.name for q in params]))
23                 head_sent = True
24         if p.kind=="value":
25                 wl('    write_%s(%s);', p.io[0].replace(' ', '_'), p.name)
26         elif p.kind=="array" and p.io and p.io[0]=="string":
27                 wl('    write_string_array(%s, %s);', p.name, p.csize)
28         elif p.csize:
29                 wl('    write_data(%s, %s);', p.name, p.csize)
30         else:
31                 wl('    write_pointer(%s);', p.name)
32 if ret.ctype!='void':
33         if not head_sent:
34                 wl('    send_partial_packet();')
35                 wl('    ret = orig(%s);', ", ".join([p.name for p in params]))
36                 head_sent = True
37         wl('    write_%s(ret);', ret.io[0].replace(' ', '_'))
38 wl('    send_packet();')
39 if not head_sent:
40         wl('    orig(%s);', ", ".join([p.name for p in params]))
41 if not func.name.startswith("glX"):
42         wl('    check_error();')
43 if ret.ctype!='void':
44         wl('    return ret;')
45 wl('}')