Changeset 2497 for trunk/tutorial/02_cube.cpp
 Timestamp:
 Feb 25, 2013, 8:43:51 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

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.