2 // Copyright (C) 2007-2008 by Martin Moracek
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Encapsulates chosen renderer/display
30 #include "math/matrix.h"
31 #include "core/client/display.h"
36 class AttribBufferSet
;
44 uint batches
; // number of draw calls
52 -triangles (unique vs. total)
53 -batches (unique vs. total) - draw calls
59 -time spent rendering?
68 uint count
; // frame count
73 const Matrix4x4f
* trans
;
74 const AttribBufferSet
* attribs
;
75 const IndexBuffer
* indices
;
76 const Effect
* effect
;
77 const EffectVars
* fxVars
;
82 GeometryInfo(const Matrix4x4f
& t
, const AttribBufferSet
* a
,
83 const IndexBuffer
* i
, const Effect
* e
, const EffectVars
& ev
)
84 : trans(&t
), attribs(a
), indices(i
), effect(e
), fxVars(&ev
) {}
86 GeometryInfo(const Matrix4x4f
* t
, const AttribBufferSet
* a
,
87 const IndexBuffer
* i
, const Effect
* e
, const EffectVars
* ev
)
88 : trans(t
), attribs(a
), indices(i
), effect(e
), fxVars(ev
) {}
91 typedef std::vector
<GeometryInfo
> GeometryBatch
;
95 static bool CheckErrors(const char * msg
=NULL
, bool confirmOK
=false);
102 virtual ~Renderer() {}
104 virtual void Init(void) = 0;
106 virtual void NewFrame(void) = 0;
107 virtual void FlushFrame(void) = 0;
108 virtual void PresentFrame(void) = 0;
110 virtual void SetCamera(const PVolume
& cam
) = 0;
111 virtual void SetCameraTransform(const Matrix4x4f
* cnv
) = 0;
113 virtual void PushCanvas(const Canvas
* cnv
) = 0;
114 virtual void PopCanvas(void) = 0;
116 virtual void DrawGeometry(const GeometryBatch::iterator
& begin
,
117 const GeometryBatch::iterator
& end
) = 0;
120 Renderer
& sRenderer(void);