gfxStructs.h

Engine/source/gfx/gfxStructs.h

More...

Classes:

class

Passed to GFX for shader defines.

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 _GFXSTRUCTS_H_
 25#define _GFXSTRUCTS_H_
 26
 27#ifndef _COLOR_H_
 28#include "core/color.h"
 29#endif
 30#ifndef _GFXVERTEXCOLOR_H_
 31#include "gfx/gfxVertexColor.h"
 32#endif
 33#ifndef _GFXENUMS_H_
 34#include "gfx/gfxEnums.h"
 35#endif
 36#ifndef _MMATH_H_
 37#include "math/mMath.h"
 38#endif
 39#ifndef _PROFILER_H_
 40#include "platform/profiler.h"
 41#endif
 42#ifndef _GFXRESOURCE_H_
 43#include "gfx/gfxResource.h"
 44#endif
 45#ifndef _REFBASE_H_
 46#include "core/util/refBase.h"
 47#endif
 48#ifndef _GFXVERTEXTYPES_H_
 49#include "gfx/gfxVertexTypes.h"
 50#endif
 51
 52
 53//-----------------------------------------------------------------------------
 54// This class is used to interact with an API's fixed function lights.  See GFX->setLight
 55class GFXLightInfo 
 56{
 57public:
 58   enum Type {
 59      Point    = 0,
 60      Spot     = 1,
 61      Vector   = 2,
 62      Ambient  = 3,
 63   };
 64   Type        mType;
 65
 66   Point3F     mPos;
 67   VectorF     mDirection;
 68   ColorF      mColor;
 69   ColorF      mAmbient;
 70   F32         mRadius;
 71   F32         mInnerConeAngle;
 72   F32         mOuterConeAngle;
 73
 74   /// @todo Revisit below (currently unused by fixed function lights)
 75   Point3F position;
 76   ColorF ambient;
 77   ColorF diffuse;
 78   ColorF specular;
 79   VectorF spotDirection;
 80   F32 spotExponent;
 81   F32 spotCutoff;
 82   F32 constantAttenuation;
 83   F32 linearAttenuation;
 84   F32 quadraticAttenuation;
 85};
 86
 87//-----------------------------------------------------------------------------
 88
 89// Material definition for FF lighting
 90struct GFXLightMaterial
 91{
 92   ColorF ambient;
 93   ColorF diffuse;
 94   ColorF specular;
 95   ColorF emissive;
 96   F32 shininess;
 97};
 98
 99//-----------------------------------------------------------------------------
100
101struct GFXVideoMode 
102{
103   GFXVideoMode();
104
105   Point2I resolution;
106   U32 bitDepth;
107   U32 refreshRate;
108   bool fullScreen;
109   bool wideScreen;
110   // When this is returned from GFX, it's the max, otherwise it's the desired AA level.
111   U32 antialiasLevel;
112
113   inline bool operator ==( const GFXVideoMode &otherMode ) const 
114   {
115      if( otherMode.fullScreen != fullScreen )
116         return false;
117      if( otherMode.resolution != resolution )
118         return false;
119      if( otherMode.bitDepth != bitDepth )
120         return false;
121      if( otherMode.refreshRate != refreshRate )
122         return false;
123      if( otherMode.wideScreen != wideScreen )
124         return false;
125      if( otherMode.antialiasLevel != antialiasLevel)
126         return false;
127
128      return true;
129   }
130   
131   inline bool operator!=( const GFXVideoMode& otherMode ) const
132   {
133      return !( *this == otherMode );
134   }
135
136   /// Fill whatever fields we can from the passed string, which should be 
137   /// of form "width height [bitDepth [refreshRate] [antialiasLevel]]" Unspecified fields
138   /// aren't modified, so you may want to set defaults before parsing.
139   void parseFromString( const char *str );
140
141   /// Gets a string representation of the object as
142   /// "resolution.x resolution.y fullScreen bitDepth refreshRate antialiasLevel"
143   ///
144   /// \return (string) A string representation of the object.
145   const String toString() const;
146};
147
148
149//-----------------------------------------------------------------------------
150
151struct GFXPrimitive
152{
153   GFXPrimitiveType type;
154
155   U32 startVertex;    /// offset into vertex buffer to change where vertex[0] is
156   U32 minIndex;       /// minimal value we will see in the indices
157   U32 startIndex;     /// start of indices in buffer
158   U32 numPrimitives;  /// how many prims to render
159   U32 numVertices;    /// how many vertices... (used for locking, we lock from minIndex to minIndex + numVertices)
160
161   GFXPrimitive()
162   {
163      dMemset( this, 0, sizeof( GFXPrimitive ) );
164   }
165};
166
167/// Passed to GFX for shader defines.
168struct GFXShaderMacro
169{
170   GFXShaderMacro() {}
171
172   GFXShaderMacro( const GFXShaderMacro &macro )
173      :  name( macro.name ), 
174         value( macro.value ) 
175      {}
176
177   GFXShaderMacro(   const String &name_, 
178                     const String &value_ = String::EmptyString )
179      :  name( name_ ), 
180         value( value_ ) 
181      {}
182
183   ~GFXShaderMacro() {}
184
185   /// The macro name.
186   String name;
187
188   /// The optional macro value.
189   String value;
190
191   static void stringize( const Vector<GFXShaderMacro> &macros, String *outString );
192};
193
194
195#endif // _GFXSTRUCTS_H_
196