glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
uint uiIndices[3]={0,1,2};
float vertex[12]={-1.0f,1.0f,0.0f, -1.0f,-1.0f,0.0f, 1.0f,1.0f,0.0f};
glVertexPointer( 3, GL_FLOAT, 0, vertex );
glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, uiIndices );
Thanks for your help
Lutz Hören
Punika
[EDITED:] GL_VERTEX_ARRAY is enabled !
[ Power Productions ]
Edited by - Punika on April 6, 2001 9:10:57 AM
Stupid Vertex Buffer Question
Hi,
at the moment I want to figure out how to use the Vertex Buffer with glDrawElements. My problem is that this code don`t draw anything but I don`t know why. What`s wrong with it ?
Punika
It seems that you have an array size of 12, when it''s only supposed to hold 9.
try changing:
float vertex[12]={-1.0f,1.0f,0.0f, -1.0f,-1.0f,0.0f, 1.0f,1.0f,0.0f};
to:
float vertex[9]={-1.0f,1.0f,0.0f, -1.0f,-1.0f,0.0f, 1.0f,1.0f,0.0f};
try changing:
float vertex[12]={-1.0f,1.0f,0.0f, -1.0f,-1.0f,0.0f, 1.0f,1.0f,0.0f};
to:
float vertex[9]={-1.0f,1.0f,0.0f, -1.0f,-1.0f,0.0f, 1.0f,1.0f,0.0f};
Yes, but that`s not the problem. I changed it to 12 when I have tried a quad. At the moment I am changing it to 9. But the same result. No, drawing
Punika
Learning by doing

Punika
Learning by doing

Punika
Well, i dont use the draw elements function, though in delphi, i do something like this:
glVertexPointer(3,GL_FLOAT,0,@VERTEX_ARRAY);
glDrawArrays(GL_POLYGON,0,PointCount);
where @VERTEX_ARRAY is a pointer to my VERTEX_ARRAY[9]
glVertexPointer(3,GL_FLOAT,0,@VERTEX_ARRAY);
glDrawArrays(GL_POLYGON,0,PointCount);
where @VERTEX_ARRAY is a pointer to my VERTEX_ARRAY[9]
April 06, 2001 02:01 PM
quote:
Original post by Punika
Yes, but that`s not the problem. I changed it to 12 when I have tried a quad. At the moment I am changing it to 9. But the same result. No, drawing![]()
Punika
Learning by doing![]()
hmm, your code works fine for me
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity (); // Reset The Modelview Matrix
glTranslatef (0.0f, 0.0f, -6.0f);
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
unsigned int uiIndices[3]={0,1,2};
float vertex[9]={-1.0f,-1.0f,0.0f, -1.0f,1.0f,0.0f, 1.0f,1.0f,0.0f};
glVertexPointer( 3, GL_FLOAT, 0, vertex );
//glIndexPointer( GL_UNSIGNED_INT,0,uiIndices
glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, uiIndices );
glFlush ();
It really works but why is this stupid triangle black ?
Punika
Learning by doing
Punika
Learning by doing

Punika
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement