1 /*
2 
3 *************************************************************************
4 
5 ArmageTron -- Just another Tron Lightcycle Game in 3D.
6 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
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_SCREEN_H
29 #define ArmageTron_SCREEN_H
30 
31 #include "tString.h"
32 #include "tCallback.h"
33 #include "tCallbackString.h"
34 
35 typedef enum {
36     ArmageTron_Desktop=0,ArmageTron_320_200,ArmageTron_Min=ArmageTron_320_200, ArmageTron_320_240,ArmageTron_400_300,
37     ArmageTron_512_384,ArmageTron_640_480,ArmageTron_800_600,
38     ArmageTron_1024_768,ArmageTron_1280_800,ArmageTron_1280_854,ArmageTron_1280_1024,
39     ArmageTron_1600_1200,ArmageTron_1680_1050,ArmageTron_2048_1572,ArmageTron_Custom, ArmageTron_Invalid=-1
40 }
41 rResolution;
42 
43 typedef enum {
44     ArmageTron_ColorDepth_16, ArmageTron_ColorDepth_Desktop,
45     ArmageTron_ColorDepth_32
46 }
47 rColorDepth;
48 
49 struct rScreenSize
50 {
51     rResolution         res;
52     int                 width, height;
53 
54     rScreenSize( int width, int height ); //!< constructor
55     explicit rScreenSize( rResolution r = ArmageTron_Invalid ); //!< constructor
56     void UpdateSize();                                          //!< update size from res enum
57 
58     bool operator ==( rScreenSize const & other ) const; //!< comparison operator
59     bool operator !=( rScreenSize const & other ) const; //!< comparison operator
60 
61     int Compare( rScreenSize const & other ) const; //!< comparison function
62 };
63 
64 class rScreenSettings
65 {
66 public:
67     rScreenSize			res;
68     rScreenSize			windowSize;
69     bool				fullscreen;
70     rColorDepth			colorDepth;
71     rColorDepth			zDepth;
72     bool				useSDL;
73     bool				checkErrors;
74     REAL				aspect;			// aspect ratio of pixels ( width/height )
75 
76     rScreenSettings(rResolution r,
77                     bool fs=true,
78                     rColorDepth cd=ArmageTron_ColorDepth_Desktop,
79                     bool sdl=true,
80                     bool ce =true);
81 };
82 
83 bool sr_DesktopScreensizeSupported();
84 
85 extern rScreenSettings currentScreensetting;
86 extern rScreenSettings lastSuccess;
87 
88 struct SDL_Surface;
89 extern SDL_Surface *sr_screen;
90 
91 extern int sr_screenWidth,sr_screenHeight;
92 
93 extern bool sr_alphaBlend;
94 extern bool sr_screenshotIsPlanned;
95 extern bool sr_smoothShading;
96 
97 extern bool sr_glOut;           // do we have gl-output at all?
98 extern bool sr_textOut;          // display game text graphically?
99 extern bool sr_FPSOut;           // display frame counter?
100 
101 //! how should caching display lists be used?
102 enum rDisplayListUsage
103 {
104     rDisplayList_Off=0, // not at all
105     rDisplayList_CAC,   // yes, with GL_COMPILE, then glCallList.
106     rDisplayList_CAE,   // yes, with GL_COMPILE_AND_EXECUTE
107     rDisplayList_Count
108 };
109 
110 extern rDisplayListUsage sr_useDisplayLists;   // use GL display lists
111 extern bool sr_blacklistDisplayLists;   // use GL display lists (override for buggy implementations)
112 // not delete the screen, just pait the background with depth test
113 // disabled. Gives 20% speedup.
114 
115 
116 #define rMIRROR_OFF     0
117 #define rMIRROR_OBJECTS 1
118 #define rMIRROR_WALLS   2
119 #define rMIRROR_ALL     10
120 
121 extern int sr_floorMirror;
122 
123 #define rFLOOR_OFF        0
124 #define rFLOOR_GRID       1
125 #define rFLOOR_TEXTURE    2
126 #define rFLOOR_TWOTEXTURE 3
127 
128 extern int sr_floorDetail;
129 
130 #define rFEAT_OFF    -1
131 #define rFEAT_DEFAULT 0
132 #define rFEAT_ON      1
133 
134 extern bool sr_highRim;
135 extern bool sr_upperSky,sr_lowerSky;
136 extern bool sr_skyWobble;
137 extern bool sr_dither;
138 extern bool sr_infinityPlane;
139 extern bool sr_laggometer;
140 extern bool sr_predictObjects;
141 extern bool sr_texturesTruecolor;
142 extern bool sr_keepWindowActive;
143 
144 extern tString renderer_identification;  // type of renderer used
145 
146 extern tString gl_vendor;
147 extern tString gl_renderer;
148 extern tString gl_version;
149 extern tString gl_extensions;
150 
151 class rPerFrameTask:public tCallback{
152 public:
153     rPerFrameTask(VOIDFUNC *f);
154     static void DoPerFrameTasks();
155 };
156 
157 class rRenderIdCallback:public tCallbackString{
158 public:
159     rRenderIdCallback(STRINGRETFUNC *f);
160     static tString RenderId();
161 };
162 
163 class rCallbackBeforeScreenModeChange:public tCallback{
164 public:
165     rCallbackBeforeScreenModeChange(VOIDFUNC *f);
166     static void Exec();
167 };
168 
169 class rCallbackAfterScreenModeChange:public tCallback{
170 public:
171     rCallbackAfterScreenModeChange(VOIDFUNC *f);
172     static void Exec();
173 };
174 
175 bool sr_InitDisplay();
176 void sr_ExitDisplay();
177 void sr_ReinitDisplay();
178 
179 void sr_LoadDefaultConfig();
180 
181 void sr_ResetRenderState(bool menu=0);
182 void sr_DepthOffset(bool offset);
183 void sr_Activate(bool active); // set activation staus
184 
185 void sr_LockSDL();
186 void sr_UnlockSDL();
187 #endif
188