I am trying to impliment a vertex program to draw a tri-strip along a list of points(segment list). I am attempting to use vertex attributes to accomplish this. What I am currently doing is just creating a vertex array for all the points I need and then moving them to the correct point when I reach the vertex program. I am passing the list of points for the segment list as attributes for each vertex.
I know that the data in the vertex arrays are correct since I have a function to do what I want the shader to do which I have run on the vertex data and seen the correct results. This leads me to believe that the attribute data that I am passing is incorrect or currupt.
I am currently using an nVidia 5950 ultra with vers 56.72 drivers.
Here are the basics of what I have now:
#define SEGLIST_POINT_ARRAY 3
//I create the attribute array
pASegListPoints = new GLfloat[(nNumVerts * NUM_FLOATS_PER_VERT) * 2];
//Then bind the attribute
glBindAttribLocationARB(ShaderObject, SEGLIST_POINT_ARRAY, "SegListPoint");
//I then fill the array with the data
//I then set the attrib pointer up
glVertexAttribPointerARB(SEGLIST_POINT_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, pASegListPoints);
//Enable vertex array
//Enable the attribute
//Draw the tri-strip
glDrawArrays(GL_TRIANGLE_STRIP, 0, nNumVerts*2);
//Disable the states
varying vec4 Color;
attribute vec3 SegListPoint;
vec4 vert = vec4(SegListPoint, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * vert;
Color = (0.0, 1.0, 0.0, 1.0);
varying vec4 Color;
gl_FragColor = Color;
The result I get is a randomly flashing white screen with an occasional randomly shaped poly coming from the origin. I figure I should at the very least be getting a randomly flashing BLUE screen. I can’t seem to figure out what the problem is.
You need to link the progam after you have assigned attributes.
See the ARB_vertex_shader spec:
“In order to have attribute bindings take effect the program object needs
to be linked after issuing the BindAttribLocationARB command. The linker
will bind any active attributes not already explicitly specified through
BindAttribLocationARB. After a successful link the complete list of
bindings can be queried using the command GetAttribLocationARB.”
If this is not working, try a newer driver of the 60.xx series.
Linking it makes it look a whole lot better but it is still white and has some verts way off in lala land off screen. The basic shape seems to resemble what I am looking for though.
Maybe it’s the driver version. I have been trying for about 4 months now to get nVidia to give me a developers login so I can get a hold of thier new beta drivers and software but I can’t even get them to reply to my email. Is there any other way to get a hold of the beta drivers?
Try googling, I found this site which looks very well sorted: http://download.guru3d.com/detonator/
Use at your own risk.
You need to bind to attribute position 0 when sending position data.
I am actually just using the segment list position data as the referance point to do other things. I simplified the code for this post. I also simplified the code to try and narrow down what could be causing the problems.
What I am really trying to do is to create a spiral shape that follows the line segments. I am passing a direction vector, a normal vector (also containing width data), in addition to the segment point. I was rotating the vertex around the segment list points while moving it down the direction vector tward the next point. This created a tri-strip spiral down the segment list. It works as code so it should work as a shader.
If I have to bind position attributes to position 0 then what if I have two positions I am using as referance?
I just loaded forceware version 61.40 and the problem still persists.
The point is that the vertex shader is only invoked if attribute 0 is triggered. It doesn’t need to be anything special. You can put any data in any attribute if your shader takes care of the handling, but if you don’t use attrib 0 it won’t render anything. It’s the same as if you wouldn’t send glVertices in immediate mode.
Does the order matter? If attribute index 0 signals the completion of a vertex, what call signals that completion? I am assuming it isn’t the binding of the attribute that signals the completion since I do that before I even have an attribute array. So it must be either the glVertexAttribPointerARB call or the glEnableVetexAttribArray call. If this is the case do I have to call the index 0 attribute last in order for it to work correcly or does it matter? Does it signal that all the attribute arrays are completed and ready to be used?
Sorry, that’s a lot of questions. I was using the example for the particle systems in chapter 13 of the OpenGL Shading Language book as my example of how to use vertex arrays and they only seem to use index 3 and 4. I have now switched my code to use index 0 for my segment points but I am still getting white polys almost resembling the correct data but with some verts going off somewhere into the distance. White polys too, when I am explicitly setting the color to blue.
While setup pointers and enabling client states there is no any T&L work. T&L starts only when app call some of glDrawArrays, glDrawElements, glMultiDrawArraysEXT, glMultiDrawElements and glDrawRange calls.
You don’t have to worry about gl*Pointer order.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.