Changeset 1227
- Timestamp:
- Apr 14, 2012, 8:28:15 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core.h
r1224 r1227 99 99 #include "layer.h" 100 100 #include "gpu/shader.h" 101 #include "gpu/vertexbuffer.h" 101 102 #include "gpu/vbo.h" 102 #include "gpu/vertexbuffer.h"103 103 #include "image/image.h" 104 104 #include "application/application.h" -
trunk/src/gpu/shader.cpp
r1221 r1227 232 232 } 233 233 234 int Shader::GetAttribLocation(char const *attr) const 235 { 236 #if defined USE_D3D9 || defined _XBOX 237 /* FIXME: do we have attribs on these platforms? */ 238 return 0; 239 #elif !defined __CELLOS_LV2__ 240 return glGetAttribLocation(data->prog_id, attr); 241 #else 242 /* FIXME: need to differentiate between vertex and fragment program */ 243 return 0; 244 #endif 234 ShaderAttrib Shader::GetAttribLocation(char const *attr, 235 VertexUsage usage, int index) const 236 { 237 ShaderAttrib ret; 238 #if defined USE_D3D9 || defined _XBOX 239 ret.m_flags = (uint32_t)index << 16; 240 ret.m_flags |= (uint32_t)usage; 241 #elif !defined __CELLOS_LV2__ 242 ret.m_flags = glGetAttribLocation(data->prog_id, attr); 243 #else 244 /* FIXME: can we do this at all? */ 245 #endif 246 return ret; 245 247 } 246 248 -
trunk/src/gpu/shader.h
r1215 r1227 35 35 }; 36 36 37 struct ShaderAttrib 38 { 39 friend class Shader; 40 friend class VertexDeclaration; 41 42 public: 43 ShaderAttrib(int flags = 0xffffffff) : m_flags(flags) {} 44 45 private: 46 uint32_t m_flags; 47 }; 48 37 49 class ShaderData; 38 50 … … 43 55 static void Destroy(Shader *shader); 44 56 45 int GetAttribLocation(char const *attr) const; 57 ShaderAttrib GetAttribLocation(char const *attr, struct VertexUsage usage, 58 int index) const; 46 59 47 60 ShaderUniform GetUniformLocation(char const *uni) const; -
trunk/src/gpu/vertexbuffer.cpp
r1226 r1227 33 33 { 34 34 35 // 36 // The VertexBufferData class 37 // -------------------------- 38 // 39 40 class VertexBufferData 41 { 42 friend class VertexBuffer; 43 friend class VertexDeclaration; 44 45 #if defined USE_D3D9 46 IDirect3DVertexBuffer9 *m_vbo; 47 #elif defined _XBOX 48 D3DVertexBuffer *m_vbo; 49 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ 50 GLuint m_vbo; 51 uint8_t *m_memory; 52 size_t m_size; 53 #endif 54 }; 55 56 // 57 // The VertexDeclaration class 58 // --------------------------- 59 // 60 35 61 VertexStreamBase const VertexStreamBase::Empty; 62 63 VertexDeclaration::VertexDeclaration(VertexStreamBase const &s1, 64 VertexStreamBase const &s2, 65 VertexStreamBase const &s3, 66 VertexStreamBase const &s4, 67 VertexStreamBase const &s5, 68 VertexStreamBase const &s6, 69 VertexStreamBase const &s7, 70 VertexStreamBase const &s8, 71 VertexStreamBase const &s9, 72 VertexStreamBase const &s10, 73 VertexStreamBase const &s11, 74 VertexStreamBase const &s12) : m_count(0) 75 { 76 if (&s1 != &VertexStreamBase::Empty) AddStream(s1); 77 if (&s2 != &VertexStreamBase::Empty) AddStream(s2); 78 if (&s3 != &VertexStreamBase::Empty) AddStream(s3); 79 if (&s4 != &VertexStreamBase::Empty) AddStream(s4); 80 if (&s5 != &VertexStreamBase::Empty) AddStream(s5); 81 if (&s6 != &VertexStreamBase::Empty) AddStream(s6); 82 if (&s7 != &VertexStreamBase::Empty) AddStream(s7); 83 if (&s8 != &VertexStreamBase::Empty) AddStream(s8); 84 if (&s9 != &VertexStreamBase::Empty) AddStream(s9); 85 if (&s10 != &VertexStreamBase::Empty) AddStream(s10); 86 if (&s11 != &VertexStreamBase::Empty) AddStream(s11); 87 if (&s12 != &VertexStreamBase::Empty) AddStream(s12); 88 Initialize(); 89 } 90 91 VertexDeclaration::~VertexDeclaration() 92 { 93 #if defined _XBOX || defined USE_D3D9 94 # if defined USE_D3D9 95 IDirect3DVertexDeclaration9 *vdecl = (IDirect3DVertexDeclaration9 *)m_data; 96 # elif defined _XBOX 97 D3DVertexDeclaration *vdecl = (D3DVertexDeclaration *)m_data; 98 # endif 99 100 vdecl->Release(); 101 #else 102 103 #endif 104 } 105 106 void VertexDeclaration::Bind() 107 { 108 #if defined _XBOX || defined USE_D3D9 109 # if defined USE_D3D9 110 IDirect3DVertexDeclaration9 *vdecl = (IDirect3DVertexDeclaration9 *)m_data; 111 # elif defined _XBOX 112 D3DVertexDeclaration *vdecl = (D3DVertexDeclaration *)m_data; 113 # endif 114 115 g_d3ddevice->SetVertexDeclaration(vdecl); 116 #else 117 118 #endif 119 } 120 121 void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attr1, 122 ShaderAttrib attr2, 123 ShaderAttrib attr3, 124 ShaderAttrib attr4, 125 ShaderAttrib attr5, 126 ShaderAttrib attr6, 127 ShaderAttrib attr7, 128 ShaderAttrib attr8, 129 ShaderAttrib attr9, 130 ShaderAttrib attr10, 131 ShaderAttrib attr11, 132 ShaderAttrib attr12) 133 { 134 #if defined _XBOX || defined USE_D3D9 135 /* Only the first item is required to know which stream this 136 * is about; the rest of the information is stored in the 137 * vertex declaration already. */ 138 uint32_t usage = attr1.m_flags >> 16; 139 uint32_t index = attr1.m_flags & 0xffff; 140 int usage_index = 0, stream = -1, stride = 0; 141 for (int i = 0; i < m_count; i++) 142 { 143 if (m_streams[i].usage == usage) 144 if (usage_index++ == index) 145 stream = m_streams[i].index; 146 if (stream == m_streams[i].index) 147 stride += m_streams[i].size; 148 } 149 150 /* Now we know the stream index and the element stride */ 151 /* FIXME: precompute most of the crap above! */ 152 if (stream >= 0) 153 g_d3ddevice->SetStreamSource(stream, vb->m_data->m_vbo, 0, stride); 154 #else 155 glBindBuffer(GL_ARRAY_BUFFER, vb); 156 ShaderAttrib l[12] = { attr1, attr2, attr3, attr4, attr5, attr6, 157 attr7, attr8, attr9, attr10, attr11, attr12 }; 158 for (int i = 0; i < 12 && l[i].m_flags != 0xffffffff; i++) 159 { 160 uint32_t usage = l[i].m_flags >> 16; 161 uint32_t index = l[i].m_flags & 0xffff; 162 glEnableVertexAttribArray((GLint)attr.flags); 163 /* FIXME: Hardcoded!! Where to get that from? */ 164 glVertexAttribPointer((GLint)attr.flags, 3, GL_FLOAT, GL_FALSE, 0, 0); 165 #endif 166 } 36 167 37 168 void VertexDeclaration::Initialize() … … 39 170 #if defined _XBOX || defined USE_D3D9 40 171 static D3DVERTEXELEMENT9 const end_element[] = { D3DDECL_END() }; 41 static D3D ECLTYPE const X = D3DDECLTYPE_UNUSED;42 static D3D ECLTYPE const tlut[] =172 static D3DDECLTYPE const X = D3DDECLTYPE_UNUSED; 173 static D3DDECLTYPE const tlut[] = 43 174 { 44 175 D3DDECLTYPE_UNUSED, … … 73 204 74 205 D3DVERTEXELEMENT9 elements[12 + 1]; 75 int nstreams = 0; 76 while (m_streams[nstreams].size) 77 { 78 elements[nstreams].Stream = m_streams[nstreams].index; 79 elements[nstreams].Offset = 0; 80 for (int i = 0; i < nstreams; i++) 81 elements[nstreams].Offset += m_streams[nstreams].size; 82 83 if (m_streams[nstreams].type >= 0 84 && m_streams[nstreams].type < sizeof(tlut) / sizeof(*tlut)) 85 elements[nstreams].Type = tlut[m_streams[nstreams].type]; 206 for (int n = 0; n < m_count; n++) 207 { 208 elements[n].Stream = m_streams[n].index; 209 elements[n].Offset = 0; 210 for (int i = 0; i < n; i++) 211 elements[n].Offset += m_streams[n].size; 212 213 if (m_streams[n].stream_type >= 0 214 && m_streams[n].stream_type < sizeof(tlut) / sizeof(*tlut)) 215 elements[n].Type = tlut[m_streams[n].stream_type]; 86 216 else 87 elements[n streams].Type = D3DDECLTYPE_UNUSED;88 89 elements[n streams].Method = D3DDECLMETHOD_DEFAULT;90 91 if (m_streams[n streams].usage >= 092 && m_streams[n streams].usage < sizeof(ulut) / sizeof(*ulut))93 elements[n streams].Type = ulut[m_streams[nstreams].usage];217 elements[n].Type = D3DDECLTYPE_UNUSED; 218 219 elements[n].Method = D3DDECLMETHOD_DEFAULT; 220 221 if (m_streams[n].usage >= 0 222 && m_streams[n].usage < sizeof(ulut) / sizeof(*ulut)) 223 elements[n].Usage = ulut[m_streams[n].usage]; 94 224 else 95 elements[nstreams].Type = D3DDECLUSAGE_POSITION; 96 97 elements[nstreams].UsageIndex = 0; 98 for (int i = 0; i < nstreams; i++) 99 if (elements[i].Stream == elements[nstreams].Stream 100 && elements[i].Usage == elements[nstreams].Usage) 101 elements[nstreams].UsageIndex++; 102 103 nstreams++; 225 elements[n].Usage = D3DDECLUSAGE_POSITION; 226 227 elements[n].UsageIndex = 0; 228 for (int i = 0; i < n; i++) 229 if (elements[i].Stream == elements[n].Stream 230 && elements[i].Usage == elements[n].Usage) 231 elements[n].UsageIndex++; 104 232 } 105 elements[ nstreams] = end_element[0];233 elements[m_count] = end_element[0]; 106 234 107 235 # if defined USE_D3D9 … … 117 245 118 246 #endif 119 }120 121 VertexDeclaration::~VertexDeclaration()122 {123 #if defined _XBOX || defined USE_D3D9124 # if defined USE_D3D9125 IDirect3DVertexDeclaration9 *vdecl = (IDirect3DVertexDeclaration9 *)m_data;126 # elif defined _XBOX127 D3DVertexDeclaration *vdecl = (D3DVertexDeclaration *)m_data;128 # endif129 130 vdecl->Release();131 #else132 133 #endif134 }135 136 void VertexDeclaration::Bind()137 {138 #if defined _XBOX || defined USE_D3D9139 # if defined USE_D3D9140 IDirect3DVertexDeclaration9 *vdecl = (IDirect3DVertexDeclaration9 *)m_data;141 # elif defined _XBOX142 D3DVertexDeclaration *vdecl = (D3DVertexDeclaration *)m_data;143 # endif144 145 g_d3ddevice->SetVertexDeclaration(vdecl);146 #else147 148 #endif149 }150 151 VertexDeclaration::VertexDeclaration(VertexStreamBase const &s1,152 VertexStreamBase const &s2,153 VertexStreamBase const &s3,154 VertexStreamBase const &s4,155 VertexStreamBase const &s5,156 VertexStreamBase const &s6,157 VertexStreamBase const &s7,158 VertexStreamBase const &s8,159 VertexStreamBase const &s9,160 VertexStreamBase const &s10,161 VertexStreamBase const &s11,162 VertexStreamBase const &s12) : m_count(0)163 {164 if (&s1 != &VertexStreamBase::Empty) AddStream(s1);165 if (&s2 != &VertexStreamBase::Empty) AddStream(s2);166 if (&s3 != &VertexStreamBase::Empty) AddStream(s3);167 if (&s4 != &VertexStreamBase::Empty) AddStream(s4);168 if (&s5 != &VertexStreamBase::Empty) AddStream(s5);169 if (&s6 != &VertexStreamBase::Empty) AddStream(s6);170 if (&s7 != &VertexStreamBase::Empty) AddStream(s7);171 if (&s8 != &VertexStreamBase::Empty) AddStream(s8);172 if (&s9 != &VertexStreamBase::Empty) AddStream(s9);173 if (&s10 != &VertexStreamBase::Empty) AddStream(s10);174 if (&s11 != &VertexStreamBase::Empty) AddStream(s11);175 if (&s12 != &VertexStreamBase::Empty) AddStream(s12);176 Initialize();177 247 } 178 248 … … 191 261 } 192 262 263 // 264 // The VertexBuffer class 265 // ---------------------- 266 // 267 268 VertexBuffer::VertexBuffer(size_t size) 269 : m_data(new VertexBufferData) 270 { 271 #if defined USE_D3D9 || defined _XBOX 272 g_d3ddevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, NULL, 273 D3DPOOL_MANAGED, &m_data->m_vbo, NULL); 274 new uint8_t[size]; 275 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ 276 glGenBuffers(1, &m_data->m_vbo); 277 m_data->m_memory = new uint8_t[size]; 278 m_data->m_size = size; 279 #endif 280 } 281 282 VertexBuffer::~VertexBuffer() 283 { 284 #if defined USE_D3D9 || defined _XBOX 285 m_data->m_vbo->Release(); 286 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ 287 glDeleteBuffers(1, &m_data->m_vbo); 288 delete[] m_data->m_memory; 289 #endif 290 } 291 292 void *VertexBuffer::Lock(size_t offset, size_t size) 293 { 294 #if defined USE_D3D9 || defined _XBOX 295 void *ret; 296 if (FAILED(m_data->m_vbo->Lock(offset, size, (void **)&ret, 0))) 297 exit(0); 298 return ret; 299 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ 300 return m_data->m_memory + offset; 301 #endif 302 } 303 304 void VertexBuffer::Unlock() 305 { 306 #if defined USE_D3D9 || defined _XBOX 307 m_data->m_vbo->Unlock(); 308 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ 309 glBindBuffer(GL_ARRAY_BUFFER, m_vbo); 310 glBufferData(GL_ARRAY_BUFFER, m_data->m_size, m_data->m_memory, 311 GL_STATIC_DRAW); 312 #endif 313 } 314 193 315 } /* namespace lol */ 194 316 -
trunk/src/gpu/vertexbuffer.h
r1226 r1227 10 10 11 11 // 12 // The VertexBuffer class13 // ---------------------- 12 // The VertexBuffer and VertexDeclaration classes 13 // ---------------------------------------------- 14 14 // 15 15 … … 21 21 namespace lol 22 22 { 23 24 class VertexBuffer 25 { 26 friend class VertexDeclaration; 27 28 public: 29 VertexBuffer(size_t size); 30 ~VertexBuffer(); 31 32 void *Lock(size_t offset, size_t size); 33 void Unlock(); 34 35 private: 36 class VertexBufferData *m_data; 37 }; 23 38 24 39 struct VertexUsage … … 81 96 #undef LOL_TYPE 82 97 83 template<typename T> inline void AddStream(int n, intusage)98 template<typename T> inline void AddStream(int n, VertexUsage usage) 84 99 { 85 100 m_streams[n].stream_type = GetType((T *)NULL); … … 97 112 98 113 template<> 99 inline void VertexStreamBase::AddStream<void>(int n, intusage)114 inline void VertexStreamBase::AddStream<void>(int n, VertexUsage usage) 100 115 { 101 116 (void)usage; … … 150 165 151 166 void Bind(); 167 void SetStream(VertexBuffer *vb, ShaderAttrib attr1, 168 ShaderAttrib attr2 = ShaderAttrib(), 169 ShaderAttrib attr3 = ShaderAttrib(), 170 ShaderAttrib attr4 = ShaderAttrib(), 171 ShaderAttrib attr5 = ShaderAttrib(), 172 ShaderAttrib attr6 = ShaderAttrib(), 173 ShaderAttrib attr7 = ShaderAttrib(), 174 ShaderAttrib attr8 = ShaderAttrib(), 175 ShaderAttrib attr9 = ShaderAttrib(), 176 ShaderAttrib attr10 = ShaderAttrib(), 177 ShaderAttrib attr11 = ShaderAttrib(), 178 ShaderAttrib attr12 = ShaderAttrib()); 152 179 153 180 private: -
trunk/test/tutorial/tut01.cpp
r1226 r1227 100 100 #endif 101 101 ); 102 #if !defined _XBOX && !defined USE_D3D9 103 m_attrib = m_shader->GetAttribLocation("in_Position"); 104 #endif 105 m_ready = true; 102 m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); 106 103 107 #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX && !defined USE_D3D9 108 /* Method 1: store vertex buffer on the GPU memory */ 109 glGenBuffers(1, &m_vbo); 110 glBindBuffer(GL_ARRAY_BUFFER, m_vbo); 111 glBufferData(GL_ARRAY_BUFFER, sizeof(m_vertices), m_vertices, 112 GL_STATIC_DRAW); 113 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX && !defined USE_D3D9 114 /* Method 2: upload vertex information at each frame */ 115 #elif defined _XBOX || defined USE_D3D9 116 m_vdecl = 117 new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); 104 m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); 118 105 119 if (FAILED(g_d3ddevice->CreateVertexBuffer(sizeof(m_vertices), D3DUSAGE_WRITEONLY, NULL, D3DPOOL_MANAGED, &m_vbo, NULL))) 120 exit(0); 121 122 vec2 *vertices; 123 if (FAILED(m_vbo->Lock(0, 0, (void **)&vertices, 0))) 124 exit(0); 106 m_vbo = new VertexBuffer(sizeof(m_vertices)); 107 void *vertices = m_vbo->Lock(0, 0); 125 108 memcpy(vertices, m_vertices, sizeof(m_vertices)); 126 109 m_vbo->Unlock(); 127 #else 128 #endif 110 111 m_ready = true; 129 112 130 113 /* FIXME: this object never cleans up */ … … 133 116 m_shader->Bind(); 134 117 m_vdecl->Bind(); 118 m_vdecl->SetStream(m_vbo, m_coord); 135 119 #if defined _XBOX || defined USE_D3D9 136 120 g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); 137 g_d3ddevice->SetStreamSource(0, m_vbo, 0, sizeof(*m_vertices));138 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__139 glBindBuffer(GL_ARRAY_BUFFER, m_vbo);140 glEnableVertexAttribArray(m_attrib);141 glVertexAttribPointer(m_attrib, 2, GL_FLOAT, GL_FALSE, 0, 0);142 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__143 /* Never used for now */144 glEnableVertexAttribArray(m_attrib);145 glVertexAttribPointer(m_attrib, 2, GL_FLOAT, GL_FALSE, 0, m_vertices);146 #else147 glEnableClientState(GL_VERTEX_ARRAY);148 glVertexPointer(3, GL_FLOAT, 0, m_vertices);149 121 #endif 150 122 … … 172 144 Shader *m_shader; 173 145 VertexDeclaration *m_vdecl; 174 #if defined USE_D3D9 175 IDirect3DVertexBuffer9 *m_vbo; 176 #elif defined _XBOX 177 D3DVertexBuffer *m_vbo; 178 #else 179 int m_attrib; 180 # if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ 181 GLuint m_vbo; 182 # endif 183 #endif 146 VertexBuffer *m_vbo; 147 ShaderAttrib m_coord; 184 148 bool m_ready; 185 149 }; -
trunk/test/tutorial/tut02.cpp
r1226 r1227 139 139 #endif 140 140 ); 141 #if !defined _XBOX && !defined USE_D3D9142 m_coord = m_shader->GetAttribLocation("in_Vertex");143 m_color = m_shader->GetAttribLocation("in_Color");144 #endif145 141 m_mvp = m_shader->GetUniformLocation("in_Matrix"); 146 m_ready = true; 142 m_coord = m_shader->GetAttribLocation("in_Vertex", 143 VertexUsage::Position, 0); 144 m_color = m_shader->GetAttribLocation("in_Color", 145 VertexUsage::Color, 0); 147 146 148 147 m_vdecl = 149 148 new VertexDeclaration(VertexStream<vec3>(VertexUsage::Position), 150 149 VertexStream<vec3>(VertexUsage::Color)); 150 151 m_vbo = new VertexBuffer(sizeof(m_vertices)); 152 void *vertices = m_vbo->Lock(0, 0); 153 memcpy(vertices, m_vertices, sizeof(m_vertices)); 154 m_vbo->Unlock(); 155 156 m_cbo = new VertexBuffer(sizeof(m_colors)); 157 void *colors = m_cbo->Lock(0, 0); 158 memcpy(colors, m_colors, sizeof(m_colors)); 159 m_cbo->Unlock(); 160 151 161 #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX && !defined USE_D3D9 152 162 /* Method 1: store vertex buffer on the GPU memory */ 153 glGenBuffers(1, &m_vbo);154 glBindBuffer(GL_ARRAY_BUFFER, m_vbo);155 glBufferData(GL_ARRAY_BUFFER, sizeof(m_vertices), m_vertices,156 GL_STATIC_DRAW);157 glGenBuffers(1, &m_cbo);158 glBindBuffer(GL_ARRAY_BUFFER, m_cbo);159 glBufferData(GL_ARRAY_BUFFER, sizeof(m_colors), m_colors,160 GL_STATIC_DRAW);161 163 glGenBuffers(1, &m_ibo); 162 164 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo); … … 164 166 GL_STATIC_DRAW); 165 167 #elif defined _XBOX || defined USE_D3D9 166 if (FAILED(g_d3ddevice->CreateVertexBuffer(sizeof(m_vertices), D3DUSAGE_WRITEONLY, NULL, D3DPOOL_MANAGED, &m_vbo, NULL)))167 exit(0);168 169 vec3 *vertices;170 if (FAILED(m_vbo->Lock(0, 0, (void **)&vertices, 0)))171 exit(0);172 memcpy(vertices, m_vertices, sizeof(m_vertices));173 m_vbo->Unlock();174 175 if (FAILED(g_d3ddevice->CreateVertexBuffer(sizeof(m_colors), D3DUSAGE_WRITEONLY, NULL, D3DPOOL_MANAGED, &m_cbo, NULL)))176 exit(0);177 178 vec3 *colors;179 if (FAILED(m_cbo->Lock(0, 0, (void **)&colors, 0)))180 exit(0);181 memcpy(colors, m_colors, sizeof(m_colors));182 m_cbo->Unlock();183 184 168 int16_t *indices; 185 169 if (FAILED(g_d3ddevice->CreateIndexBuffer(sizeof(m_indices), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_ibo, NULL))) … … 194 178 195 179 /* FIXME: this object never cleans up */ 180 m_ready = true; 196 181 } 197 182 … … 199 184 m_shader->SetUniform(m_mvp, m_matrix); 200 185 m_vdecl->Bind(); 186 m_vdecl->SetStream(m_vbo, m_coord); 187 m_vdecl->SetStream(m_cbo, m_color); 188 201 189 #if defined _XBOX || defined USE_D3D9 202 190 g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); 203 g_d3ddevice->SetStreamSource(0, m_vbo, 0, sizeof(*m_vertices));204 g_d3ddevice->SetStreamSource(1, m_cbo, 0, sizeof(*m_colors));205 191 g_d3ddevice->SetIndices(m_ibo); 206 192 g_d3ddevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, sizeof(m_indices) / sizeof(*m_indices)); … … 238 224 i16vec3 m_indices[12]; 239 225 Shader *m_shader; 226 ShaderAttrib m_coord, m_color; 227 ShaderUniform m_mvp; 240 228 VertexDeclaration *m_vdecl; 229 VertexBuffer *m_vbo, *m_cbo; 241 230 #if defined USE_D3D9 242 IDirect3DVertexBuffer9 *m_vbo, *m_cbo;243 231 IDirect3DIndexBuffer9 *m_ibo; 244 232 #elif defined _XBOX 245 D3DVertexBuffer *m_vbo, *m_cbo;246 233 D3DIndexBuffer *m_ibo; 247 234 #else 248 int m_coord, m_color;249 235 #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ 250 GLuint m_vbo, m_cbo, m_ibo; 251 #endif 252 #endif 253 ShaderUniform m_mvp; 236 GLuint m_ibo; 237 #endif 238 #endif 254 239 bool m_ready; 255 240 };
Note: See TracChangeset
for help on using the changeset viewer.