PDA

View Full Version : using GL_MAP2_COLOR_4 inOpenGL to change vertexe colors



ali-----
02-12-2013, 08:53 AM
I have a model in which I store my vertex data to draw a surface, every thing is OK but color of vertexes dose not work?

GLfloat ctrlpoints[model->rowCount()][model->columnCount()][3];
for (int i = 0; i < model->columnCount(); ++i) {
for (int j = 0; j < model->rowCount(); ++j) {
ctrlpoints[j][i][0]=(float)j/model->columnCount();
ctrlpoints[j][i][1]=(float)i/model->rowCount();
ctrlpoints[j][i][2]=(float)model->data(model->index(i,j)).toInt();
}
}
GLfloat ctrlpointsColor[model->rowCount()][model->columnCount()][4];
for (int i = 0; i < model->columnCount(); ++i) {
for (int j = 0; j < model->rowCount(); ++j) {
ctrlpointsColor[j][i][0]=1;
ctrlpointsColor[j][i][1]=0;
ctrlpointsColor[j][i][2]=0;
ctrlpointsColor[j][i][3]=1;
}
}

glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_MAP2_COLOR_4);
glEnable(GL_AUTO_NORMAL);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3*model->columnCount(), model->rowCount(), 0, 1, 3, model->columnCount(), &ctrlpoints[0][0][0]);
glMap2f(GL_MAP2_COLOR_4, 0, 1, 4*model->columnCount(), model->rowCount(), 0, 1, 4, model->columnCount(),&ctrlpointsColor[0][0][0]);
glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0);
glEvalMesh2(GL_FILL, 0, 20, 0, 20);

BionicBytes
02-13-2013, 11:49 AM
I think you're going to have to supply more detail than " it does not work". What do you see ?
Post your vertex array setup code and draw code.
Perhaps even read the posting guidelines?