File: render.h

package info (click to toggle)
gnubg 0.90-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 30,800 kB
  • ctags: 8,224
  • sloc: ansic: 92,884; xml: 13,338; sh: 9,675; makefile: 425; python: 392; yacc: 295; sql: 237; lex: 220; php: 102; cs: 81; awk: 25; sed: 16
file content (198 lines) | stat: -rw-r--r-- 8,251 bytes parent folder | download
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
 * render.h
 *
 * by Gary Wong <gtw@gnu.org>, 1997-2002.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 3 or later of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: render.h,v 1.32 2008/03/08 09:17:40 Superfly_Jon Exp $
 */

#ifndef _RENDER_H_
#define _RENDER_H_

#include "gnubg-types.h"

#if USE_BOARD3D
#include "types3d.h"
struct _Material
{
	float ambientColour[4];
	float diffuseColour[4];
	float specularColour[4];
	int shine;
	int alphaBlend;
	TextureInfo* textureInfo;
	Texture* pTexture;
};
#endif

typedef enum _woodtype {
    WOOD_ALDER, WOOD_ASH, WOOD_BASSWOOD, WOOD_BEECH, WOOD_CEDAR,
    WOOD_EBONY, WOOD_FIR, WOOD_MAPLE, WOOD_OAK, WOOD_PINE, WOOD_REDWOOD,
    WOOD_WALNUT, WOOD_WILLOW, WOOD_PAINT
} woodtype;

typedef struct _renderdata {
    woodtype wt;
    double aarColour[ 2 ][ 4 ]; /* RGBA for each player */
    double aarDiceColour[ 2 ][ 4 ]; /* RGB(A) of dice for each player */
    int afDieColour[ 2 ]; /* TRUE means same colour as chequers */
    double aarDiceDotColour[ 2 ][ 4 ]; /* RGB(A) of dice dot for each player */
    double arCubeColour[ 4 ]; /* RGB(A) of cube */
    unsigned char aanBoardColour[ 4 ][ 4 ]; /* RGB(A) backgr., border, pts */
    int aSpeckle[ 4 ]; /* speckle for background, border, pts */
    float arRefraction[ 2 ], arCoefficient[ 2 ],
	arExponent[ 2 ]; /* Phong parameters for chequers */
    float arDiceCoefficient[ 2 ], arDiceExponent[ 2 ]; /* Phong parameters */
    float arLight[ 3 ]; /* XYZ light vector */
    float rRound; /* shape of chequers */
    unsigned int nSize; /* basic unit of board size, in pixels -- a chequer's
		  diameter is 6 of these units (and is 2 units thick).
		  The board is 108x82(old:72) units, the dice 7x7 and cube 8x8. */
    int fHinges; /* TRUE if hinges should be drawn */
    int fLabels; /* TRUE if point numbers should be drawn */
    int fClockwise; /* orientation for board point numbers */
    int fShowIDs; /* Position + match ids */
    int fDiceArea; /* Show dice below board */
    int fShowGameInfo;
    int fDynamicLabels; /* TRUE if the point numbers are dynamic, i.e.,
                           they adjust depending on the player on roll */
	int showMoveIndicator;
#if USE_BOARD3D
	displaytype fDisplayType;	/* 2d or 3d display */
	int fHinges3d; /* TRUE if hinges should be drawn */
	int showShadows;	/* Show 3d shadows */
	int shadowDarkness;	/* How dark are shadows */
	float dimness;	/* Darnkess as percentage of ambient light */

	int animateRoll;	/* Animate dice rolls */
	int animateFlag;	/* Animate resignation flag */
	int closeBoardOnExit;	/* Animate board close on quit */
	int quickDraw;	/* Cut down 3d drawing to improve performance */
	unsigned int curveAccuracy;	/* Round curve approximation accuracy */
	lighttype lightType;	/* Positional/Directional light source */
	float lightPos[3];	/* x,y,z pos of light source */
	int lightLevels[3];	/* amibient/diffuse/specular light levels */
	int boardAngle;	/* Angle board is tilted at */
	int skewFactor;	/* FOV adjustment */
	int planView;	/* Ortho view? */
	float diceSize;	/* How big are the dice */
	int roundedEdges;	/* Rounded board edges? */
	int bgInTrays;	/* Rounded board edges? */
	int roundedPoints;	/* Rounded points */
	PieceType pieceType;	/* Different piece models */
	PieceTextureType pieceTextureType;	/* Different piece texture types */
	int afDieColour3d[ 2 ]; /* TRUE means same colour as chequers */
	int acrossCheq, downCheq; /* Split main board up to improve rendering */

	Material ChequerMat[2];	/* Chequer colours */
	Material DiceMat[2], DiceDotMat[2];
	Material CubeMat, CubeNumberMat;
	Material BaseMat, PointMat[2];
	Material BoxMat, HingeMat;
	Material PointNumberMat;
	Material BackGroundMat;
#endif
} renderdata;

typedef struct _renderimages {
    unsigned char *ach, *achChequer[ 2 ], *achChequerLabels, *achDice[ 2 ],
	*achPip[ 2 ], *achCube, *achCubeFaces;
    unsigned char *achResign;
    unsigned char *achResignFaces;
    unsigned short *asRefract[ 2 ];
    unsigned char *auchArrow[ 2 ];
    unsigned char *achLabels[ 2 ];
} renderimages;

extern void RenderInitialise( void );
extern void RenderFinalise( void );

extern int PreferenceCompare(renderdata *prd1, renderdata *prd2);

extern void CopyArea( unsigned char *puchDest, int nDestStride,
		      unsigned char *puchSrc, int nSrcStride,
		      int cx, int cy );
extern void CopyAreaRotateClip( unsigned char *puchDest, int nDestStride,
				int xDest, int yDest, int cxDest, int cyDest,
				unsigned char *puchSrc, int nSrcStride,
				int xSrc, int ySrc, int cx, int cy,
				int nTheta );
/* Changed from AlphaBlend as name clashes in windows */
extern void AlphaBlendBase( unsigned char *puchDest, int nDestStride,
			unsigned char *puchBack, int nBackStride,
			unsigned char *puchFore, int nForeStride,
			int cx, int cy );
extern void AlphaBlendClip( unsigned char *puchDest, int nDestStride,
			    int xDest, int yDest, int cxDest, int cyDest,
			    unsigned char *puchBack, int nBackStride,
			    int xBack, int yBack,
			    unsigned char *puchFore, int nForeStride,
			    int xFore, int yFore, int cx, int cy );
extern void RefractBlend( unsigned char *puchDest, int nDestStride,
			  unsigned char *puchBack, int nBackStride,
			  unsigned char *puchFore, int nForeStride,
			  unsigned short *psRefract, int nRefractStride,
			  int cx, int cy );
extern void RefractBlendClip( unsigned char *puchDest, int nDestStride,
			      int xDest, int yDest, int cxDest, int cyDest,
			      unsigned char *puchBack, int nBackStride,
			      int xBack, int yBack,
			      unsigned char *puchFore, int nForeStride,
			      int xFore, int yFore,
			      unsigned short *psRefract, int nRefractStride,
			      int cx, int cy );
extern void AlphaBlendClip2( unsigned char *puchDest, int nDestStride,
			     int xDest, int yDest, int cxDest, int cyDest,
			     unsigned char *puchBack, int nBackStride,
			     int xBack, int yBack,
			     unsigned char *puchFore, int nForeStride,
			     int xFore, int yFore, int cx, int cy );
extern void RenderBoard( renderdata *prd, unsigned char *puch, int nStride );
extern void RenderChequers( renderdata *prd, unsigned char *puch0,
			    unsigned char *puch1, unsigned short *psRefract0,
			    unsigned short *psRefract1, int nStride );
extern void RenderChequerLabels( renderdata *prd, unsigned char *puch,
				 int nStride );
extern void RenderCube( renderdata *prd, unsigned char *puch, int nStride );
extern void RenderCubeFaces( renderdata *prd, unsigned char *puch,
			     int nStride, unsigned char *puchCube,
			     int nStrideCube );
extern void RenderDice( renderdata *prd, unsigned char *puch0,
			unsigned char *puch1, int nStride );
extern void RenderPips( renderdata *prd, unsigned char *puch0,
			unsigned char *puch1, int nStride );
extern void RenderImages( renderdata *prd, renderimages *pri );
extern void RenderArrows( renderdata *prd, unsigned char* puch0,
			  unsigned char* puch1, int nStride, int fClockwise );
extern void
RenderBoardLabels( renderdata *prd, 
                   unsigned char *achLo, unsigned char *achHi, int nStride );

extern void FreeImages( renderimages *pri );
    
extern void CalculateArea( renderdata *prd, unsigned char *puch, int nStride,
			   renderimages *pri, TanBoard anBoard,
			   int anOff[ 2 ], int anDice[ 2 ],
			   int anDicePosition[ 2 ][ 2 ],
			   int fDiceColour, int anCubePosition[ 2 ],
			   int nLogCube, int nCubeOrientation,
                           int anResignPosition[ 2 ],
                           int fResign, int fResignOrientation,
                           int anArrowPosition[ 2 ],
			   int fPlaying, int nPlayer,
			   int x, int y, int cx, int cy );

#endif