3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2008 Manuel Moos (manuel@moosnet.de) and the AA Development Team
8
**************************************************************************
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
***************************************************************************
28
#ifndef ArmageTron_DISPLAYLIST_H
29
#define ArmageTron_DISPLAYLIST_H
34
#include "tLinkedList.h"
37
// Usage example for caching display elements:
42
static rDisplayList list;
44
// + some logic calling list.Clear() when it needs updating
48
rDisplayListFiller filler( list );
54
// Things we have found to be problematic in certain OpenGL
56
// - Redundant color settings (glColor3f(1,1,1);glColor3f(1,1,1);)
57
// - Infinite points (glVertex4f(1,1,0,0);)
60
//! display list wrapper
61
class rDisplayList: public tListItem< rDisplayList >
63
friend class rDisplayListFiller;
71
return list_ && !inhibit_;
77
bool IsInhibited() const
86
//! check whether a displaylist is currently being recorded.
87
static bool IsRecording();
89
//! calls the display list, returns true if there was a list to call
95
//! clears the display list and don't regenerate it for the next few calls
96
void Clear( int inhibitGeneration = 1 );
98
//! clears all display lists
99
static void ClearAll();
101
//! cancels recording of the current display list
102
static void Cancel();
104
//! calls the display list, returns true if there was a list to call
105
virtual bool OnCall();
107
rDisplayList( rDisplayList const & );
108
rDisplayList & operator = ( rDisplayList const & );
111
GLuint list_; //!< the display list
112
int inhibit_; //!< inhibit display list generation for a while
113
bool filling_; //!< set if we're just filling the list
117
//! display list wrapper for display lists changing when the alpha blending setting changes
118
class rDisplayListAlphaSensitive: public rDisplayList
121
rDisplayListAlphaSensitive();
124
//! calls the display list, returns true if there was a list to call
125
virtual bool OnCall();
127
bool lastAlpha_; //!< the last alpha blending value
130
//! create an object of this type to fill a display list while you render
131
class rDisplayListFiller
133
friend class rDisplayList;
135
//! constructor, automatically starting to fill teh list
136
explicit rDisplayListFiller( rDisplayList & list, bool respectBlacklist = true );
137
~rDisplayListFiller();
139
//! starts filling the display list (done automatically on construction)
140
void Start( bool respectBlacklist = true );
142
//! stops filling the display list (done automatically on destruction)
146
rDisplayListFiller( rDisplayListFiller const & );
147
rDisplayListFiller & operator = ( rDisplayListFiller const & );
151
rDisplayList & list_;