| @@ -21,6 +21,90 @@ | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| /* A safe enum to indicate how a vertex stream is going to be used. For | |||||
| * now there is only TexCoord and not TexCoord0 TexCoord1 etc. because | |||||
| * we can always reorganise the vertex declaration for the indices to | |||||
| * match. If the need arises these enums will be added. */ | |||||
| struct VertexUsage | |||||
| { | |||||
| enum Value | |||||
| { | |||||
| Position = 0, | |||||
| BlendWeight, | |||||
| BlendIndices, | |||||
| Normal, | |||||
| PointSize, | |||||
| TexCoord, | |||||
| TexCoordExt, | |||||
| Tangent, | |||||
| Binormal, | |||||
| TessFactor, | |||||
| PositionT, | |||||
| Color, | |||||
| Fog, | |||||
| Depth, | |||||
| Sample, | |||||
| Max | |||||
| } | |||||
| m_value; | |||||
| private: | |||||
| static String GetName(Value v, bool use_simple) | |||||
| { | |||||
| String tmp = String(""); | |||||
| if (!use_simple) tmp += "<"; | |||||
| switch (v) | |||||
| { | |||||
| case Position: { tmp += "Position"; break; } | |||||
| case BlendWeight: { tmp += "BlendWeight"; break; } | |||||
| case BlendIndices: { tmp += "BlendIndices";break; } | |||||
| case Normal: { tmp += "Normal"; break; } | |||||
| case PointSize: { tmp += "PointSize"; break; } | |||||
| case TexCoord: { tmp += "TexCoord"; break; } | |||||
| case TexCoordExt: { tmp += "TexCoordExt"; break; } | |||||
| case Tangent: { tmp += "Tangent"; break; } | |||||
| case Binormal: { tmp += "Binormal"; break; } | |||||
| case TessFactor: { tmp += "TessFactor"; break; } | |||||
| case PositionT: { tmp += "PositionT"; break; } | |||||
| case Color: { tmp += "Color"; break; } | |||||
| case Fog: { tmp += "Fog"; break; } | |||||
| case Depth: { tmp += "Depth"; break; } | |||||
| case Sample: { tmp += "Sample"; break; } | |||||
| default: { tmp += "UNDEFINED"; break; } | |||||
| } | |||||
| if (!use_simple) tmp += ">"; | |||||
| return tmp; | |||||
| } | |||||
| public: | |||||
| static String GetName(Value v) | |||||
| { | |||||
| return GetName(v, false); | |||||
| } | |||||
| static String GetNameList(uint32_t v) | |||||
| { | |||||
| String tmp = String("<"); | |||||
| int nb = 0; | |||||
| for (int i = 0; i < Max; ++i) | |||||
| { | |||||
| if (v & (1<<i)) | |||||
| { | |||||
| if (nb != 0) | |||||
| tmp += ", "; | |||||
| tmp += GetName(Value(i), true); | |||||
| ++nb; | |||||
| } | |||||
| } | |||||
| return tmp + ">"; | |||||
| } | |||||
| inline VertexUsage(Value v) : m_value(v) {} | |||||
| inline VertexUsage(int v) : m_value((Value)v) {} | |||||
| inline operator Value() { return m_value; } | |||||
| }; | |||||
| struct ShaderUniform | struct ShaderUniform | ||||
| { | { | ||||
| friend class Shader; | friend class Shader; | ||||
| @@ -41,6 +125,9 @@ struct ShaderAttrib | |||||
| public: | public: | ||||
| inline ShaderAttrib() : m_flags((uint64_t)0 - 1) {} | inline ShaderAttrib() : m_flags((uint64_t)0 - 1) {} | ||||
| inline bool IsValid() { return m_flags != (uint64_t)0 - 1; } | |||||
| inline VertexUsage GetUsage() { return VertexUsage((int)(m_flags >> 16) & 0xffff); } | |||||
| inline int GetIndex() { return (int)(m_flags & 0xffff); } | |||||
| private: | private: | ||||
| uint64_t m_flags; | uint64_t m_flags; | ||||
| @@ -38,90 +38,6 @@ private: | |||||
| class VertexBufferData *m_data; | class VertexBufferData *m_data; | ||||
| }; | }; | ||||
| /* A safe enum to indicate how a vertex stream is going to be used. For | |||||
| * now there is only TexCoord and not TexCoord0 TexCoord1 etc. because | |||||
| * we can always reorganise the vertex declaration for the indices to | |||||
| * match. If the need arises these enums will be added. */ | |||||
| struct VertexUsage | |||||
| { | |||||
| enum Value | |||||
| { | |||||
| Position = 0, | |||||
| BlendWeight, | |||||
| BlendIndices, | |||||
| Normal, | |||||
| PointSize, | |||||
| TexCoord, | |||||
| TexCoordExt, | |||||
| Tangent, | |||||
| Binormal, | |||||
| TessFactor, | |||||
| PositionT, | |||||
| Color, | |||||
| Fog, | |||||
| Depth, | |||||
| Sample, | |||||
| Max | |||||
| } | |||||
| m_value; | |||||
| private: | |||||
| static String GetName(Value v, bool use_simple) | |||||
| { | |||||
| String tmp = String(""); | |||||
| if (!use_simple) tmp += "<"; | |||||
| switch (v) | |||||
| { | |||||
| case Position: { tmp += "Position"; break; } | |||||
| case BlendWeight: { tmp += "BlendWeight"; break; } | |||||
| case BlendIndices: { tmp += "BlendIndices";break; } | |||||
| case Normal: { tmp += "Normal"; break; } | |||||
| case PointSize: { tmp += "PointSize"; break; } | |||||
| case TexCoord: { tmp += "TexCoord"; break; } | |||||
| case TexCoordExt: { tmp += "TexCoordExt"; break; } | |||||
| case Tangent: { tmp += "Tangent"; break; } | |||||
| case Binormal: { tmp += "Binormal"; break; } | |||||
| case TessFactor: { tmp += "TessFactor"; break; } | |||||
| case PositionT: { tmp += "PositionT"; break; } | |||||
| case Color: { tmp += "Color"; break; } | |||||
| case Fog: { tmp += "Fog"; break; } | |||||
| case Depth: { tmp += "Depth"; break; } | |||||
| case Sample: { tmp += "Sample"; break; } | |||||
| default: { tmp += "UNDEFINED"; break; } | |||||
| } | |||||
| if (!use_simple) tmp += ">"; | |||||
| return tmp; | |||||
| } | |||||
| public: | |||||
| static String GetName(Value v) | |||||
| { | |||||
| return GetName(v, false); | |||||
| } | |||||
| static String GetNameList(uint32_t v) | |||||
| { | |||||
| String tmp = String("<"); | |||||
| int nb = 0; | |||||
| for (int i = 0; i < Max; ++i) | |||||
| { | |||||
| if (v & (1<<i)) | |||||
| { | |||||
| if (nb != 0) | |||||
| tmp += ", "; | |||||
| tmp += GetName(Value(i), true); | |||||
| ++nb; | |||||
| } | |||||
| } | |||||
| return tmp + ">"; | |||||
| } | |||||
| inline VertexUsage(Value v) : m_value(v) {} | |||||
| inline VertexUsage(int v) : m_value((Value)v) {} | |||||
| inline operator Value() { return m_value; } | |||||
| }; | |||||
| /* A safe enum to indicate what kind of primitive to draw. Used in | /* A safe enum to indicate what kind of primitive to draw. Used in | ||||
| * VertexDeclaration::DrawElements() for instance. */ | * VertexDeclaration::DrawElements() for instance. */ | ||||
| struct MeshPrimitive | struct MeshPrimitive | ||||