TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
grshadow.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 file : grshadow.cpp
4 created : Fri Mar 22 23:16:44 CET 2002
5 copyright : (C) 2001 by Christophe Guionneau
6 version : $Id$
7
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#include <plib/ssg.h>
20#include "grshadow.h"
21
22#ifdef DMALLOC
23#include "dmalloc.h"
24#endif
25
26void ssgVtxTableShadow::copy_from ( ssgVtxTableShadow *src, int clone_flags )
27{
28 ssgVtxTable::copy_from ( src, clone_flags ) ;
29 factor=src->factor;
30 unit=src->unit;
31}
32ssgBase *ssgVtxTableShadow::clone ( int clone_flags )
33{
35 b -> copy_from ( this, clone_flags ) ;
36 return b ;
37}
42
43
44
45ssgVtxTableShadow::ssgVtxTableShadow (float f, float u) : ssgVtxTable(), factor(f), unit(u)
46{
47 /*factor=f;
48 unit=u;
49 ssgVtxTable();*/
50}
51ssgVtxTableShadow::ssgVtxTableShadow ( GLenum ty, ssgVertexArray *vl,
52 ssgNormalArray *nl,
53 ssgTexCoordArray *tl,
54 ssgColourArray *cl ) : ssgVtxTable( ty, vl, nl, tl, cl )
55{
56 type = ssgTypeVtxTable () ;
57 factor=0;
58 unit=0;
59}
60
62{
63 /* ssgDeRefDelete ( vertices ) ;
64 ssgDeRefDelete ( normals ) ;
65 ssgDeRefDelete ( texcoords ) ;
66 ssgDeRefDelete ( colours ) ; */
67}
68
69
70void ssgVtxTableShadow::setOffset(float f, float u)
71{
72 factor=f;
73 unit=f;
74}
75
76
77
79{
80 int num_colours = getNumColours () ;
81 int num_normals = getNumNormals () ;
82 int num_vertices = getNumVertices () ;
83 int num_texcoords = getNumTexCoords () ;
84
85
86 sgVec3 *vx = (sgVec3 *) vertices -> get(0) ;
87 sgVec3 *nm = (sgVec3 *) normals -> get(0) ;
88 sgVec2 *tx = (sgVec2 *) texcoords -> get(0) ;
89 sgVec4 *cl = (sgVec4 *) colours -> get(0) ;
90
91 glDepthMask(GL_FALSE);
92 glPolygonOffset(-15.0f, -20.0f);
93 glEnable(GL_POLYGON_OFFSET_FILL);
94 //glEnable(GL_CULL_FACE);
95
96 glBegin ( gltype ) ;
97
98 if ( num_colours == 0 ) glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ;
99 if ( num_colours == 1 ) glColor4fv ( cl [ 0 ] ) ;
100 if ( num_normals == 1 ) glNormal3fv ( nm [ 0 ] ) ;
101
102 for ( int i = 0 ; i < num_vertices ; i++ )
103 {
104 if ( num_colours > 1 ) glColor4fv ( cl [ i ] ) ;
105 if ( num_normals > 1 ) glNormal3fv ( nm [ i ] ) ;
106 if ( num_texcoords > 1 ) glTexCoord2fv ( tx [ i ] ) ;
107
108 glVertex3fv ( vx [ i ] ) ;
109 }
110
111 glEnd () ;
112 glDisable(GL_POLYGON_OFFSET_FILL);
113 glDepthMask(GL_TRUE);
114}
int getNumColours()
Definition grshadow.h:32
virtual void copy_from(ssgVtxTableShadow *src, int clone_flags)
Definition grshadow.cpp:26
virtual ssgBase * clone(int clone_flags=0)
Definition grshadow.cpp:32
int getNumNormals()
Definition grshadow.h:31
void setOffset(float f, float u)
Definition grshadow.cpp:70
ssgVtxTableShadow(float f, float u)
Definition grshadow.cpp:45
int getNumVertices()
Definition grshadow.h:30
virtual ~ssgVtxTableShadow(void)
Definition grshadow.cpp:61
int getNumTexCoords()
Definition grshadow.h:33