Changeset 1243
 Timestamp:
 Apr 21, 2012, 10:18:11 AM (10 years ago)
 Location:
 trunk
 Files:

 1 added
 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/core.h
r1237 r1243 71 71 #include "timer.h" 72 72 #include "thread/thread.h" 73 #include "array.h" 73 74 74 75 // Static classes 
trunk/test/tutorial/01_triangle.cpp
r1242 r1243 37 37 Triangle() 38 38 { 39 m_vertices [0]= vec2( 0.0, 0.8);40 m_vertices [1]= vec2(0.8, 0.8);41 m_vertices [2]= vec2( 0.8, 0.8);39 m_vertices += vec2( 0.0, 0.8); 40 m_vertices += vec2(0.8, 0.8); 41 m_vertices += vec2( 0.8, 0.8); 42 42 m_ready = false; 43 43 } … … 76 76 m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); 77 77 78 m_vbo = new VertexBuffer( sizeof(m_vertices));78 m_vbo = new VertexBuffer(m_vertices.Bytes()); 79 79 void *vertices = m_vbo>Lock(0, 0); 80 memcpy(vertices, m_vertices, sizeof(m_vertices));80 memcpy(vertices, &m_vertices[0], m_vertices.Bytes()); 81 81 m_vbo>Unlock(); 82 82 … … 94 94 95 95 private: 96 vec2 m_vertices[3];96 Array<vec2> m_vertices; 97 97 Shader *m_shader; 98 98 ShaderAttrib m_coord; 
trunk/test/tutorial/02_cube.cpp
r1242 r1243 49 49 50 50 /* Front vertices/colors */ 51 m_mesh [0] = vec3(1.0, 1.0, 1.0); m_mesh[1]= vec3(1.0, 0.0, 1.0);52 m_mesh [2] = vec3( 1.0, 1.0, 1.0); m_mesh[3]= vec3(0.0, 1.0, 0.0);53 m_mesh [4] = vec3( 1.0, 1.0, 1.0); m_mesh[5]= vec3(1.0, 0.5, 0.0);54 m_mesh [6] = vec3(1.0, 1.0, 1.0); m_mesh[7]= vec3(1.0, 1.0, 0.0);51 m_mesh += vec3(1.0, 1.0, 1.0); m_mesh += vec3(1.0, 0.0, 1.0); 52 m_mesh += vec3( 1.0, 1.0, 1.0); m_mesh += vec3(0.0, 1.0, 0.0); 53 m_mesh += vec3( 1.0, 1.0, 1.0); m_mesh += vec3(1.0, 0.5, 0.0); 54 m_mesh += vec3(1.0, 1.0, 1.0); m_mesh += vec3(1.0, 1.0, 0.0); 55 55 /* Back */ 56 m_mesh [8] = vec3(1.0, 1.0, 1.0); m_mesh[9]= vec3(1.0, 0.0, 0.0);57 m_mesh [10] = vec3( 1.0, 1.0, 1.0); m_mesh[11]= vec3(0.0, 0.5, 0.0);58 m_mesh [12] = vec3( 1.0, 1.0, 1.0); m_mesh[13]= vec3(0.0, 0.5, 1.0);59 m_mesh [14] = vec3(1.0, 1.0, 1.0); m_mesh[15]= vec3(0.0, 0.0, 1.0);60 61 m_indices [0]= i16vec3(0, 1, 2);62 m_indices [1]= i16vec3(2, 3, 0);63 m_indices [2]= i16vec3(1, 5, 6);64 m_indices [3]= i16vec3(6, 2, 1);65 m_indices [4]= i16vec3(7, 6, 5);66 m_indices [5]= i16vec3(5, 4, 7);67 m_indices [6]= i16vec3(4, 0, 3);68 m_indices [7]= i16vec3(3, 7, 4);69 m_indices [8]= i16vec3(4, 5, 1);70 m_indices [9]= i16vec3(1, 0, 4);71 m_indices [10]= i16vec3(3, 2, 6);72 m_indices [11]= i16vec3(6, 7, 3);56 m_mesh += vec3(1.0, 1.0, 1.0); m_mesh += vec3(1.0, 0.0, 0.0); 57 m_mesh += vec3( 1.0, 1.0, 1.0); m_mesh += vec3(0.0, 0.5, 0.0); 58 m_mesh += vec3( 1.0, 1.0, 1.0); m_mesh += vec3(0.0, 0.5, 1.0); 59 m_mesh += vec3(1.0, 1.0, 1.0); m_mesh += vec3(0.0, 0.0, 1.0); 60 61 m_indices += i16vec3(0, 1, 2); 62 m_indices += i16vec3(2, 3, 0); 63 m_indices += i16vec3(1, 5, 6); 64 m_indices += i16vec3(6, 2, 1); 65 m_indices += i16vec3(7, 6, 5); 66 m_indices += i16vec3(5, 4, 7); 67 m_indices += i16vec3(4, 0, 3); 68 m_indices += i16vec3(3, 7, 4); 69 m_indices += i16vec3(4, 5, 1); 70 m_indices += i16vec3(1, 0, 4); 71 m_indices += i16vec3(3, 2, 6); 72 m_indices += i16vec3(6, 7, 3); 73 73 74 74 m_ready = false; … … 140 140 VertexUsage::Color)); 141 141 142 m_vbo = new VertexBuffer( sizeof(m_mesh));142 m_vbo = new VertexBuffer(m_mesh.Bytes()); 143 143 void *mesh = m_vbo>Lock(0, 0); 144 memcpy(mesh, m_mesh, sizeof(m_mesh));144 memcpy(mesh, &m_mesh[0], m_mesh.Bytes()); 145 145 m_vbo>Unlock(); 146 146 … … 149 149 glGenBuffers(1, &m_ibo); 150 150 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo); 151 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(m_indices), m_indices,152 GL_STATIC_DRAW);151 glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.Bytes(), 152 &m_indices[0], GL_STATIC_DRAW); 153 153 #elif defined _XBOX  defined USE_D3D9 154 154 int16_t *indices; 155 if (FAILED(g_d3ddevice>CreateIndexBuffer( sizeof(m_indices), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_ibo, NULL)))155 if (FAILED(g_d3ddevice>CreateIndexBuffer(m_indices.Bytes(), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_ibo, NULL))) 156 156 Abort(); 157 157 if (FAILED(m_ibo>Lock(0, 0, (void **)&indices, 0))) 158 158 Abort(); 159 memcpy(indices, m_indices, sizeof(m_indices));159 memcpy(indices, &m_indices[0], m_indices.Bytes()); 160 160 m_ibo>Unlock(); 161 161 #else … … 179 179 if (FAILED(g_d3ddevice>SetIndices(m_ibo))) 180 180 Abort(); 181 if (FAILED(g_d3ddevice>DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 8, 0, sizeof(m_indices) / sizeof(*m_indices))))181 if (FAILED(g_d3ddevice>DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 8, 0, m_indices.Count()))) 182 182 Abort(); 183 183 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ … … 202 202 float m_angle; 203 203 mat4 m_matrix; 204 vec3 m_mesh[16];205 i16vec3 m_indices[12];204 Array<vec3> m_mesh; 205 Array<i16vec3> m_indices; 206 206 Shader *m_shader; 207 207 ShaderAttrib m_coord, m_color;
Note: See TracChangeset
for help on using the changeset viewer.