Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: using GL_MAP2_COLOR_4 inOpenGL to change vertexe colors

  1. #1
    Newbie Newbie
    Join Date
    Feb 2013
    Posts
    1

    Question using GL_MAP2_COLOR_4 inOpenGL to change vertexe colors

    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?
    Code :
    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);

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,165
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •