Changeset 2497
- Timestamp:
- Feb 25, 2013, 8:43:51 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gpu/vertexbuffer.cpp
r2426 r2497 155 155 Abort(); 156 156 break; 157 case MeshPrimitive::Lines: 158 if (FAILED(g_d3ddevice->DrawPrimitive(D3DPT_LINELIST, 159 skip, count))) 160 Abort(); 161 break; 157 162 } 158 163 #else … … 175 180 case MeshPrimitive::Points: 176 181 glDrawArrays(GL_POINTS, skip, count); 182 break; 183 case MeshPrimitive::Lines: 184 glDrawArrays(GL_LINES, skip, count); 177 185 break; 178 186 } … … 218 226 Abort(); 219 227 break; 228 case MeshPrimitive::Lines: 229 if (FAILED(g_d3ddevice->DrawIndexedPrimitive(D3DPT_LINELIST, 230 vbase, vskip, vcount, skip, count))) 231 Abort(); 232 break; 220 233 } 221 234 #else … … 246 259 (void)vbase; (void)vskip; (void)vcount; (void)skip; 247 260 glDrawElements(GL_POINTS, count, GL_UNSIGNED_SHORT, 0); 261 break; 262 case MeshPrimitive::Lines: 263 /* FIXME: ignores most of the arguments! */ 264 (void)vbase; (void)vskip; (void)vcount; (void)skip; 265 glDrawElements(GL_LINES, count, GL_UNSIGNED_SHORT, 0); 248 266 break; 249 267 } -
trunk/src/lol/gpu/vertexbuffer.h
r2426 r2497 77 77 TriangleFans, 78 78 Points, 79 Lines, 79 80 } 80 81 m_value; -
trunk/tutorial/02_cube.cpp
r2277 r2497 39 39 m_mesh.Push(vec3(-1.0, 1.0, -1.0), vec3(0.0, 0.0, 1.0)); 40 40 41 m_indices << i16vec3(0, 1, 2); 42 m_indices << i16vec3(2, 3, 0); 43 m_indices << i16vec3(1, 5, 6); 44 m_indices << i16vec3(6, 2, 1); 45 m_indices << i16vec3(7, 6, 5); 46 m_indices << i16vec3(5, 4, 7); 47 m_indices << i16vec3(4, 0, 3); 48 m_indices << i16vec3(3, 7, 4); 49 m_indices << i16vec3(4, 5, 1); 50 m_indices << i16vec3(1, 0, 4); 51 m_indices << i16vec3(3, 2, 6); 52 m_indices << i16vec3(6, 7, 3); 41 m_faces_indices << 0 << 1 << 2 << 2 << 3 << 0; 42 m_faces_indices << 1 << 5 << 6 << 6 << 2 << 1; 43 m_faces_indices << 7 << 6 << 5 << 5 << 4 << 7; 44 m_faces_indices << 4 << 0 << 3 << 3 << 7 << 4; 45 m_faces_indices << 4 << 5 << 1 << 1 << 0 << 4; 46 m_faces_indices << 3 << 2 << 6 << 6 << 7 << 3; 47 48 m_lines_indices << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 0; 49 m_lines_indices << 4 << 5 << 5 << 6 << 6 << 7 << 7 << 4; 50 m_lines_indices << 0 << 4 << 1 << 5 << 2 << 6 << 3 << 7; 53 51 54 52 m_ready = false; … … 92 90 m_vbo->Unlock(); 93 91 94 m_ibo = new IndexBuffer(m_indices.Bytes()); 95 void *indices = m_ibo->Lock(0, 0); 96 memcpy(indices, &m_indices[0], m_indices.Bytes()); 97 m_ibo->Unlock(); 92 m_lines_ibo = new IndexBuffer(m_lines_indices.Bytes()); 93 void *indices = m_lines_ibo->Lock(0, 0); 94 memcpy(indices, &m_lines_indices[0], m_lines_indices.Bytes()); 95 m_lines_ibo->Unlock(); 96 97 m_faces_ibo = new IndexBuffer(m_faces_indices.Bytes()); 98 indices = m_faces_ibo->Lock(0, 0); 99 memcpy(indices, &m_faces_indices[0], m_faces_indices.Bytes()); 100 m_faces_ibo->Unlock(); 98 101 99 102 /* FIXME: this object never cleans up */ … … 104 107 105 108 m_shader->Bind(); 106 m_shader->SetUniform(m_mvp, m_matrix);107 109 m_vdecl->SetStream(m_vbo, m_coord, m_color); 108 110 m_vdecl->Bind(); 109 m_ibo->Bind(); 111 112 m_shader->SetUniform(m_mvp, m_matrix); 113 m_lines_ibo->Bind(); 114 m_vdecl->DrawIndexedElements(MeshPrimitive::Lines, 0, 0, 115 m_mesh.Count(), 0, m_lines_indices.Count()); 116 m_lines_ibo->Unbind(); 117 118 m_shader->SetUniform(m_mvp, m_matrix * mat4::scale(0.5f)); 119 m_faces_ibo->Bind(); 110 120 m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, 111 m_mesh.Count(), 0, m_indices.Count() * 3); 112 m_ibo->Unbind(); 121 m_mesh.Count(), 0, m_faces_indices.Count()); 122 m_faces_ibo->Unbind(); 123 113 124 m_vdecl->Unbind(); 114 125 } … … 118 129 mat4 m_matrix; 119 130 Array<vec3,vec3> m_mesh; 120 Array< i16vec3> m_indices;131 Array<uint16_t> m_lines_indices, m_faces_indices; 121 132 122 133 Shader *m_shader; … … 125 136 VertexDeclaration *m_vdecl; 126 137 VertexBuffer *m_vbo; 127 IndexBuffer *m_ ibo;138 IndexBuffer *m_lines_ibo, *m_faces_ibo; 128 139 129 140 bool m_ready;
Note: See TracChangeset
for help on using the changeset viewer.