2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #ifndef RENDER_SYSTEM_H
22 #define RENDER_SYSTEM_H
26 #include "guilib/Geometry.h"
27 #include "guilib/TransformMatrix.h"
28 #include "guilib/DirtyRegion.h"
32 typedef enum _RenderingSystemType
34 RENDERING_SYSTEM_OPENGL
,
35 RENDERING_SYSTEM_DIRECTX
,
36 RENDERING_SYSTEM_OPENGLES
37 } RenderingSystemType
;
40 * CRenderSystemBase interface allows us to create the rendering engine we use.
41 * We currently have two engines: OpenGL and DirectX
42 * This interface is very basic since a lot of the actual details will go in to the derived classes
45 typedef uint32_t color_t
;
49 RENDER_CAPS_DXT
= (1 << 0),
50 RENDER_CAPS_NPOT
= (1 << 1),
51 RENDER_CAPS_DXT_NPOT
= (1 << 2),
52 RENDER_CAPS_BGRA
= (1 << 3),
53 RENDER_CAPS_BGRA_APPLE
= (1 << 4)
58 RENDER_QUIRKS_MAJORMEMLEAK_OVERLAYRENDERER
= 1 << 0,
59 RENDER_QUIRKS_YV12_PREFERED
= 1 << 1,
60 RENDER_QUIRKS_BROKEN_OCCLUSION_QUERY
= 1 << 2,
63 enum RENDER_STEREO_VIEW
65 RENDER_STEREO_VIEW_OFF
,
66 RENDER_STEREO_VIEW_LEFT
,
67 RENDER_STEREO_VIEW_RIGHT
,
70 enum RENDER_STEREO_MODE
72 RENDER_STEREO_MODE_OFF
,
73 RENDER_STEREO_MODE_SPLIT_HORIZONTAL
,
74 RENDER_STEREO_MODE_SPLIT_VERTICAL
,
75 RENDER_STEREO_MODE_ANAGLYPH_RED_CYAN
,
76 RENDER_STEREO_MODE_ANAGLYPH_GREEN_MAGENTA
,
77 RENDER_STEREO_MODE_ANAGLYPH_YELLOW_BLUE
,
78 RENDER_STEREO_MODE_INTERLACED
,
79 RENDER_STEREO_MODE_CHECKERBOARD
,
80 RENDER_STEREO_MODE_HARDWAREBASED
,
81 RENDER_STEREO_MODE_MONO
,
82 RENDER_STEREO_MODE_COUNT
,
85 RENDER_STEREO_MODE_AUTO
= 100,
86 RENDER_STEREO_MODE_UNDEFINED
= 999,
90 class CRenderSystemBase
94 virtual ~CRenderSystemBase();
97 RenderingSystemType
GetRenderingSystemType() { return m_enumRenderingSystem
; }
99 virtual bool InitRenderSystem() = 0;
100 virtual bool DestroyRenderSystem() = 0;
101 virtual bool ResetRenderSystem(int width
, int height
, bool fullScreen
, float refreshRate
) = 0;
103 virtual bool BeginRender() = 0;
104 virtual bool EndRender() = 0;
105 virtual void PresentRender(bool rendered
, bool videoLayer
) = 0;
106 virtual bool ClearBuffers(color_t color
) = 0;
107 virtual bool IsExtSupported(const char* extension
) = 0;
109 virtual void SetViewPort(CRect
& viewPort
) = 0;
110 virtual void GetViewPort(CRect
& viewPort
) = 0;
111 virtual void RestoreViewPort() {};
113 virtual bool ScissorsCanEffectClipping() { return false; }
114 virtual CRect
ClipRectToScissorRect(const CRect
&rect
) { return CRect(); }
115 virtual void SetScissors(const CRect
&rect
) = 0;
116 virtual void ResetScissors() = 0;
118 virtual void CaptureStateBlock() = 0;
119 virtual void ApplyStateBlock() = 0;
121 virtual void SetCameraPosition(const CPoint
&camera
, int screenWidth
, int screenHeight
, float stereoFactor
= 0.f
) = 0;
122 virtual void ApplyHardwareTransform(const TransformMatrix
&matrix
) = 0;
123 virtual void RestoreHardwareTransform() = 0;
124 virtual void SetStereoMode(RENDER_STEREO_MODE mode
, RENDER_STEREO_VIEW view
)
130 virtual bool TestRender() = 0;
133 * Project (x,y,z) 3d scene coordinates to (x,y) 2d screen coordinates
135 virtual void Project(float &x
, float &y
, float &z
) { }
137 void GetRenderVersion(unsigned int& major
, unsigned int& minor
) const;
138 const std::string
& GetRenderVendor() const { return m_RenderVendor
; }
139 const std::string
& GetRenderRenderer() const { return m_RenderRenderer
; }
140 const std::string
& GetRenderVersionString() const { return m_RenderVersion
; }
141 bool SupportsDXT() const;
142 bool SupportsBGRA() const;
143 bool SupportsBGRAApple() const;
144 bool SupportsNPOT(bool dxt
) const;
145 virtual bool SupportsStereo(RENDER_STEREO_MODE mode
) const;
146 unsigned int GetMaxTextureSize() const { return m_maxTextureSize
; }
147 unsigned int GetMinDXTPitch() const { return m_minDXTPitch
; }
148 unsigned int GetRenderQuirks() const { return m_renderQuirks
; }
151 bool m_bRenderCreated
;
152 RenderingSystemType m_enumRenderingSystem
;
154 unsigned int m_maxTextureSize
;
155 unsigned int m_minDXTPitch
;
157 std::string m_RenderRenderer
;
158 std::string m_RenderVendor
;
159 std::string m_RenderVersion
;
160 int m_RenderVersionMinor
;
161 int m_RenderVersionMajor
;
162 unsigned int m_renderCaps
;
163 unsigned int m_renderQuirks
;
164 RENDER_STEREO_VIEW m_stereoView
;
165 RENDER_STEREO_MODE m_stereoMode
;
168 #endif // RENDER_SYSTEM_H