Merge pull request #4594 from FernetMenta/paplayer
[xbmc.git] / xbmc / rendering / RenderSystem.h
blobfa64ebae36f34fe095440a93136c81adc7ce5ded
1 /*
2 * Copyright (C) 2005-2013 Team XBMC
3 * http://xbmc.org
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)
8 * any later version.
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
24 #pragma once
26 #include "guilib/Geometry.h"
27 #include "guilib/TransformMatrix.h"
28 #include "guilib/DirtyRegion.h"
29 #include "utils/StdString.h"
30 #include <stdint.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;
47 enum
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)
56 enum
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_INTERLACED,
78 RENDER_STEREO_MODE_HARDWAREBASED,
79 RENDER_STEREO_MODE_MONO,
80 RENDER_STEREO_MODE_COUNT,
82 // psuevdo modes
83 RENDER_STEREO_MODE_AUTO = 100,
87 class CRenderSystemBase
89 public:
90 CRenderSystemBase();
91 virtual ~CRenderSystemBase();
93 // Retrieve
94 RenderingSystemType GetRenderingSystemType() { return m_enumRenderingSystem; }
96 virtual bool InitRenderSystem() = 0;
97 virtual bool DestroyRenderSystem() = 0;
98 virtual bool ResetRenderSystem(int width, int height, bool fullScreen, float refreshRate) = 0;
100 virtual bool BeginRender() = 0;
101 virtual bool EndRender() = 0;
102 virtual bool PresentRender(const CDirtyRegionList& dirty) = 0;
103 virtual bool ClearBuffers(color_t color) = 0;
104 virtual bool IsExtSupported(const char* extension) = 0;
106 virtual void SetVSync(bool vsync) = 0;
107 bool GetVSync() { return m_bVSync; }
109 virtual void SetViewPort(CRect& viewPort) = 0;
110 virtual void GetViewPort(CRect& viewPort) = 0;
111 virtual void RestoreViewPort() {};
113 virtual void SetScissors(const CRect &rect) = 0;
114 virtual void ResetScissors() = 0;
116 virtual void CaptureStateBlock() = 0;
117 virtual void ApplyStateBlock() = 0;
119 virtual void SetCameraPosition(const CPoint &camera, int screenWidth, int screenHeight) = 0;
120 virtual void ApplyHardwareTransform(const TransformMatrix &matrix) = 0;
121 virtual void RestoreHardwareTransform() = 0;
122 virtual void SetStereoMode(RENDER_STEREO_MODE mode, RENDER_STEREO_VIEW view)
124 m_stereoMode = mode;
125 m_stereoView = view;
128 virtual bool TestRender() = 0;
131 * Project (x,y,z) 3d scene coordinates to (x,y) 2d screen coordinates
133 virtual void Project(float &x, float &y, float &z) { }
135 void GetRenderVersion(unsigned int& major, unsigned int& minor) const;
136 const CStdString& GetRenderVendor() const { return m_RenderVendor; }
137 const CStdString& GetRenderRenderer() const { return m_RenderRenderer; }
138 const CStdString& GetRenderVersionString() const { return m_RenderVersion; }
139 bool SupportsDXT() const;
140 bool SupportsBGRA() const;
141 bool SupportsBGRAApple() const;
142 bool SupportsNPOT(bool dxt) const;
143 bool SupportsStereo(RENDER_STEREO_MODE mode) const;
144 unsigned int GetMaxTextureSize() const { return m_maxTextureSize; }
145 unsigned int GetMinDXTPitch() const { return m_minDXTPitch; }
146 unsigned int GetRenderQuirks() const { return m_renderQuirks; }
148 protected:
149 bool m_bRenderCreated;
150 RenderingSystemType m_enumRenderingSystem;
151 bool m_bVSync;
152 unsigned int m_maxTextureSize;
153 unsigned int m_minDXTPitch;
155 CStdString m_RenderRenderer;
156 CStdString m_RenderVendor;
157 CStdString m_RenderVersion;
158 int m_RenderVersionMinor;
159 int m_RenderVersionMajor;
160 unsigned int m_renderCaps;
161 unsigned int m_renderQuirks;
162 RENDER_STEREO_VIEW m_stereoView;
163 RENDER_STEREO_MODE m_stereoMode;
166 #endif // RENDER_SYSTEM_H