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
 54struct GFXVideoMode 
 55{
 56   GFXVideoMode();
 57
 58   Point2I resolution;
 59   U32 bitDepth;
 60   U32 refreshRate;
 61   bool fullScreen;
 62   bool wideScreen;
 63   // When this is returned from GFX, it's the max, otherwise it's the desired AA level.
 64   U32 antialiasLevel;
 65
 66   inline bool operator ==( const GFXVideoMode &otherMode ) const 
 67   {
 68      if( otherMode.fullScreen != fullScreen )
 69         return false;
 70      if( otherMode.resolution != resolution )
 71         return false;
 72      if( otherMode.bitDepth != bitDepth )
 73         return false;
 74      if( otherMode.refreshRate != refreshRate )
 75         return false;
 76      if( otherMode.wideScreen != wideScreen )
 77         return false;
 78      if( otherMode.antialiasLevel != antialiasLevel)
 79         return false;
 80
 81      return true;
 82   }
 83   
 84   inline bool operator!=( const GFXVideoMode& otherMode ) const
 85   {
 86      return !( *this == otherMode );
 87   }
 88
 89   /// Fill whatever fields we can from the passed string, which should be 
 90   /// of form "width height [bitDepth [refreshRate] [antialiasLevel]]" Unspecified fields
 91   /// aren't modified, so you may want to set defaults before parsing.
 92   void parseFromString( const char *str );
 93
 94   /// Gets a string representation of the object as
 95   /// "resolution.x resolution.y fullScreen bitDepth refreshRate antialiasLevel"
 96   ///
 97   /// \return (string) A string representation of the object.
 98   const String toString() const;
 99};
100
101//-----------------------------------------------------------------------------
102
103struct GFXPrimitive
104{
105   GFXPrimitiveType type;
106
107   U32 startVertex;    /// offset into vertex buffer to change where vertex[0] is
108   U32 minIndex;       /// minimal value we will see in the indices
109   U32 startIndex;     /// start of indices in buffer
110   U32 numPrimitives;  /// how many prims to render
111   U32 numVertices;    /// how many vertices... (used for locking, we lock from minIndex to minIndex + numVertices)
112
113   GFXPrimitive()
114   {
115      type = GFXPT_FIRST;
116      startVertex = 0;
117      minIndex = 0;
118      startIndex = 0;
119      numPrimitives = 0;
120      numVertices = 0;
121   }
122};
123
124/// Passed to GFX for shader defines.
125struct GFXShaderMacro
126{
127   GFXShaderMacro() {}
128
129   GFXShaderMacro( const GFXShaderMacro &macro )
130      :  name( macro.name ), 
131         value( macro.value ) 
132      {}
133
134   GFXShaderMacro(   const String &name_, 
135                     const String &value_ = String::EmptyString )
136      :  name( name_ ), 
137         value( value_ ) 
138      {}
139
140   ~GFXShaderMacro() {}
141
142   /// The macro name.
143   String name;
144
145   /// The optional macro value.
146   String value;
147
148   static void stringize( const Vector<GFXShaderMacro> &macros, String *outString );
149};
150
151#endif // _GFXSTRUCTS_H_
152