gfxNullDevice.h 6.9 KB

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