PDA

View Full Version : Which Primitives Should I Use?



rpminihan
11-27-2002, 11:00 AM
Hello,

I'm quite an OpenGL newbie so please bear with me. I'm tying to render 60 vertices. They represent signal strength values on a ground penetrating radar scan. The x and y data makes a regular grid. I want the vertices color to represent signal strength. I have code that is plotting the points at the desired locations in the proper color.

What I want to do now, is connect all the points with smooth colors, so that I have a solid surface. I've been working with GL_QUADS, but I suspect that I'm sending the vertex data incorrectly, because I'm getting very strange results.

Here's a code snippet:

glBegin(GL_QUAD_STRIP);
for(i=0;i<60;i++){
if(vertex[i].data == 173)
glColor3f(1.0,1.0,1.0);
else if(vertex[i].data == 174)
glColor3f(1.0,0.0,0.0);
else if(vertex[i].data == 175)
glColor3f(0.0,1.0,0.0);
else if(vertex[i].data == 176)
glColor3f(0.0,0.0,1.0);
else if(vertex[1].data == 177)
glColor3f(1.0,0.0,1.0);
glVertex2f(vertex[i].x,vertex[i].y);
}
glEnd();


Any suggestions?

kehziah
11-27-2002, 02:08 PM
How is your data organized? I guess you have in your array the n vertices for the first row, then the n vertices for the second etc... (n is the width of your grid)

If so, if you want a solid grid (that is, a colored rectangle), you should submit your vertices in a different order from what you are doing now :
that would be something like :

for (j=0;j<nRows-1;j++)
{
for (i=0; i<n-1; i++)
{
vert[j*n+i]
vert[j*n+i+1]
vert[j*n+i+n+1]
vert[j*n+i+n]
}
}

[This message has been edited by kehziah (edited 11-27-2002).]