gfxNullDevice.h
Engine/source/gfx/Null/gfxNullDevice.h
Classes:
class
class
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _GFXNullDevice_H_ 25#define _GFXNullDevice_H_ 26 27#include "platform/platform.h" 28 29//----------------------------------------------------------------------------- 30 31#include "gfx/gfxDevice.h" 32#include "gfx/gfxInit.h" 33#include "gfx/gfxFence.h" 34 35class GFXNullWindowTarget : public GFXWindowTarget 36{ 37public: 38 virtual bool present() 39 { 40 return true; 41 } 42 43 virtual const Point2I getSize() 44 { 45 // Return something stupid. 46 return Point2I(1,1); 47 } 48 49 virtual GFXFormat getFormat() { return GFXFormatR8G8B8A8; } 50 51 virtual void resetMode() 52 { 53 54 } 55 56 virtual void zombify() {}; 57 virtual void resurrect() {}; 58 59}; 60 61class GFXNullDevice : public GFXDevice 62{ 63public: 64 GFXNullDevice(); 65 virtual ~GFXNullDevice(); 66 67 static GFXDevice *createInstance( U32 adapterIndex ); 68 69 static void enumerateAdapters( Vector<GFXAdapter*> &adapterList ); 70 71 void init( const GFXVideoMode &mode, PlatformWindow *window = NULL ); 72 73 virtual void activate() { }; 74 virtual void deactivate() { }; 75 virtual GFXAdapterType getAdapterType() { return NullDevice; }; 76 77 /// @name Debug Methods 78 /// @{ 79 virtual void enterDebugEvent(ColorI color, const char *name) { }; 80 virtual void leaveDebugEvent() { }; 81 virtual void setDebugMarker(ColorI color, const char *name) { }; 82 /// @} 83 84 /// Enumerates the supported video modes of the device 85 virtual void enumerateVideoModes() { }; 86 87 /// Sets the video mode for the device 88 virtual void setVideoMode( const GFXVideoMode &mode ) { }; 89protected: 90 static GFXAdapter::CreateDeviceInstanceDelegate mCreateDeviceInstance; 91 92 /// Called by GFXDevice to create a device specific stateblock 93 virtual GFXStateBlockRef createStateBlockInternal(const GFXStateBlockDesc& desc); 94 /// Called by GFXDevice to actually set a stateblock. 95 virtual void setStateBlockInternal(GFXStateBlock* block, bool force) { }; 96 /// @} 97 98 /// Called by base GFXDevice to actually set a const buffer 99 virtual void setShaderConstBufferInternal(GFXShaderConstBuffer* buffer) { }; 100 101 virtual void setTextureInternal(U32 textureUnit, const GFXTextureObject*texture) { }; 102 103 104 /// @name State Initalization. 105 /// @{ 106 107 /// State initalization. This MUST BE CALLED in setVideoMode after the device 108 /// is created. 109 virtual void initStates() { }; 110 111 virtual GFXVertexBuffer *allocVertexBuffer( U32 numVerts, 112 const GFXVertexFormat *vertexFormat, 113 U32 vertSize, 114 GFXBufferType bufferType, 115 void* data = NULL ); 116 virtual GFXPrimitiveBuffer *allocPrimitiveBuffer( U32 numIndices, 117 U32 numPrimitives, 118 GFXBufferType bufferType, 119 void* data = NULL ); 120 121 virtual GFXVertexDecl* allocVertexDecl( const GFXVertexFormat *vertexFormat ) { return NULL; } 122 virtual void setVertexDecl( const GFXVertexDecl *decl ) { } 123 virtual void setVertexStream( U32 stream, GFXVertexBuffer *buffer ) { } 124 virtual void setVertexStreamFrequency( U32 stream, U32 frequency ) { } 125 126public: 127 virtual GFXCubemap * createCubemap(); 128 virtual GFXCubemapArray *createCubemapArray(); 129 virtual GFXTextureArray *createTextureArray(); 130 131 virtual F32 getFillConventionOffset() const { return 0.0f; }; 132 133 ///@} 134 135 virtual GFXTextureTarget *allocRenderToTextureTarget(bool genMips=true){return NULL;}; 136 virtual GFXWindowTarget *allocWindowTarget(PlatformWindow *window) 137 { 138 return new GFXNullWindowTarget(); 139 }; 140 141 virtual void _updateRenderTargets(){}; 142 143 virtual F32 getPixelShaderVersion() const { return 0.0f; }; 144 virtual void setPixelShaderVersion( F32 version ) { }; 145 virtual U32 getNumSamplers() const { return 0; }; 146 virtual U32 getNumRenderTargets() const { return 0; }; 147 148 virtual GFXShader* createShader() { return NULL; }; 149 150 virtual void copyResource(GFXTextureObject *pDst, GFXCubemap *pSrc, const U32 face) { }; 151 virtual void clear( U32 flags, const LinearColorF& color, F32 z, U32 stencil ) { }; 152 virtual void clearColorAttachment(const U32 attachment, const LinearColorF& color) { }; 153 virtual bool beginSceneInternal() { return true; }; 154 virtual void endSceneInternal() { }; 155 156 virtual void drawPrimitive( GFXPrimitiveType primType, U32 vertexStart, U32 primitiveCount ) { }; 157 virtual void drawIndexedPrimitive( GFXPrimitiveType primType, 158 U32 startVertex, 159 U32 minIndex, 160 U32 numVerts, 161 U32 startIndex, 162 U32 primitiveCount ) { }; 163 164 virtual void setClipRect( const RectI &rect ) { }; 165 virtual const RectI &getClipRect() const { return clip; }; 166 167 virtual void preDestroy() { Parent::preDestroy(); }; 168 169 virtual U32 getMaxDynamicVerts() { return 16384; }; 170 virtual U32 getMaxDynamicIndices() { return 16384; }; 171 172 virtual GFXFormat selectSupportedFormat( GFXTextureProfile *profile, 173 const Vector<GFXFormat> &formats, 174 bool texture, 175 bool mustblend, 176 bool mustfilter ) { return GFXFormatR8G8B8A8; }; 177 178 GFXFence *createFence() { return new GFXGeneralFence( this ); } 179 GFXOcclusionQuery* createOcclusionQuery() { return NULL; } 180 181private: 182 typedef GFXDevice Parent; 183 RectI clip; 184}; 185 186#endif 187