Changeset 9103:c54b0474f6bf in orange
 Timestamp:
 10/12/11 23:56:32 (3 years ago)
 Branch:
 default
 Convert:
 98d0a1cb44156f8a7aecf17f5fb8cf6c39a0788d
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

source/orangeqt/canvas3d.cpp
r9080 r9103 1180 1180 } 1181 1181 1182 // Build VBOs:1183 1182 int needed_floats = m_edges.size() * 2 * 3; 1184 1183 float* vbo_edges_data = new float[needed_floats]; … … 1206 1205 1207 1206 // Similar for nodes: 1208 needed_floats = m_nodes.size() * 3; 1207 // vec3 location 1208 // vec3 offset 1209 // vec3 color 1210 // vec2 selected_marked 1211 // 1212 // 6 vertices (2 triangles) 1213 needed_floats = m_nodes.size() * (3+3+3+2) * 6; 1209 1214 float* vbo_nodes_data = new float[needed_floats]; 1210 1215 dest = vbo_nodes_data; 1211 1216 memset(vbo_nodes_data, 0, needed_floats * sizeof(float)); 1217 // 2D rectangle offsets (2 triangles) 1218 const float x_offsets[] = {0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; 1219 const float y_offsets[] = {0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; 1220 1212 1221 for (int i = 0; i < m_nodes.size(); ++i) 1213 1222 { 1214 1223 Node3D* node = m_nodes[i]; 1215 *dest = node>x(); dest++; 1216 *dest = node>y(); dest++; 1217 *dest = node>z(); dest++; 1224 QColor color = node>color(); 1225 float x = node>x(); 1226 float y = node>y(); 1227 float z = node>z(); 1228 float red = color.red() / 255.f; 1229 float green = color.green() / 255.f; 1230 float blue = color.blue() / 255.f; 1231 float selected = node>selected() ? 1.f : 0.f; 1232 float marked = node>marked() ? 1.f : 0.f; 1233 1234 for (int v = 0; v < 6; ++v) 1235 { 1236 *dest = x; dest++; 1237 *dest = y; dest++; 1238 *dest = z; dest++; 1239 1240 *dest = x_offsets[v]; dest++; 1241 *dest = y_offsets[v]; dest++; 1242 *dest = 0.f; dest++; 1243 1244 *dest = red; dest++; 1245 *dest = green; dest++; 1246 *dest = blue; dest++; 1247 1248 *dest = selected; dest++; 1249 *dest = marked; dest++; 1250 } 1218 1251 } 1219 1252 … … 1249 1282 1250 1283 glBindBuffer(GL_ARRAY_BUFFER, m_vbo_nodes); 1251 int vertex_size = 3; 1252 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, vertex_size*4, BUFFER_OFFSET(0)); 1284 int vertex_size = (3+3+3+2)*4; 1285 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, vertex_size, BUFFER_OFFSET(0)); 1286 glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, vertex_size, BUFFER_OFFSET(3*4)); 1287 glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, vertex_size, BUFFER_OFFSET(6*4)); 1288 glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, vertex_size, BUFFER_OFFSET(9*4)); 1253 1289 glEnableVertexAttribArray(0); 1254 glDrawArrays(GL_POINTS, 0, m_nodes.size()); 1290 glEnableVertexAttribArray(1); 1291 glEnableVertexAttribArray(2); 1292 glEnableVertexAttribArray(3); 1293 glDrawArrays(GL_TRIANGLES, 0, m_nodes.size() * 6); 1255 1294 glDisableVertexAttribArray(0); 1295 glDisableVertexAttribArray(1); 1296 glDisableVertexAttribArray(2); 1297 glDisableVertexAttribArray(3); 1256 1298 1257 1299 glBindBuffer(GL_ARRAY_BUFFER, 0);
Note: See TracChangeset
for help on using the changeset viewer.