Torque3D Documentation / _generateds / gfxGLEnumTranslate.cpp

gfxGLEnumTranslate.cpp

Engine/source/gfx/gl/gfxGLEnumTranslate.cpp

More...

Public Variables

GFXGLBlend [GFXBlend_COUNT]
GFXGLBlendOp [GFXBlendOp_COUNT]
GFXGLBufferType [GFXBufferType_COUNT]
GFXGLCmpFunc [GFXCmp_COUNT]
GFXGLCullMode [GFXCull_COUNT]
GFXGLFillMode [GFXFill_COUNT]
GFXGLPrimType [GFXPT_COUNT]
GFXGLSamplerState [GFXSAMP_COUNT]
GFXGLStencilOp [GFXStencilOp_COUNT]
GFXGLTextureAddress [GFXAddress_COUNT]
GFXGLTextureFilter [GFXTextureFilter_COUNT]
GFXGLTextureFormat [GFXFormat_COUNT]
GFXGLTextureSwizzle [GFXFormat_COUNT]
GFXGLTextureType [GFXFormat_COUNT]

Detailed Description

Public Variables

GLenum GFXGLBlend [GFXBlend_COUNT]
GLenum GFXGLBlendOp [GFXBlendOp_COUNT]
GLenum GFXGLBufferType [GFXBufferType_COUNT]
GLenum GFXGLCmpFunc [GFXCmp_COUNT]
GLenum GFXGLCullMode [GFXCull_COUNT]
GLenum GFXGLFillMode [GFXFill_COUNT]
GLenum GFXGLPrimType [GFXPT_COUNT]
GLenum GFXGLSamplerState [GFXSAMP_COUNT]
GLenum GFXGLStencilOp [GFXStencilOp_COUNT]
GLenum GFXGLTextureAddress [GFXAddress_COUNT]
GLenum GFXGLTextureFilter [GFXTextureFilter_COUNT]
GLenum GFXGLTextureFormat [GFXFormat_COUNT]
GLenum GFXGLTextureInternalFormat [GFXFormat_COUNT]
GLint * GFXGLTextureSwizzle [GFXFormat_COUNT]
GLenum GFXGLTextureType [GFXFormat_COUNT]
  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#include "platform/platform.h"
 25#include "gfx/gl/gfxGLEnumTranslate.h"
 26 
 27GLenum GFXGLPrimType[GFXPT_COUNT];
 28GLenum GFXGLBlend[GFXBlend_COUNT];
 29GLenum GFXGLBlendOp[GFXBlendOp_COUNT];
 30GLenum GFXGLSamplerState[GFXSAMP_COUNT];
 31GLenum GFXGLTextureFilter[GFXTextureFilter_COUNT];
 32GLenum GFXGLTextureAddress[GFXAddress_COUNT];
 33GLenum GFXGLCmpFunc[GFXCmp_COUNT];
 34GLenum GFXGLStencilOp[GFXStencilOp_COUNT];
 35GLenum GFXGLTextureInternalFormat[GFXFormat_COUNT];
 36GLenum GFXGLTextureFormat[GFXFormat_COUNT];
 37GLenum GFXGLTextureType[GFXFormat_COUNT];
 38GLint* GFXGLTextureSwizzle[GFXFormat_COUNT];
 39GLenum GFXGLBufferType[GFXBufferType_COUNT];
 40GLenum GFXGLCullMode[GFXCull_COUNT];
 41GLenum GFXGLFillMode[GFXFill_COUNT];
 42
 43void GFXGLEnumTranslate::init()
 44{
 45   // Buffer types
 46   GFXGLBufferType[GFXBufferTypeStatic] = GL_STATIC_DRAW;
 47   GFXGLBufferType[GFXBufferTypeDynamic] = GL_DYNAMIC_DRAW;
 48   GFXGLBufferType[GFXBufferTypeVolatile] = GL_STREAM_DRAW;
 49   GFXGLBufferType[GFXBufferTypeImmutable] = GL_STATIC_DRAW;
 50
 51   // Primitives
 52   GFXGLPrimType[GFXPointList] = GL_POINTS;
 53   GFXGLPrimType[GFXLineList] = GL_LINES;
 54   GFXGLPrimType[GFXLineStrip] = GL_LINE_STRIP;
 55   GFXGLPrimType[GFXTriangleList] = GL_TRIANGLES;
 56   GFXGLPrimType[GFXTriangleStrip] = GL_TRIANGLE_STRIP;
 57
 58   // Blend
 59   GFXGLBlend[GFXBlendZero] = GL_ZERO;
 60   GFXGLBlend[GFXBlendOne] = GL_ONE;
 61   GFXGLBlend[GFXBlendSrcColor] = GL_SRC_COLOR;
 62   GFXGLBlend[GFXBlendInvSrcColor] = GL_ONE_MINUS_SRC_COLOR;
 63   GFXGLBlend[GFXBlendSrcAlpha] = GL_SRC_ALPHA;
 64   GFXGLBlend[GFXBlendInvSrcAlpha] = GL_ONE_MINUS_SRC_ALPHA;
 65   GFXGLBlend[GFXBlendDestAlpha] = GL_DST_ALPHA;
 66   GFXGLBlend[GFXBlendInvDestAlpha] = GL_ONE_MINUS_DST_ALPHA;
 67   GFXGLBlend[GFXBlendDestColor] = GL_DST_COLOR;
 68   GFXGLBlend[GFXBlendInvDestColor] = GL_ONE_MINUS_DST_COLOR;
 69   GFXGLBlend[GFXBlendSrcAlphaSat] = GL_SRC_ALPHA_SATURATE;
 70   
 71   // Blend op
 72   GFXGLBlendOp[GFXBlendOpAdd] = GL_FUNC_ADD;
 73   GFXGLBlendOp[GFXBlendOpSubtract] = GL_FUNC_SUBTRACT;
 74   GFXGLBlendOp[GFXBlendOpRevSubtract] = GL_FUNC_REVERSE_SUBTRACT;
 75   GFXGLBlendOp[GFXBlendOpMin] = GL_MIN;
 76   GFXGLBlendOp[GFXBlendOpMax] = GL_MAX;
 77
 78   // Sampler
 79   GFXGLSamplerState[GFXSAMPMagFilter] = GL_TEXTURE_MAG_FILTER;
 80   GFXGLSamplerState[GFXSAMPMinFilter] = GL_TEXTURE_MIN_FILTER;
 81   GFXGLSamplerState[GFXSAMPAddressU] = GL_TEXTURE_WRAP_S;
 82   GFXGLSamplerState[GFXSAMPAddressV] = GL_TEXTURE_WRAP_T;
 83   GFXGLSamplerState[GFXSAMPAddressW] = GL_TEXTURE_WRAP_R;
 84   GFXGLSamplerState[GFXSAMPMipMapLODBias] = GL_TEXTURE_LOD_BIAS;
 85   
 86   // Comparison
 87   GFXGLCmpFunc[GFXCmpNever] = GL_NEVER;
 88   GFXGLCmpFunc[GFXCmpLess] = GL_LESS;
 89   GFXGLCmpFunc[GFXCmpEqual] = GL_EQUAL;
 90   GFXGLCmpFunc[GFXCmpLessEqual] = GL_LEQUAL;
 91   GFXGLCmpFunc[GFXCmpGreater] = GL_GREATER;
 92   GFXGLCmpFunc[GFXCmpNotEqual] = GL_NOTEQUAL;
 93   GFXGLCmpFunc[GFXCmpGreaterEqual] = GL_GEQUAL;
 94   GFXGLCmpFunc[GFXCmpAlways] = GL_ALWAYS;
 95
 96   GFXGLTextureFilter[GFXTextureFilterNone] = GL_NEAREST;
 97   GFXGLTextureFilter[GFXTextureFilterPoint] = GL_NEAREST;
 98   GFXGLTextureFilter[GFXTextureFilterLinear] = GL_LINEAR;
 99
100   GFXGLTextureFilter[GFXTextureFilterAnisotropic] = GL_LINEAR;
101   GFXGLTextureFilter[GFXTextureFilterPyramidalQuad] = GL_LINEAR; 
102   GFXGLTextureFilter[GFXTextureFilterGaussianQuad] = GL_LINEAR;
103
104   GFXGLTextureAddress[GFXAddressWrap] = GL_REPEAT;
105   GFXGLTextureAddress[GFXAddressMirror] = GL_REPEAT;
106   GFXGLTextureAddress[GFXAddressClamp] = GL_CLAMP_TO_EDGE;
107   GFXGLTextureAddress[GFXAddressBorder] = GL_REPEAT;
108   GFXGLTextureAddress[GFXAddressMirrorOnce] = GL_REPEAT;
109   
110   // Stencil ops
111   GFXGLStencilOp[GFXStencilOpKeep] = GL_KEEP;
112   GFXGLStencilOp[GFXStencilOpZero] = GL_ZERO;
113   GFXGLStencilOp[GFXStencilOpReplace] = GL_REPLACE;
114   GFXGLStencilOp[GFXStencilOpIncrSat] = GL_INCR;
115   GFXGLStencilOp[GFXStencilOpDecrSat] = GL_DECR;
116   GFXGLStencilOp[GFXStencilOpInvert] = GL_INVERT;
117   
118   GFXGLStencilOp[GFXStencilOpIncr] = GL_INCR_WRAP;
119   GFXGLStencilOp[GFXStencilOpDecr] = GL_DECR_WRAP;
120   
121   
122   // Texture formats
123   for(int i = 0; i < GFXFormat_COUNT; ++i)
124   {
125      GFXGLTextureInternalFormat[i] = GL_NONE;
126      GFXGLTextureFormat[i] = GL_NONE;
127      GFXGLTextureType[i] = GL_NONE;
128      GFXGLTextureSwizzle[i] = NULL;
129   }
130
131   GFXGLTextureInternalFormat[GFXFormatA8] = GL_R8;
132   GFXGLTextureInternalFormat[GFXFormatL8] = GL_R8;
133   GFXGLTextureInternalFormat[GFXFormatR5G5B5A1] = GL_RGB5_A1;
134   GFXGLTextureInternalFormat[GFXFormatR5G5B5X1] = GL_RGB5_A1;
135   GFXGLTextureInternalFormat[GFXFormatL16] = GL_R16;
136   GFXGLTextureInternalFormat[GFXFormatD16] = GL_DEPTH_COMPONENT16;
137   GFXGLTextureInternalFormat[GFXFormatR8G8B8] = GL_RGB8;
138   GFXGLTextureInternalFormat[GFXFormatR8G8B8A8] = GL_RGBA8;
139   GFXGLTextureInternalFormat[GFXFormatR8G8B8X8] = GL_RGBA8;
140   GFXGLTextureInternalFormat[GFXFormatB8G8R8A8] = GL_RGBA8;
141   GFXGLTextureInternalFormat[GFXFormatR10G10B10A2] = GL_RGB10_A2;
142   GFXGLTextureInternalFormat[GFXFormatD32] = GL_DEPTH_COMPONENT32;
143   GFXGLTextureInternalFormat[GFXFormatD24X8] = GL_DEPTH24_STENCIL8;
144   GFXGLTextureInternalFormat[GFXFormatD24S8] = GL_DEPTH24_STENCIL8;
145   GFXGLTextureInternalFormat[GFXFormatR16G16B16A16] = GL_RGBA16;
146   GFXGLTextureInternalFormat[GFXFormatDXT1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
147   GFXGLTextureInternalFormat[GFXFormatDXT2] = GL_ZERO;
148   GFXGLTextureInternalFormat[GFXFormatDXT3] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
149   GFXGLTextureInternalFormat[GFXFormatDXT4] = GL_ZERO;
150   GFXGLTextureInternalFormat[GFXFormatDXT5] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
151   
152   GFXGLTextureFormat[GFXFormatA8] = GL_RED;
153   GFXGLTextureFormat[GFXFormatL8] = GL_RED;
154   GFXGLTextureFormat[GFXFormatR5G5B5A1] = GL_RGBA;
155   GFXGLTextureFormat[GFXFormatR5G5B5X1] = GL_RGBA;
156   GFXGLTextureFormat[GFXFormatL16] = GL_RED;
157   GFXGLTextureFormat[GFXFormatD16] = GL_DEPTH_COMPONENT;
158   GFXGLTextureFormat[GFXFormatR8G8B8] = GL_RGB;
159   GFXGLTextureFormat[GFXFormatR8G8B8A8] = GL_RGBA;
160   GFXGLTextureFormat[GFXFormatR8G8B8X8] = GL_RGBA;
161   GFXGLTextureFormat[GFXFormatB8G8R8A8] = GL_BGRA;
162   GFXGLTextureFormat[GFXFormatR10G10B10A2] = GL_RGBA;
163   GFXGLTextureFormat[GFXFormatD32] = GL_DEPTH_COMPONENT;
164   GFXGLTextureFormat[GFXFormatD24X8] = GL_DEPTH_STENCIL;
165   GFXGLTextureFormat[GFXFormatD24S8] = GL_DEPTH_STENCIL;
166   GFXGLTextureFormat[GFXFormatR16G16B16A16] = GL_RGBA;
167   GFXGLTextureFormat[GFXFormatDXT1] = GL_RGBA;
168   GFXGLTextureFormat[GFXFormatDXT2] = GL_ZERO;
169   GFXGLTextureFormat[GFXFormatDXT3] = GL_RGBA;
170   GFXGLTextureFormat[GFXFormatDXT4] = GL_ZERO;
171   GFXGLTextureFormat[GFXFormatDXT5] = GL_RGBA;
172   
173   GFXGLTextureType[GFXFormatA8] = GL_UNSIGNED_BYTE;
174   GFXGLTextureType[GFXFormatL8] = GL_UNSIGNED_BYTE;
175   GFXGLTextureType[GFXFormatR5G5B5A1] = GL_UNSIGNED_SHORT_5_5_5_1;
176   GFXGLTextureType[GFXFormatR5G5B5X1] = GL_UNSIGNED_SHORT_5_5_5_1;
177   GFXGLTextureType[GFXFormatL16] = GL_UNSIGNED_SHORT;
178   GFXGLTextureType[GFXFormatD16] = GL_UNSIGNED_SHORT;
179   GFXGLTextureType[GFXFormatR8G8B8] = GL_UNSIGNED_BYTE;
180   GFXGLTextureType[GFXFormatR8G8B8A8] = GL_UNSIGNED_BYTE;
181   GFXGLTextureType[GFXFormatR8G8B8X8] = GL_UNSIGNED_BYTE;
182   GFXGLTextureType[GFXFormatB8G8R8A8] = GL_UNSIGNED_BYTE;;
183   GFXGLTextureType[GFXFormatR10G10B10A2] = GL_UNSIGNED_INT_10_10_10_2;
184   GFXGLTextureType[GFXFormatD32] = GL_UNSIGNED_INT;
185   GFXGLTextureType[GFXFormatD24X8] = GL_UNSIGNED_INT_24_8;
186   GFXGLTextureType[GFXFormatD24S8] = GL_UNSIGNED_INT_24_8;
187   GFXGLTextureType[GFXFormatR16G16B16A16] = GL_UNSIGNED_SHORT;
188   GFXGLTextureType[GFXFormatDXT1] = GL_UNSIGNED_BYTE;
189   GFXGLTextureType[GFXFormatDXT2] = GL_ZERO;
190   GFXGLTextureType[GFXFormatDXT3] = GL_UNSIGNED_BYTE;
191   GFXGLTextureType[GFXFormatDXT4] = GL_ZERO;
192   GFXGLTextureType[GFXFormatDXT5] = GL_UNSIGNED_BYTE;
193
194   GFXGLTextureType[GFXFormatR8G8B8A8_SRGB] = GL_SRGB8_ALPHA8;
195
196   static GLint Swizzle_GFXFormatA8[] = { GL_NONE, GL_NONE, GL_NONE, GL_RED };
197   static GLint Swizzle_GFXFormatL[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA };
198   GFXGLTextureSwizzle[GFXFormatA8] = Swizzle_GFXFormatA8; // old GL_ALPHA8   
199   GFXGLTextureSwizzle[GFXFormatL8] = Swizzle_GFXFormatL; // old GL_LUMINANCE8
200   GFXGLTextureSwizzle[GFXFormatL16] = Swizzle_GFXFormatL; // old GL_LUMINANCE16
201
202   GFXGLTextureInternalFormat[GFXFormatR32F] = GL_R32F;
203   GFXGLTextureFormat[GFXFormatR32F] = GL_RED;
204   GFXGLTextureType[GFXFormatR32F] = GL_FLOAT;
205
206   GFXGLTextureInternalFormat[GFXFormatR32G32B32A32F] = GL_RGBA32F_ARB;
207   GFXGLTextureFormat[GFXFormatR32G32B32A32F] = GL_RGBA;
208   GFXGLTextureType[GFXFormatR32G32B32A32F] = GL_FLOAT;
209
210   GFXGLTextureInternalFormat[GFXFormatR16F] = GL_R16F;
211   GFXGLTextureFormat[GFXFormatR16F] = GL_RED;
212   GFXGLTextureType[GFXFormatR16F] = GL_HALF_FLOAT_ARB;
213
214   GFXGLTextureInternalFormat[GFXFormatR16G16F] = GL_RG16F;
215   GFXGLTextureFormat[GFXFormatR16G16F] = GL_RG;
216   GFXGLTextureType[GFXFormatR16G16F] = GL_HALF_FLOAT_ARB;
217
218   GFXGLTextureInternalFormat[GFXFormatR16G16B16A16F] = GL_RGBA16F_ARB;
219   GFXGLTextureFormat[GFXFormatR16G16B16A16F] = GL_RGBA;
220   GFXGLTextureType[GFXFormatR16G16B16A16F] = GL_HALF_FLOAT_ARB;
221
222   if( gglHasExtension(ARB_ES2_compatibility) )
223   {
224      GFXGLTextureInternalFormat[GFXFormatR5G6B5] = GL_RGB5_A1;
225      GFXGLTextureFormat[GFXFormatR5G6B5] = GL_RGBA;
226      GFXGLTextureType[GFXFormatR5G6B5] = GL_UNSIGNED_SHORT_5_5_5_1;
227   }
228   else
229   {
230      GFXGLTextureInternalFormat[GFXFormatR5G6B5] = GL_RGB565;
231      GFXGLTextureFormat[GFXFormatR5G6B5] = GL_RGB;
232      GFXGLTextureType[GFXFormatR5G6B5] = GL_UNSIGNED_SHORT_5_6_5;
233   }
234
235   if( gglHasExtension(ARB_texture_rg) )
236   {
237      GFXGLTextureInternalFormat[GFXFormatR16G16] = GL_RG16;
238      GFXGLTextureFormat[GFXFormatR16G16] = GL_RG;
239      GFXGLTextureType[GFXFormatR16G16] = GL_UNSIGNED_SHORT;
240   }
241   else
242   {
243      GFXGLTextureInternalFormat[GFXFormatR16G16] = GL_RGBA16;
244      GFXGLTextureFormat[GFXFormatR16G16] = GL_RGBA;
245      GFXGLTextureType[GFXFormatR16G16] = GL_UNSIGNED_SHORT;
246   }
247
248   // Cull - Opengl render upside down need to invert cull
249   GFXGLCullMode[GFXCullNone] = GL_FRONT;
250   GFXGLCullMode[GFXCullCW] = GL_FRONT;
251   GFXGLCullMode[GFXCullCCW] = GL_BACK;
252
253   // Fill
254   GFXGLFillMode[GFXFillPoint] = GL_POINT;
255   GFXGLFillMode[GFXFillWireframe] = GL_LINE;
256   GFXGLFillMode[GFXFillSolid] = GL_FILL;
257}
258