1 // SwiftShader Software Renderer
\r
3 // Copyright(c) 2005-2012 TransGaming Inc.
\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,
\r
6 // transcribed, stored in a retrieval system, translated into any human or computer
\r
7 // language by any means, or disclosed to third parties without the explicit written
\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
\r
9 // or implied, including but not limited to any patent rights, are granted to you.
\r
12 #ifndef gl_Device_hpp
\r
13 #define gl_Device_hpp
\r
15 #include "Renderer/Renderer.hpp"
\r
43 unsigned int height;
\r
48 class Device : public sw::Renderer
\r
51 explicit Device(sw::Context *context);
\r
55 virtual void clearColor(unsigned int color, unsigned int rgbaMask);
\r
56 virtual void clearDepth(float z);
\r
57 virtual void clearStencil(unsigned int stencil, unsigned int mask);
\r
58 virtual Image *createDepthStencilSurface(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
\r
59 virtual Image *createRenderTarget(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool lockable);
\r
60 virtual void drawIndexedPrimitive(PrimitiveType type, unsigned int indexOffset, unsigned int primitiveCount, int indexSize);
\r
61 virtual void drawPrimitive(PrimitiveType primitiveType, unsigned int primiveCount);
\r
62 virtual void setDepthStencilSurface(egl::Image *newDepthStencil);
\r
63 virtual void setPixelShader(sw::PixelShader *shader);
\r
64 virtual void setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);
\r
65 virtual void setScissorEnable(bool enable);
\r
66 virtual void setRenderTarget(egl::Image *renderTarget);
\r
67 virtual void setScissorRect(const sw::Rect &rect);
\r
68 virtual void setVertexShader(sw::VertexShader *shader);
\r
69 virtual void setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);
\r
70 virtual void setViewport(const Viewport &viewport);
\r
72 virtual bool stretchRect(egl::Image *sourceSurface, const sw::Rect *sourceRect, egl::Image *destSurface, const sw::Rect *destRect, bool filter);
\r
73 virtual void finish();
\r
76 sw::Context *const context;
\r
78 bool bindResources();
\r
79 void bindShaderConstants();
\r
80 bool bindViewport(); // Also adjusts for scissoring
\r
82 bool validRectangle(const sw::Rect *rect, egl::Image *surface);
\r
85 sw::Rect scissorRect;
\r
88 sw::PixelShader *pixelShader;
\r
89 sw::VertexShader *vertexShader;
\r
91 bool pixelShaderDirty;
\r
92 unsigned int pixelShaderConstantsFDirty;
\r
93 bool vertexShaderDirty;
\r
94 unsigned int vertexShaderConstantsFDirty;
\r
96 float pixelShaderConstantF[224][4];
\r
97 float vertexShaderConstantF[256][4];
\r
99 egl::Image *renderTarget;
\r
100 egl::Image *depthStencil;
\r
104 #endif // gl_Device_hpp
\r