gfxCubemap.h

Engine/source/gfx/gfxCubemap.h

More...

Classes:

class

A reference counted handle to a cubemap resource.

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 _GFXCUBEMAP_H_
25#define _GFXCUBEMAP_H_
26
27#ifndef _GFXTEXTUREHANDLE_H_
28#include "gfx/gfxTextureHandle.h"
29#endif
30
31class GFXDevice;
32struct DDSFile;
33
34///
35class GFXCubemap : public StrongRefBase, public GFXResource
36{
37   friend class GFXDevice;
38   friend class GFXTextureManager;
39
40protected:
41
42   // should only be called by GFXDevice
43   virtual void setToTexUnit( U32 tuNum ) = 0;
44
45   /// The path to the cubemap file.
46   String mPath;
47
48   /// Sets the cubemap file path.
49   void _setPath( const String &path ) { mPath = path; }
50
51public:
52
53   /// Create a static cubemap from a list of 6 face textures.
54   virtual void initStatic( GFXTexHandle *faces ) = 0;
55
56   /// Create a static cubemap from a DDS cubemap file.
57   virtual void initStatic( DDSFile *dds ) = 0;
58
59   ///
60   virtual void initDynamic( U32 texSize, GFXFormat faceFormat = GFXFormatR8G8B8A8 ) = 0;
61
62   void initNormalize(U32 size);
63      
64   virtual ~GFXCubemap();
65
66   /// Returns the size of the faces.
67   virtual U32 getSize() const = 0;
68
69   /// Returns the face texture format.
70   virtual GFXFormat getFormat() const = 0;
71
72   /// Returns the cubemap file path set at creation.
73   const String& getPath() const { return mPath; }
74
75   // GFXResource interface
76   /// The resource should put a description of itself (number of vertices, size/width of texture, etc.) in buffer
77   virtual const String describeSelf() const;
78};
79
80
81/// A reference counted handle to a cubemap resource.
82class GFXCubemapHandle : public StrongRefPtr<GFXCubemap>
83{
84public:
85   GFXCubemapHandle() {}
86   GFXCubemapHandle( GFXCubemap *cubemap ) { StrongRefPtr<GFXCubemap>::set( cubemap ); }
87   GFXCubemapHandle( const String &cubemapDDS ) { set( cubemapDDS ); }
88
89   /// Set a cubemap from a DDS cubemap texture file.
90   bool set( const String &cubemapDDS );
91
92   /// Releases the texture handle.
93   void free() { StrongObjectRef::set( NULL ); }
94};
95
96
97#endif // GFXCUBEMAP
98