Changeset 1231
- Timestamp:
- Apr 15, 2012, 11:20:05 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gpu/vertexbuffer.cpp
r1230 r1231 119 119 } 120 120 121 void VertexDeclaration::DrawElements(MeshPrimitive type, int skip, int count) 122 { 123 #if defined _XBOX || defined USE_D3D9 124 g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); 125 switch (type) 126 { 127 case MeshPrimitive::Triangles: 128 g_d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, skip, count); 129 break; 130 } 131 #else 132 switch (type) 133 { 134 case MeshPrimitive::Triangles: 135 glDrawArrays(GL_TRIANGLES, skip * 3, count * 3); 136 break; 137 } 138 #endif 139 } 140 121 141 void VertexDeclaration::Unbind() 122 142 { … … 124 144 /* FIXME: Nothing to do? */ 125 145 #else 126 /* FIXME: we need to record what happens*/146 /* FIXME: we need to unbind what we bound */ 127 147 //glDisableVertexAttribArray(m_attrib); 128 148 /* FIXME: only useful for VAOs */ 129 149 //glBindBuffer(GL_ARRAY_BUFFER, 0); 150 /* Or: */ 151 //glDisableVertexAttribArray(m_attrib); 152 /* Or even: */ 153 //glDisableClientState(GL_VERTEX_ARRAY); 130 154 #endif 131 155 } … … 186 210 * the information. It sucks. */ 187 211 188 int attr_index = 0, usage_index = 0 , stream = -1;212 int attr_index = 0, usage_index = 0; 189 213 /* First, find the stream index */ 190 214 for (; attr_index < m_count; attr_index++) 191 215 if (m_streams[attr_index].usage == usage) 192 216 if (usage_index++ == index) 193 {194 stream = m_streams[attr_index].index;195 217 break; 196 }197 218 198 219 /* Now compute the stride and offset up to this stream index */ -
trunk/src/gpu/vertexbuffer.h
r1230 r1231 62 62 }; 63 63 64 struct MeshPrimitive 65 { 66 enum Value 67 { 68 Triangles, 69 } 70 m_value; 71 72 inline MeshPrimitive(Value v) { m_value = v; } 73 inline operator Value() { return m_value; } 74 }; 75 64 76 class VertexStreamBase 65 77 { … … 165 177 166 178 void Bind(); 179 void DrawElements(MeshPrimitive type, int skip, int count); 167 180 void Unbind(); 168 181 void SetStream(VertexBuffer *vb, ShaderAttrib attr1, -
trunk/test/tutorial/tut01.cpp
r1228 r1231 14 14 15 15 #include "core.h" 16 #include "lolgl.h"17 16 #include "loldebug.h" 18 17 19 18 using namespace std; 20 19 using namespace lol; 21 22 #if defined _WIN32 && defined USE_D3D923 # define FAR24 # define NEAR25 # include <d3d9.h>26 #endif27 20 28 21 #if USE_SDL && defined __APPLE__ … … 37 30 # undef main /* FIXME: still needed? */ 38 31 # include <direct.h> 39 #endif40 41 #if defined USE_D3D942 extern IDirect3DDevice9 *g_d3ddevice;43 #elif defined _XBOX44 extern D3DDevice *g_d3ddevice;45 32 #endif 46 33 … … 62 49 if (!m_ready) 63 50 { 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 51 m_shader = Shader::Create( 80 52 #if !defined __CELLOS_LV2__ && !defined _XBOX && !defined USE_D3D9 … … 117 89 m_vdecl->Bind(); 118 90 m_vdecl->SetStream(m_vbo, m_coord); 119 #if defined _XBOX || defined USE_D3D9 120 g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); 121 #endif 122 123 #if defined _XBOX || defined USE_D3D9 124 g_d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); 125 #else 126 glDrawArrays(GL_TRIANGLES, 0, 3); 127 #endif 128 91 m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 1); 129 92 m_vdecl->Unbind(); 130 #if defined _XBOX || defined USE_D3D9131 /* FIXME: do we need to unset anything here? */132 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__133 //glDisableVertexAttribArray(m_attrib);134 //glBindBuffer(GL_ARRAY_BUFFER, 0);135 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__136 /* Never used for now */137 glDisableVertexAttribArray(m_attrib);138 #else139 glDisableClientState(GL_VERTEX_ARRAY);140 #endif141 93 } 142 94 … … 144 96 vec2 m_vertices[3]; 145 97 Shader *m_shader; 98 ShaderAttrib m_coord; 146 99 VertexDeclaration *m_vdecl; 147 100 VertexBuffer *m_vbo; 148 ShaderAttrib m_coord;149 101 bool m_ready; 150 102 };
Note: See TracChangeset
for help on using the changeset viewer.