PDA

View Full Version : problem in glDrawArray



Dastagir
06-28-2010, 05:40 AM
hi,
code:

glDisable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer( 3, GL_FLOAT, 0, createdVertices );
glDrawArrays(GL_LINE_LOOP, 0,count);
glDisableClientState(GL_VERTEX_ARRAY);

i'm having an array of 40,00,000 vertices with start and end points.while displaying with gldrawarray some stranges line are present which i have not used to draw.i had checked my array values.everything is right.i had tried with small array at that time also its displaying some lines.

carsten neumann
06-28-2010, 07:40 AM
glDrawArrays(GL_LINE_LOOP, 0,count);

i'm having an array of 40,00,000 vertices with start and end points.


Those two statements seem contradictory. GL_LINE_LOOP will draw a single line through all the vertices given, while GL_LINES draws many lines, each from vertex i to i+1.
Did you perhaps mean glDrawArrays(GL_LINES, 0, count) ?

Dastagir
06-28-2010, 07:58 AM
http://cid-6a2ae6c2240ebc3b.photos.live.com/self.aspx/New%20album/pic.jpg

i have tried with small array but still some strange lines are present.i have tried with both GL_LINES and GL_LINE_LOOP but some lines r displaying.i have attached the picture with this

carsten neumann
06-28-2010, 09:16 AM
Hm, I'm not sure I understand the problem without the picture (I don't see it here or a link to it) or a more detailed description of your inputs and the expected and actual output.

Between which vertices are the additional lines?

If your vertices are [v0, v1, v2, v3, v4, v5]

you get with GL_LINES:
line0 v0 to v1
line1 v2 to v3
line2 v4 to v5

with GL_LINE_LOOP:
line0 v0 to v1
line1 v1 to v2 *
line2 v2 to v3
line3 v3 to v4 *
line4 v4 to v5

Dastagir
06-28-2010, 11:05 PM
pic1:My exact output

pic1 (http://cid-6a2ae6c2240ebc3b.photos.live.com/self.aspx/New%20album/pic.jpg)

http://cid-6a2ae6c2240ebc3b.photos.live.com/self.aspx/New%20album/pic.jpg

pic2:Some lines are present which i have not drawn

pic2 (http://cid-6a2ae6c2240ebc3b.photos.live.com/self.aspx/New%20album/pic2.jpg)

http://cid-6a2ae6c2240ebc3b.photos.live.com/self.aspx/New%20album/pic2.jpg


i have attached my two outputs pic.jpg is exact output i have used with glBegin and glEnd.when used the glDrawArrays i'm getting some lines.

My Code:

glClear(GL_COLOR_BUFFER_BIT);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer( 3, GL_FLOAT, 0,createdVertices );
glDrawArrays(GL_LINE_LOOP, 0,m_vertexNumber);
glDisableClientState(GL_VERTEX_ARRAY);
glFlush();

My Array:
4 5 0
4 6.932 0
4 6.932 0
3.97036 6.93177 0
3.97036 6.93177 0
3.94074 6.93109 0
3.94074 6.93109 0
3.91112 6.92995 0
3.91112 6.92995 0
3.88153 6.92836 0
3.88153 6.92836 0
3.85196 6.92632 0
3.85196 6.92632 0
3.82243 6.92382 0
3.82243 6.92382 0
3.79294 6.92087 0
3.79294 6.92087 0
3.7635 6.91747 0
3.7635 6.91747 0
3.73412 6.91362 0
3.73412 6.91362 0
3.7048 6.90931 0
3.7048 6.90931 0
3.67554 6.90456 0
3.67554 6.90456 0
3.64637 6.89936 0
3.64637 6.89936 0
3.61727 6.89371 0
3.61727 6.89371 0
3.58827 6.88762 0
3.58827 6.88762 0
3.55936 6.88108 0
3.55936 6.88108 0
3.53056 6.8741 0
3.53056 6.8741 0
3.50187 6.86668 0
3.50187 6.86668 0
3.4733 6.85882 0
3.4733 6.85882 0
3.44484 6.85052 0
3.44484 6.85052 0
3.41652 6.84179 0
3.41652 6.84179 0
3.38834 6.83262 0
3.38834 6.83262 0
3.3603 6.82302 0
3.3603 6.82302 0
3.33241 6.813 0
3.33241 6.813 0
3.30468 6.80254 0