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