Changeset 1225


Ignore:
Timestamp:
Apr 14, 2012, 12:03:12 PM (8 years ago)
Author:
sam
Message:

gpu: fix compilation errors and warnings in the vertex declaration code.

Location:
trunk/src/gpu
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gpu/vertexbuffer.cpp

    r1224 r1225  
    2121{
    2222
     23/* For some reason defining this in the .h leads to duplicate definitions
     24 * between the executable and the static library. */
     25template<> void VertexBuffer::AddStream<void>(int n, int index)
     26{
     27    (void)index;
     28    m_streams[n].size = 0;
     29}
     30
    2331void VertexBuffer::Initialize()
    2432{
    2533#if defined _XBOX || defined USE_D3D9
    2634   
    27 #endif   
     35#endif
    2836}
    2937
  • trunk/src/gpu/vertexbuffer.h

    r1224 r1225  
    1010
    1111//
    12 // The GpuVbo class
    13 // ----------------
     12// The VertexBuffer class
     13// ----------------------
    1414//
    1515
     
    1717#define __LOL_VERTEXBUFFER_H__
    1818
     19#include <cstring>
     20
    1921namespace lol
    2022{
     23
     24#if 0
     25VertexBuffer(0, LOL_TYPE_VEC2 | LOL_USAGE_TEXTURE(0),
     26                LOL_TYPE_FLOAT | LOL_USAGE_POSITION(0),
     27             1, LOL_TYPE_FLOAT | LOL_USAGE_TEXCOORD(0),
     28             2, LOL_TYPE_FLOAT | LOL_USAGE_TEXCOORD(1));
     29
     30VertexBuffer(VertexStream<vec2, LOL_USAGE_TEXTURE(0)
     31                          float, Texture(
     32#endif
    2133
    2234class VertexBuffer
     
    3648    VertexBuffer() {}
    3749
    38     enum StreamType
     50    enum
    3951    {
    40         VBO_TYPE_VOID,
     52        VBO_TYPE_VOID = 0,
    4153        VBO_TYPE_FLOAT,
    4254        VBO_TYPE_VEC2,
     
    4759    };
    4860
    49     template<typename T> static StreamType GetType();
     61    static uint8_t GetType(void *x) { (void)x; return VBO_TYPE_VOID; }
     62    static uint8_t GetType(float *x) { (void)x; return VBO_TYPE_FLOAT; }
     63    static uint8_t GetType(vec2 *x) { (void)x; return VBO_TYPE_VEC2; }
     64    static uint8_t GetType(vec3 *x) { (void)x; return VBO_TYPE_VEC3; }
     65    static uint8_t GetType(vec4 *x) { (void)x; return VBO_TYPE_VEC4; }
     66    static uint8_t GetType(i16vec4 *x) { (void)x; return VBO_TYPE_I16VEC4; }
     67    static uint8_t GetType(u8vec4 *x) { (void)x; return VBO_TYPE_U8VEC4; }
    5068
    51     struct { StreamType stream_type; int index; } m_streams[12 + 1];
     69    struct { uint8_t stream_type, index, size; } m_streams[12 + 1];
     70
     71    template<typename T> void AddStream(int n, int index)
     72    {
     73        m_streams[n].stream_type = GetType((T *)NULL);
     74        m_streams[n].index = index;
     75        m_streams[n].size = sizeof(T);
     76    }
    5277
    5378private:
     
    5580};
    5681
    57 template<> VertexBuffer::StreamType VertexBuffer::GetType<void>() { return VBO_TYPE_VOID; }
    58 template<> VertexBuffer::StreamType VertexBuffer::GetType<float>() { return VBO_TYPE_FLOAT; }
    59 template<> VertexBuffer::StreamType VertexBuffer::GetType<vec2>() { return VBO_TYPE_VEC2; }
    60 template<> VertexBuffer::StreamType VertexBuffer::GetType<vec3>() { return VBO_TYPE_VEC3; }
    61 template<> VertexBuffer::StreamType VertexBuffer::GetType<vec4>() { return VBO_TYPE_VEC4; }
    62 template<> VertexBuffer::StreamType VertexBuffer::GetType<i16vec4>() { return VBO_TYPE_I16VEC4; }
    63 template<> VertexBuffer::StreamType VertexBuffer::GetType<u8vec4>() { return VBO_TYPE_U8VEC4; }
     82template<> void VertexBuffer::AddStream<void>(int n, int index);
    6483
    6584template<typename T1 = void,  typename T2 = void,  typename T3 = void,
     
    86105
    87106private:
    88     template<typename T> void AddStream(int index, int stream)
    89     {
    90         m_streams[index].stream_type = GetType<T>();
    91         m_streams[index].index = index;
    92     }
    93107};
    94108
Note: See TracChangeset for help on using the changeset viewer.