~evan-nelson/armagetronad/armagetronad+pcm

« back to all changes in this revision

Viewing changes to src/render/rDisplayList.h

Attempting to create a timeout for PLAYER_CENTER_MESSAGE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
*************************************************************************
4
 
 
5
 
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
 
Copyright (C) 2008  Manuel Moos (manuel@moosnet.de) and the AA Development Team
7
 
 
8
 
**************************************************************************
9
 
 
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.
14
 
 
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.
19
 
 
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.
23
 
  
24
 
***************************************************************************
25
 
 
26
 
*/
27
 
 
28
 
#ifndef ArmageTron_DISPLAYLIST_H
29
 
#define ArmageTron_DISPLAYLIST_H
30
 
 
31
 
#include "config.h"
32
 
 
33
 
#include "rGL.h"
34
 
#include "tLinkedList.h"
35
 
 
36
 
 
37
 
// Usage example for caching display elements:
38
 
 
39
 
#if 0
40
 
void example()
41
 
{
42
 
    static rDisplayList list;
43
 
 
44
 
    // + some logic calling list.Clear() when it needs updating
45
 
 
46
 
    if ( !list.Call() )
47
 
    {
48
 
        rDisplayListFiller filler( list );
49
 
 
50
 
        // + rendering code
51
 
    }
52
 
}
53
 
 
54
 
// Things we have found to be problematic in certain OpenGL
55
 
// implementations:
56
 
// - Redundant color settings (glColor3f(1,1,1);glColor3f(1,1,1);)
57
 
// - Infinite points (glVertex4f(1,1,0,0);)
58
 
#endif
59
 
 
60
 
//! display list wrapper
61
 
class rDisplayList: public tListItem< rDisplayList >
62
 
{
63
 
    friend class rDisplayListFiller;
64
 
public:
65
 
    rDisplayList();
66
 
    ~rDisplayList();
67
 
 
68
 
    bool IsSet() const
69
 
    {
70
 
#ifndef DEDICATED
71
 
        return list_ && !inhibit_;
72
 
#else
73
 
        return false;
74
 
#endif
75
 
    }
76
 
 
77
 
    bool IsInhibited() const
78
 
    {
79
 
#ifndef DEDICATED
80
 
        return inhibit_;
81
 
#else
82
 
        return false;
83
 
#endif
84
 
    }
85
 
 
86
 
    //! check whether a displaylist is currently being recorded.
87
 
    static bool IsRecording();
88
 
    
89
 
    //! calls the display list, returns true if there was a list to call
90
 
    bool Call()
91
 
    {
92
 
        return OnCall();
93
 
    }
94
 
 
95
 
    //! clears the display list and don't regenerate it for the next few calls
96
 
    void Clear( int inhibitGeneration = 1 );
97
 
 
98
 
    //! clears all display lists
99
 
    static void ClearAll();
100
 
 
101
 
    //! cancels recording of the current display list
102
 
    static void Cancel();
103
 
protected:
104
 
    //! calls the display list, returns true if there was a list to call
105
 
    virtual bool OnCall();
106
 
private:
107
 
    rDisplayList( rDisplayList const & );
108
 
    rDisplayList & operator = ( rDisplayList const & );
109
 
 
110
 
#ifndef DEDICATED
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
114
 
#endif
115
 
};
116
 
 
117
 
//! display list wrapper for display lists changing when the alpha blending setting changes
118
 
class rDisplayListAlphaSensitive: public rDisplayList
119
 
{
120
 
public:
121
 
    rDisplayListAlphaSensitive();
122
 
 
123
 
protected:
124
 
    //! calls the display list, returns true if there was a list to call
125
 
    virtual bool OnCall();
126
 
private:
127
 
    bool lastAlpha_; //!< the last alpha blending value
128
 
};
129
 
 
130
 
//! create an object of this type to fill a display list while you render
131
 
class rDisplayListFiller
132
 
{
133
 
    friend class rDisplayList;
134
 
public:
135
 
    //! constructor, automatically starting to fill teh list
136
 
    explicit rDisplayListFiller( rDisplayList & list, bool respectBlacklist = true );
137
 
    ~rDisplayListFiller();
138
 
 
139
 
    //! starts filling the display list (done automatically on construction)
140
 
    void Start( bool respectBlacklist = true );
141
 
    
142
 
    //! stops filling the display list (done automatically on destruction)
143
 
    void Stop();
144
 
 
145
 
private: 
146
 
    rDisplayListFiller( rDisplayListFiller const & );
147
 
    rDisplayListFiller & operator = ( rDisplayListFiller const & );
148
 
 
149
 
#ifndef DEDICATED
150
 
    //! the list
151
 
    rDisplayList & list_;
152
 
#endif
153
 
};
154
 
 
155
 
#endif
156
 
 
157