|
| 1 | +/* |
| 2 | +=========================================================================== |
| 3 | +Copyright (C) 1999-2005 Id Software, Inc. |
| 4 | +Copyright (C) 2006-2011 Robert Beckebans <[email protected]> |
| 5 | +
|
| 6 | +This file is part of Daemon source code. |
| 7 | +
|
| 8 | +Daemon source code is free software; you can redistribute it |
| 9 | +and/or modify it under the terms of the GNU General Public License as |
| 10 | +published by the Free Software Foundation; either version 2 of the License, |
| 11 | +or (at your option) any later version. |
| 12 | +
|
| 13 | +Daemon source code is distributed in the hope that it will be |
| 14 | +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +GNU General Public License for more details. |
| 17 | +
|
| 18 | +You should have received a copy of the GNU General Public License |
| 19 | +along with Daemon source code; if not, write to the Free Software |
| 20 | +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | +=========================================================================== |
| 22 | +*/ |
| 23 | +// VertexSpecification.h |
| 24 | + |
| 25 | +#ifndef VERTEX_SPECIFICATION_H |
| 26 | +#define VERTEX_SPECIFICATION_H |
| 27 | + |
| 28 | +#include "common/Common.h" |
| 29 | +#include "GL/glew.h" |
| 30 | + |
| 31 | +enum |
| 32 | +{ |
| 33 | + ATTR_INDEX_POSITION = 0, |
| 34 | + ATTR_INDEX_TEXCOORD, // TODO split into 2-element texcoords and 4-element tex + lm coords |
| 35 | + ATTR_INDEX_QTANGENT, |
| 36 | + ATTR_INDEX_COLOR, |
| 37 | + |
| 38 | + // GPU vertex skinning |
| 39 | + ATTR_INDEX_BONE_FACTORS, |
| 40 | + |
| 41 | + // GPU vertex animations |
| 42 | + ATTR_INDEX_POSITION2, |
| 43 | + ATTR_INDEX_QTANGENT2, |
| 44 | + ATTR_INDEX_MAX |
| 45 | +}; |
| 46 | + |
| 47 | +// must match order of ATTR_INDEX enums |
| 48 | +static const char* const attributeNames[] = |
| 49 | +{ |
| 50 | + "attr_Position", |
| 51 | + "attr_TexCoord0", |
| 52 | + "attr_QTangent", |
| 53 | + "attr_Color", |
| 54 | + "attr_BoneFactors", |
| 55 | + "attr_Position2", |
| 56 | + "attr_QTangent2" |
| 57 | +}; |
| 58 | + |
| 59 | +enum |
| 60 | +{ |
| 61 | + ATTR_POSITION = BIT( ATTR_INDEX_POSITION ), |
| 62 | + ATTR_TEXCOORD = BIT( ATTR_INDEX_TEXCOORD ), |
| 63 | + ATTR_QTANGENT = BIT( ATTR_INDEX_QTANGENT ), |
| 64 | + ATTR_COLOR = BIT( ATTR_INDEX_COLOR ), |
| 65 | + |
| 66 | + ATTR_BONE_FACTORS = BIT( ATTR_INDEX_BONE_FACTORS ), |
| 67 | + |
| 68 | + // for .md3 interpolation |
| 69 | + ATTR_POSITION2 = BIT( ATTR_INDEX_POSITION2 ), |
| 70 | + ATTR_QTANGENT2 = BIT( ATTR_INDEX_QTANGENT2 ), |
| 71 | + |
| 72 | + ATTR_INTERP_BITS = ATTR_POSITION2 | ATTR_QTANGENT2, |
| 73 | +}; |
| 74 | + |
| 75 | +struct vboAttributeLayout_t |
| 76 | +{ |
| 77 | + GLint numComponents; // how many components in a single attribute for a single vertex |
| 78 | + GLenum componentType; // the input type for a single component |
| 79 | + GLboolean normalize; // convert signed integers to the floating point range [-1, 1], and unsigned integers to the range [0, 1] |
| 80 | + GLsizei stride; |
| 81 | + GLsizei ofs; |
| 82 | + GLsizei frameOffset; // for vertex animation, real offset computed as ofs + frame * frameOffset |
| 83 | +}; |
| 84 | + |
| 85 | +enum class vboLayout_t |
| 86 | +{ |
| 87 | + VBO_LAYOUT_CUSTOM, |
| 88 | + VBO_LAYOUT_STATIC, |
| 89 | +}; |
| 90 | + |
| 91 | +enum |
| 92 | +{ |
| 93 | + ATTR_OPTION_NORMALIZE = BIT( 0 ), |
| 94 | + ATTR_OPTION_HAS_FRAMES = BIT( 1 ), |
| 95 | +}; |
| 96 | + |
| 97 | +struct vertexAttributeSpec_t |
| 98 | +{ |
| 99 | + int attrIndex; |
| 100 | + GLenum componentInputType; |
| 101 | + GLenum componentStorageType; |
| 102 | + const void* begin; |
| 103 | + uint32_t numComponents; |
| 104 | + uint32_t stride; |
| 105 | + int attrOptions; |
| 106 | +}; |
| 107 | + |
| 108 | +uint32_t R_ComponentSize( GLenum type ); |
| 109 | + |
| 110 | +#endif // VERTEX_SPECIFICATION_H |
0 commit comments