@@ -30,6 +30,7 @@ liblol_a_SOURCES = \ | |||||
\ | \ | ||||
gpu/shader.cpp gpu/shader.h \ | gpu/shader.cpp gpu/shader.h \ | ||||
gpu/vbo.cpp gpu/vbo.h \ | gpu/vbo.cpp gpu/vbo.h \ | ||||
gpu/vertexbuffer.cpp gpu/vertexbuffer.h \ | |||||
\ | \ | ||||
image/image.cpp image/image.h image/image-private.h \ | image/image.cpp image/image.h image/image-private.h \ | ||||
image/codec/gdiplus-image.cpp \ | image/codec/gdiplus-image.cpp \ | ||||
@@ -99,6 +99,7 @@ static inline int isnan(float f) | |||||
#include "layer.h" | #include "layer.h" | ||||
#include "gpu/shader.h" | #include "gpu/shader.h" | ||||
#include "gpu/vbo.h" | #include "gpu/vbo.h" | ||||
#include "gpu/vertexbuffer.h" | |||||
#include "image/image.h" | #include "image/image.h" | ||||
#include "application/application.h" | #include "application/application.h" | ||||
@@ -0,0 +1,31 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include "core.h" | |||||
#include "lolgl.h" | |||||
using namespace std; | |||||
namespace lol | |||||
{ | |||||
void VertexBuffer::Initialize() | |||||
{ | |||||
#if defined _XBOX || defined USE_D3D9 | |||||
#endif | |||||
} | |||||
} /* namespace lol */ | |||||
@@ -0,0 +1,98 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
// | |||||
// The GpuVbo class | |||||
// ---------------- | |||||
// | |||||
#if !defined __LOL_VERTEXBUFFER_H__ | |||||
#define __LOL_VERTEXBUFFER_H__ | |||||
namespace lol | |||||
{ | |||||
class VertexBuffer | |||||
{ | |||||
public: | |||||
VertexBuffer(VertexBuffer const& that) | |||||
{ | |||||
memcpy(this, &that, sizeof(*this)); | |||||
/* Now call the platform-specific initialisation code */ | |||||
Initialize(); | |||||
} | |||||
~VertexBuffer() {} | |||||
protected: | |||||
VertexBuffer() {} | |||||
enum StreamType | |||||
{ | |||||
VBO_TYPE_VOID, | |||||
VBO_TYPE_FLOAT, | |||||
VBO_TYPE_VEC2, | |||||
VBO_TYPE_VEC3, | |||||
VBO_TYPE_VEC4, | |||||
VBO_TYPE_I16VEC4, | |||||
VBO_TYPE_U8VEC4, | |||||
}; | |||||
template<typename T> static StreamType GetType(); | |||||
struct { StreamType stream_type; int index; } m_streams[12 + 1]; | |||||
private: | |||||
void Initialize(); | |||||
}; | |||||
template<> VertexBuffer::StreamType VertexBuffer::GetType<void>() { return VBO_TYPE_VOID; } | |||||
template<> VertexBuffer::StreamType VertexBuffer::GetType<float>() { return VBO_TYPE_FLOAT; } | |||||
template<> VertexBuffer::StreamType VertexBuffer::GetType<vec2>() { return VBO_TYPE_VEC2; } | |||||
template<> VertexBuffer::StreamType VertexBuffer::GetType<vec3>() { return VBO_TYPE_VEC3; } | |||||
template<> VertexBuffer::StreamType VertexBuffer::GetType<vec4>() { return VBO_TYPE_VEC4; } | |||||
template<> VertexBuffer::StreamType VertexBuffer::GetType<i16vec4>() { return VBO_TYPE_I16VEC4; } | |||||
template<> VertexBuffer::StreamType VertexBuffer::GetType<u8vec4>() { return VBO_TYPE_U8VEC4; } | |||||
template<typename T1 = void, typename T2 = void, typename T3 = void, | |||||
typename T4 = void, typename T5 = void, typename T6 = void, | |||||
typename T7 = void, typename T8 = void, typename T9 = void, | |||||
typename T10 = void, typename T11 = void, typename T12 = void> | |||||
class VertexDeclaration : public VertexBuffer | |||||
{ | |||||
public: | |||||
/* Arguments are the stream index; default to zero */ | |||||
VertexDeclaration(int s1 = 0, int s2 = 0, int s3 = 0, | |||||
int s4 = 0, int s5 = 0, int s6 = 0, | |||||
int s7 = 0, int s8 = 0, int s9 = 0, | |||||
int s10 = 0, int s11 = 0, int s12 = 0) | |||||
{ | |||||
for (int i = 0; i < 12 + 1; i++) | |||||
m_streams[i].stream_type = VBO_TYPE_VOID; | |||||
AddStream<T1>(0, s1); AddStream<T2>(1, s2); AddStream<T3>(2, s3); | |||||
AddStream<T4>(3, s4); AddStream<T5>(4, s5); AddStream<T6>(5, s6); | |||||
AddStream<T7>(6, s7); AddStream<T8>(7, s8); AddStream<T9>(8, s9); | |||||
AddStream<T10>(9, s10); AddStream<T11>(10, s11); AddStream<T12>(11, s12); | |||||
} | |||||
private: | |||||
template<typename T> void AddStream(int index, int stream) | |||||
{ | |||||
m_streams[index].stream_type = GetType<T>(); | |||||
m_streams[index].index = index; | |||||
} | |||||
}; | |||||
} /* namespace lol */ | |||||
#endif // __LOL_VERTEXBUFFER_H__ | |||||
@@ -61,6 +61,22 @@ public: | |||||
if (!m_ready) | if (!m_ready) | ||||
{ | { | ||||
VertexBuffer vb(VertexDeclaration<vec2, float, ivec3>(0, 0, 1)); | |||||
m_shader = Shader::Create( | m_shader = Shader::Create( | ||||
#if !defined __CELLOS_LV2__ && !defined _XBOX && !defined USE_D3D9 | #if !defined __CELLOS_LV2__ && !defined _XBOX && !defined USE_D3D9 | ||||
"#version 120\n" | "#version 120\n" | ||||
@@ -87,6 +87,7 @@ | |||||
<ClCompile Include="..\src\forge.cpp" /> | <ClCompile Include="..\src\forge.cpp" /> | ||||
<ClCompile Include="..\src\gpu\shader.cpp" /> | <ClCompile Include="..\src\gpu\shader.cpp" /> | ||||
<ClCompile Include="..\src\gpu\vbo.cpp" /> | <ClCompile Include="..\src\gpu\vbo.cpp" /> | ||||
<ClCompile Include="..\src\gpu\vertexbuffer.cpp" /> | |||||
<ClCompile Include="..\src\gradient.cpp" /> | <ClCompile Include="..\src\gradient.cpp" /> | ||||
<ClCompile Include="..\src\hash.cpp" /> | <ClCompile Include="..\src\hash.cpp" /> | ||||
<ClCompile Include="..\src\image\codec\android-image.cpp" /> | <ClCompile Include="..\src\image\codec\android-image.cpp" /> | ||||
@@ -140,6 +141,7 @@ | |||||
<ClInclude Include="..\src\forge.h" /> | <ClInclude Include="..\src\forge.h" /> | ||||
<ClInclude Include="..\src\gpu\shader.h" /> | <ClInclude Include="..\src\gpu\shader.h" /> | ||||
<ClInclude Include="..\src\gpu\vbo.h" /> | <ClInclude Include="..\src\gpu\vbo.h" /> | ||||
<ClInclude Include="..\src\gpu\vertexbuffer.h" /> | |||||
<ClInclude Include="..\src\gradient.h" /> | <ClInclude Include="..\src\gradient.h" /> | ||||
<ClInclude Include="..\src\hash.h" /> | <ClInclude Include="..\src\hash.h" /> | ||||
<ClInclude Include="..\src\image\image-private.h" /> | <ClInclude Include="..\src\image\image-private.h" /> | ||||
@@ -166,6 +166,9 @@ | |||||
<ClCompile Include="..\src\gpu\vbo.cpp"> | <ClCompile Include="..\src\gpu\vbo.cpp"> | ||||
<Filter>src\gpu</Filter> | <Filter>src\gpu</Filter> | ||||
</ClCompile> | </ClCompile> | ||||
<ClCompile Include="..\src\gpu\vertexbuffer.cpp"> | |||||
<Filter>src\gpu</Filter> | |||||
</ClCompile> | |||||
<ClCompile Include="..\src\application\application.cpp"> | <ClCompile Include="..\src\application\application.cpp"> | ||||
<Filter>src\application</Filter> | <Filter>src\application</Filter> | ||||
</ClCompile> | </ClCompile> | ||||
@@ -339,6 +342,9 @@ | |||||
<ClInclude Include="..\src\gpu\vbo.h"> | <ClInclude Include="..\src\gpu\vbo.h"> | ||||
<Filter>src\gpu</Filter> | <Filter>src\gpu</Filter> | ||||
</ClInclude> | </ClInclude> | ||||
<ClInclude Include="..\src\gpu\vertexbuffer.h"> | |||||
<Filter>src\gpu</Filter> | |||||
</ClInclude> | |||||
<ClInclude Include="..\src\thread\thread.h"> | <ClInclude Include="..\src\thread\thread.h"> | ||||
<Filter>src\thread</Filter> | <Filter>src\thread</Filter> | ||||
</ClInclude> | </ClInclude> | ||||