Changeset 1238
 Timestamp:
 Apr 18, 2012, 11:15:15 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/tutorial/tut02.cpp
r1236 r1238 48 48 m_angle = 0; 49 49 50 /* Front */51 m_ vertices[0] = vec3(1.0, 1.0,1.0);52 m_ vertices[1] = vec3( 1.0, 1.0, 1.0);53 m_ vertices[2] = vec3( 1.0, 1.0, 1.0);54 m_ vertices[3] = vec3(1.0, 1.0, 1.0);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); 55 55 /* Back */ 56 m_vertices[4] = vec3(1.0, 1.0, 1.0); 57 m_vertices[5] = vec3( 1.0, 1.0, 1.0); 58 m_vertices[6] = vec3( 1.0, 1.0, 1.0); 59 m_vertices[7] = vec3(1.0, 1.0, 1.0); 60 61 m_colors[0] = vec3(1.0, 0.0, 0.0); 62 m_colors[1] = vec3(0.0, 1.0, 0.0); 63 m_colors[2] = vec3(0.0, 0.0, 1.0); 64 m_colors[3] = vec3(1.0, 1.0, 1.0); 65 m_colors[4] = vec3(1.0, 0.0, 0.0); 66 m_colors[5] = vec3(0.0, 1.0, 0.0); 67 m_colors[6] = vec3(0.0, 0.0, 1.0); 68 m_colors[7] = vec3(1.0, 1.0, 1.0); 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); 69 60 70 61 m_indices[0] = i16vec3(0, 1, 2); … … 146 137 147 138 m_vdecl = 148 new VertexDeclaration(VertexStream<vec3 >(VertexUsage::Position),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));139 new VertexDeclaration(VertexStream<vec3,vec3>(VertexUsage::Position, 140 VertexUsage::Color)); 141 142 m_vbo = new VertexBuffer(sizeof(m_mesh)); 143 void *mesh = m_vbo>Lock(0, 0); 144 memcpy(mesh, m_mesh, sizeof(m_mesh)); 154 145 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 146 161 147 #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX && !defined USE_D3D9 … … 181 167 } 182 168 183 Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));169 Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f)); 184 170 185 171 m_shader>Bind(); 186 172 m_shader>SetUniform(m_mvp, m_matrix); 187 m_vdecl>SetStream(m_vbo, m_coord); 188 m_vdecl>SetStream(m_cbo, m_color); 173 m_vdecl>SetStream(m_vbo, m_coord, m_color); 189 174 m_vdecl>Bind(); 190 175 … … 206 191 glBindBuffer(GL_ARRAY_BUFFER, 0); 207 192 #else 193 /* FIXME */ 208 194 glEnableClientState(GL_VERTEX_ARRAY); 209 195 glVertexPointer(3, GL_FLOAT, 0, m_vertices); … … 216 202 float m_angle; 217 203 mat4 m_matrix; 218 vec3 m_vertices[8]; 219 vec3 m_colors[8]; 204 vec3 m_mesh[16]; 220 205 i16vec3 m_indices[12]; 221 206 Shader *m_shader; … … 223 208 ShaderUniform m_mvp; 224 209 VertexDeclaration *m_vdecl; 225 VertexBuffer *m_vbo , *m_cbo;210 VertexBuffer *m_vbo; 226 211 #if defined USE_D3D9 227 212 IDirect3DIndexBuffer9 *m_ibo;
Note: See TracChangeset
for help on using the changeset viewer.