src/render/rRender.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #ifndef ArmageTron_RENDER_H
00029 #define ArmageTron_RENDER_H
00030 
00031 #include "defs.h"
00032 #include "rGL.h"
00033 
00034 #ifndef DONTDOIT
00035 #define glBegin        #error glBegin disabled
00036 #define glEnd          #error glEnd   disabled
00037 #define glMatrixMode   #error glEnd   disabled
00038 #endif
00039 
00040 class rRenderer{
00041 public:
00042     rRenderer();
00043     virtual ~rRenderer();
00044 
00045     virtual void Vertex(REAL x, REAL y)                 = 0;
00046     virtual void Vertex(REAL x, REAL y, REAL z)         = 0;
00047     virtual void Vertex3(REAL *x)                       = 0;
00048     virtual void Vertex(REAL x, REAL y, REAL z, REAL w) = 0;
00049 
00050     virtual void TexCoord(REAL u, REAL v)                 = 0;
00051     virtual void TexCoord(REAL u, REAL v, REAL w)         = 0;
00052     virtual void TexCoord(REAL u, REAL v, REAL w, REAL t) = 0;
00053 
00054     virtual void TexVertex(REAL x, REAL y, REAL z,
00055                            REAL u, REAL v);
00056 
00057     virtual void Color(REAL r, REAL g, REAL b)        = 0;
00058     virtual void Color(REAL r, REAL g, REAL b,REAL a) = 0;
00059 
00060     virtual void End(bool force=true)   = 0;
00061 
00062     virtual void BeginLines()      = 0;
00063     virtual void BeginTriangles()  = 0;
00064     virtual void BeginQuads()      = 0;
00065 
00066     virtual void BeginLineStrip()      = 0;
00067     virtual void BeginTriangleStrip()  = 0;
00068     virtual void BeginQuadStrip()      = 0;
00069 
00070     virtual void BeginTriangleFan()    = 0;
00071     virtual void BeginLineLoop()      = 0;
00072 
00073     virtual void Line(REAL x1, REAL y1, REAL z1,
00074                       REAL x2, REAL y2, REAL z2);
00075 
00076 
00077     virtual void ProjMatrix()     = 0;
00078     virtual void ModelMatrix()    = 0;
00079     virtual void TexMatrix()      = 0;
00080 
00081     virtual void PushMatrix()     = 0;
00082     virtual void PopMatrix()      = 0;
00083     virtual void MultMatrix(REAL mdata[4][4]) = 0;
00084 
00085     virtual void IdentityMatrix()                       = 0;
00086     virtual void ScaleMatrix(REAL f)                    = 0;
00087     virtual void ScaleMatrix(REAL f1, REAL f2, REAL f3) = 0;
00088 
00089     virtual void TranslateMatrix(REAL x1, REAL x2, REAL x3) = 0;
00090 
00091 
00092     typedef enum {BACKFACE_CULL=0, ALPHA_BLEND, ALPHA_TEST, DEPTH_TEST,
00093                   SMOOTH_SHADE, Z_OFFSET,
00094                   FLAG_END} flag;
00095 
00096     void PushFlags();
00097     void PopFlags();
00098     void SetFlag(flag f, bool c);
00099 
00100 protected:
00101     virtual void ReallySetFlag(flag f, bool c) = 0;
00102     void         ChangeFlags(int before, int after) const;
00103 
00104 #define STACK_DEPTH 100
00105 
00106     int flagstack[STACK_DEPTH];
00107     int stackpos;
00108 };
00109 
00110 extern rRenderer *renderer;
00111 
00112 inline void Vertex(REAL x, REAL y){
00113     renderer->Vertex(x,y);
00114 }
00115 
00116 inline void Vertex(REAL x, REAL y, REAL z){
00117     renderer->Vertex(x,y,z);
00118 }
00119 
00120 inline void Vertex3(REAL *x){
00121     renderer->Vertex3(x);
00122 }
00123 
00124 inline void Vertex(REAL x, REAL y, REAL z, REAL w){
00125     renderer->Vertex(x,y,z,w);
00126 }
00127 
00128 inline void TexCoord(REAL u, REAL v){
00129     renderer->TexCoord(u,v);
00130 }
00131 
00132 inline void TexCoord(REAL u, REAL v, REAL w){
00133     renderer->TexCoord(u,v,w);
00134 }
00135 
00136 inline void TexCoord(REAL u, REAL v, REAL w, REAL t){
00137     renderer->TexCoord(u,v,w,t);
00138 }
00139 
00140 inline void TexVertex(REAL x, REAL y, REAL z,
00141                       REAL u, REAL v){
00142     renderer->TexVertex(x,y,z,u,v);
00143 }
00144 
00145 inline void Color(REAL r, REAL g, REAL b){
00146     renderer->Color(r,g,b);
00147 }
00148 
00149 inline void Color(REAL r, REAL g, REAL b,REAL a){
00150     renderer->Color(r,g,b,a);
00151 }
00152 
00153 inline void RenderEnd(bool force=true){
00154     renderer->End(force);
00155 }
00156 
00157 inline void BeginLines(){
00158     renderer->BeginLines();
00159 }
00160 
00161 inline void BeginTriangles(){
00162     renderer->BeginTriangles();
00163 }
00164 
00165 inline void BeginQuads(){
00166     renderer->BeginQuads();
00167 }
00168 
00169 inline void BeginLineStrip(){
00170     renderer->BeginLineStrip();
00171 }
00172 
00173 inline void BeginLineLoop(){
00174     renderer->BeginLineLoop();
00175 }
00176 
00177 inline void BeginTriangleStrip(){
00178     renderer->BeginTriangleStrip();
00179 }
00180 
00181 inline void BeginQuadStrip(){
00182     renderer->BeginQuadStrip();
00183 }
00184 
00185 inline void BeginTriangleFan(){
00186     renderer->BeginTriangleFan();
00187 }
00188 
00189 
00190 inline void Line(REAL x1, REAL y1, REAL z1,
00191                  REAL x2, REAL y2, REAL z2){
00192     renderer->Line(x1,y1,z1,x2,y2,z2);
00193 }
00194 
00195 
00196 
00197 inline void ProjMatrix(){
00198     renderer->ProjMatrix();
00199 }
00200 
00201 inline void ModelMatrix(){
00202     renderer->ModelMatrix();
00203 }
00204 
00205 inline void TexMatrix(){
00206     renderer->TexMatrix();
00207 }
00208 
00209 
00210 inline void PushMatrix(){
00211     renderer->PushMatrix();
00212 }
00213 
00214 inline void PopMatrix(){
00215     renderer->PopMatrix();
00216 }
00217 
00218 
00219 inline void MultMatrix(REAL mdata[4][4]){
00220     renderer->MultMatrix(mdata);
00221 }
00222 
00223 
00224 inline void IdentityMatrix(){
00225     renderer->IdentityMatrix();
00226 }
00227 
00228 inline void ScaleMatrix(REAL f){
00229     renderer->ScaleMatrix(f);
00230 }
00231 
00232 inline void ScaleMatrix(REAL f1, REAL f2, REAL f3){
00233     renderer->ScaleMatrix(f1,f2,f3);
00234 }
00235 
00236 
00237 inline void TranslateMatrix(REAL x1, REAL x2, REAL x3){
00238     renderer->TranslateMatrix(x1,x2,x3);
00239 }
00240 
00241 void sr_RendererCleanup();
00242 void sr_glRendererInit();
00243 
00244 #endif

Generated on Sat Mar 15 22:55:52 2008 for Armagetron Advanced by  doxygen 1.5.4