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 10 of 12

Thread: glVertexAttribP4uiv

Hybrid View

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207

    glVertexAttribP4uiv

    i have been trying to use glVertexAttribP with GL_UNSIGNED_INT_2_10_10_10_REV but stuck up at some point.

    here is my code

    Code :
    GLuint red=0,green=511,blue=511,alpha=3;
    	GLuint val = 0;
     
    	val = val | (alpha << 30);
    	val = val | (blue << 20);
    	val = val | (green << 10);
    	val = val | (red << 0);
    	GLfloat vertices[]={-0.9f, -0.9f, 0.0f,1.0f,
    						 -0.9f, 0.6f, 0.0f,1.0f,
    						 0.6f,0.6f,0.0f,1.0f,
    						 0.6f,-0.9f,0.0f,1.0f};
     
     
    	GLuint test_data[]={val,val,val,val};
    	glGenBuffers(1, &BufferId);
    	glBindBuffer(GL_ARRAY_BUFFER, BufferId);
    	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
     
    	glEnableVertexAttribArray(glGetAttribLocation(shader_data.psId,"position"));
    	glVertexAttribPointer(glGetAttribLocation(shader_data.psId,"position"), 4,GL_FLOAT,GL_FALSE, 0,0);
     
     
    	glGenBuffers(1, &BufferId1);
    	glBindBuffer(GL_ARRAY_BUFFER, BufferId1);
    	glBufferData(GL_ARRAY_BUFFER, sizeof(test_data), test_data, GL_STATIC_DRAW);
     
    	glEnableVertexAttribArray(glGetAttribLocation(shader_data.psId,"color"));
    //	glVertexAttribPointer(glGetAttribLocation(shader_data.psId,"color"), 4,GL_INT_2_10_10_10_REV,GL_TRUE, 0,0);
          glVertexAttribP4uiv(glGetAttribLocation(shader_data.psId,"color"),GL_UNSIGNED_INT_2_10_10_10_REV ,GL_TRUE,0);
     
     
    	glDrawArrays(GL_TRIANGLE_FAN,0,4);

    it gives Access violation at glDraw call. code works fine with glVertexAttribPointer. what am i missing here?
    Last edited by debonair; 05-16-2013 at 03:37 AM.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    `glEnableVertexAttribArray` says that you're using an array for that attribute. But you're not using an array. So OpenGL tries to access an array that you haven't specified. Hence the boom.

    Disable the array instead of enabling it.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    thanks for the quick one..
    Now, i commented glEnableVertexAttribArray() call keeping rest same. now i get a black color..

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Quote Originally Posted by Alfonse Reinheart View Post
    `glEnableVertexAttribArray` says that you're using an array for that attribute. But you're not using an array. So OpenGL tries to access an array that you haven't specified. Hence the boom.

    Disable the array instead of enabling it.
    when i comment glEnableVertexAttribArray() i get a black color. Seems that it fails to take color values.

  5. #5

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Quote Originally Posted by Alfonse Reinheart View Post
    You get black because that's what you set the color to.
    Sorry, i didn't get you.
    I am setting it to non zero values though red, green, blue variables in my code and finally doing bit-wise operations. Please correct me if wrong.

  7. #7
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Then show the statement where you're doing that. It isn't in the code you posted:

    Code :
    glVertexAttribP4uiv(glGetAttribLocation(shader_data.psId,"color"),GL_UNSIGNED_INT_2_10_10_10_REV ,GL_TRUE,0);

    That sets the value to 0. Which means that it's 0 for all four components.

Posting Permissions

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