summaryrefslogtreecommitdiff
path: root/src/VBox/GuestHost/OpenGL/packer/pack_current.py
blob: 4cd3f00f184bc8f51b28dc2709f23ca56071aa45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.

# This script generates the pack_current.c file.

import sys
sys.path.append( "../glapi_parser" )
import apiutil

from pack_currenttypes import *

apiutil.CopyrightC()

print """
/* DO NOT EDIT - THIS FILE GENERATED BY THE pack_current.py SCRIPT */

#include <memory.h>
#include "packer.h"
#include "state/cr_currentpointers.h"

#include <stdio.h>

void crPackOffsetCurrentPointers( int offset )
{
	CR_GET_PACKER_CONTEXT(pc);
	GLnormal_p		*normal		= &(pc->current.c.normal);
	GLcolor_p		*color		= &(pc->current.c.color);
	GLsecondarycolor_p	*secondaryColor	= &(pc->current.c.secondaryColor);
	GLtexcoord_p	*texCoord	= &(pc->current.c.texCoord);
	GLindex_p		*index		= &(pc->current.c.index);
	GLedgeflag_p	*edgeFlag	= &(pc->current.c.edgeFlag);
	GLvertexattrib_p *vertexAttrib = &(pc->current.c.vertexAttrib);
	GLfogcoord_p    *fogCoord   = &(pc->current.c.fogCoord);
	int i;
"""

for k in current_fns.keys():
	name = '%s%s' % (k[:1].lower(),k[1:])
	if current_fns[k].has_key( 'array' ):
			print '\tfor (i = 0 ; i < %s ; i++)' % current_fns[k]['array']
			print '\t{'
	for type in current_fns[k]['types']:
		for size in current_fns[k]['sizes']:
			indent = ""
			ptr = "%s->%s%d" % (name, type, size )
			if current_fns[k].has_key( 'array' ):
				ptr += "[i]"
				indent = "\t"
			print "%s\tif ( %s )" % (indent, ptr)
			print "%s\t{" % indent
			print "%s\t\t%s += offset;" % (indent, ptr )
			print "%s\t}" % indent
	if current_fns[k].has_key( 'array' ):
		print '\t}'
print """
}

void crPackNullCurrentPointers( void )
{
	CR_GET_PACKER_CONTEXT(pc);
	CRCurrentStateAttr	*c		= &(pc->current.c);
"""
print '\tmemset ( c, 0, sizeof (CRCurrentStateAttr));'
print "}"