Torque3D Documentation / _generateds / gfxNullDevice.h

gfxNullDevice.h

Engine/source/gfx/Null/gfxNullDevice.h

More...

Classes:

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   virtual void setLightInternal(U32 lightStage, const GFXLightInfo light, bool lightEnable);
104   virtual void setLightMaterialInternal(const GFXLightMaterial mat) { };
105   virtual void setGlobalAmbientInternal(ColorF color) { };
106
107   /// @name State Initalization.
108   /// @{
109
110   /// State initalization. This MUST BE CALLED in setVideoMode after the device
111   /// is created.
112   virtual void initStates() { };
113
114   virtual void setMatrix( GFXMatrixType mtype, const MatrixF &mat ) { };
115
116   virtual GFXVertexBuffer *allocVertexBuffer(  U32 numVerts, 
117                                                const GFXVertexFormat *vertexFormat, 
118                                                U32 vertSize, 
119                                                GFXBufferType bufferType,
120                                                void* data = NULL );
121   virtual GFXPrimitiveBuffer *allocPrimitiveBuffer(  U32 numIndices, 
122                                                      U32 numPrimitives, 
123                                                      GFXBufferType bufferType,
124                                                      void* data = NULL );
125
126   virtual GFXVertexDecl* allocVertexDecl( const GFXVertexFormat *vertexFormat ) { return NULL; }
127   virtual void setVertexDecl( const GFXVertexDecl *decl ) {  }
128   virtual void setVertexStream( U32 stream, GFXVertexBuffer *buffer ) { }
129   virtual void setVertexStreamFrequency( U32 stream, U32 frequency ) { }
130
131public:
132   virtual GFXCubemap * createCubemap();
133
134   virtual F32 getFillConventionOffset() const { return 0.0f; };
135
136   ///@}
137
138   virtual GFXTextureTarget *allocRenderToTextureTarget(){return NULL;};
139   virtual GFXWindowTarget *allocWindowTarget(PlatformWindow *window)
140   {
141      return new GFXNullWindowTarget();
142   };
143
144   virtual void _updateRenderTargets(){};
145
146   virtual F32 getPixelShaderVersion() const { return 0.0f; };
147   virtual void setPixelShaderVersion( F32 version ) { };
148   virtual U32 getNumSamplers() const { return 0; };
149   virtual U32 getNumRenderTargets() const { return 0; };
150
151   virtual GFXShader* createShader() { return NULL; };
152
153
154   virtual void clear( U32 flags, ColorI color, F32 z, U32 stencil ) { };
155   virtual bool beginSceneInternal() { return true; };
156   virtual void endSceneInternal() { };
157
158   virtual void drawPrimitive( GFXPrimitiveType primType, U32 vertexStart, U32 primitiveCount ) { };
159   virtual void drawIndexedPrimitive(  GFXPrimitiveType primType, 
160                                       U32 startVertex, 
161                                       U32 minIndex, 
162                                       U32 numVerts, 
163                                       U32 startIndex, 
164                                       U32 primitiveCount ) { };
165
166   virtual void setClipRect( const RectI &rect ) { };
167   virtual const RectI &getClipRect() const { return clip; };
168
169   virtual void preDestroy() { Parent::preDestroy(); };
170
171   virtual U32 getMaxDynamicVerts() { return 16384; };
172   virtual U32 getMaxDynamicIndices() { return 16384; };
173
174   virtual GFXFormat selectSupportedFormat(  GFXTextureProfile *profile, 
175                                             const Vector<GFXFormat> &formats, 
176                                             bool texture, 
177                                             bool mustblend, 
178                                             bool mustfilter ) { return GFXFormatR8G8B8A8; };
179
180   GFXFence *createFence() { return new GFXGeneralFence( this ); }
181   GFXOcclusionQuery* createOcclusionQuery() { return NULL; }
182   
183private:
184   typedef GFXDevice Parent;
185   RectI clip;
186};
187
188#endif
189