From 3ab2f621f8510259ff0da6c385413f3d52539d81 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 14 Apr 2012 10:03:12 +0000 Subject: [PATCH] gpu: fix compilation errors and warnings in the vertex declaration code. --- src/gpu/vertexbuffer.cpp | 10 +++++++- src/gpu/vertexbuffer.h | 50 +++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index 8a8156ab..7797c403 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -20,11 +20,19 @@ using namespace std; namespace lol { +/* For some reason defining this in the .h leads to duplicate definitions + * between the executable and the static library. */ +template<> void VertexBuffer::AddStream(int n, int index) +{ + (void)index; + m_streams[n].size = 0; +} + void VertexBuffer::Initialize() { #if defined _XBOX || defined USE_D3D9 -#endif +#endif } } /* namespace lol */ diff --git a/src/gpu/vertexbuffer.h b/src/gpu/vertexbuffer.h index ba954407..45debf65 100644 --- a/src/gpu/vertexbuffer.h +++ b/src/gpu/vertexbuffer.h @@ -9,16 +9,28 @@ // // -// The GpuVbo class -// ---------------- +// The VertexBuffer class +// ---------------------- // #if !defined __LOL_VERTEXBUFFER_H__ #define __LOL_VERTEXBUFFER_H__ +#include + namespace lol { +#if 0 +VertexBuffer(0, LOL_TYPE_VEC2 | LOL_USAGE_TEXTURE(0), + LOL_TYPE_FLOAT | LOL_USAGE_POSITION(0), + 1, LOL_TYPE_FLOAT | LOL_USAGE_TEXCOORD(0), + 2, LOL_TYPE_FLOAT | LOL_USAGE_TEXCOORD(1)); + +VertexBuffer(VertexStream static StreamType GetType(); + static uint8_t GetType(void *x) { (void)x; return VBO_TYPE_VOID; } + static uint8_t GetType(float *x) { (void)x; return VBO_TYPE_FLOAT; } + static uint8_t GetType(vec2 *x) { (void)x; return VBO_TYPE_VEC2; } + static uint8_t GetType(vec3 *x) { (void)x; return VBO_TYPE_VEC3; } + static uint8_t GetType(vec4 *x) { (void)x; return VBO_TYPE_VEC4; } + static uint8_t GetType(i16vec4 *x) { (void)x; return VBO_TYPE_I16VEC4; } + static uint8_t GetType(u8vec4 *x) { (void)x; return VBO_TYPE_U8VEC4; } + + struct { uint8_t stream_type, index, size; } m_streams[12 + 1]; - struct { StreamType stream_type; int index; } m_streams[12 + 1]; + template void AddStream(int n, int index) + { + m_streams[n].stream_type = GetType((T *)NULL); + m_streams[n].index = index; + m_streams[n].size = sizeof(T); + } private: void Initialize(); }; -template<> VertexBuffer::StreamType VertexBuffer::GetType() { return VBO_TYPE_VOID; } -template<> VertexBuffer::StreamType VertexBuffer::GetType() { return VBO_TYPE_FLOAT; } -template<> VertexBuffer::StreamType VertexBuffer::GetType() { return VBO_TYPE_VEC2; } -template<> VertexBuffer::StreamType VertexBuffer::GetType() { return VBO_TYPE_VEC3; } -template<> VertexBuffer::StreamType VertexBuffer::GetType() { return VBO_TYPE_VEC4; } -template<> VertexBuffer::StreamType VertexBuffer::GetType() { return VBO_TYPE_I16VEC4; } -template<> VertexBuffer::StreamType VertexBuffer::GetType() { return VBO_TYPE_U8VEC4; } +template<> void VertexBuffer::AddStream(int n, int index); template void AddStream(int index, int stream) - { - m_streams[index].stream_type = GetType(); - m_streams[index].index = index; - } }; } /* namespace lol */