# Vertex array NEED help!!

4 replies to this topic

### #1evl_one

New Member

• Members
• 3 posts

Posted 11 June 2005 - 06:18 PM

hi folks,

I visit often this forum and learn alot about Opengl.

So I try to learn to use OpenGL. Most of the time i use gvertex3f to plot some polygons on the screen. But its to slow when I try to plot more then 20 K polygon to the screen.

I read alot of vertex array. they told me that its alot faster then the normal way so I make some example to test it. When the test code is ready i dont see i thing on my screen.

Can somebody tell me what I'm doing wrong???

ps : sorry for my bad english

ps2 : this is a piece of my code


static GLfloat corners[] = { -25.0f, 25.0f, 25.0f, // 0 // Front of cube

25.0f, 25.0f, 25.0f, // 1

25.0f, -25.0f, 25.0f,// 2

-25.0f, -25.0f, 25.0f,// 3

-25.0f, 25.0f, -25.0f,// 4 // Back of cube

25.0f, 25.0f, -25.0f,// 5

25.0f, -25.0f, -25.0f,// 6

-25.0f, -25.0f, -25.0f };// 7

// Array of indexes to create the cube

static GLubyte indexes[] = { 0, 1, 2, 3,   // Front Face

4, 5, 1, 0,   // Top Face

3, 2, 6, 7,   // Bottom Face

5, 4, 7, 6,   // Back Face

1, 5, 6, 2,   // Right Face

4, 0, 3, 7 };  // Left Face

void render(void)
{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Make the cube a wire frame
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

// Save the matrix state
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(0.0f, 0.0f, -200.0f);
// Rotate about x and y axes
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 0.0f, 1.0f);

// Enable and specify the vertex array
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, corners);

// Using Drawarrays

glPopMatrix();

glFlush();
}



### #2Reedbeta

DevMaster Staff

• 5340 posts
• LocationSanta Clara, CA

Posted 11 June 2005 - 06:42 PM

I don't see anything wrong in the code you've posted. Does it work if you replace the glDrawElements line by a glVertex loop (without changing any other code)?
reedbeta.com - developer blog, OpenGL demos, and other projects

### #3evl_one

New Member

• Members
• 3 posts

Posted 12 June 2005 - 11:47 AM

Reedbeta said:

I don't see anything wrong in the code you've posted. Does it work if you replace the glDrawElements line by a glVertex loop (without changing any other code)?

I solve my problem :D

i change the value from 25.0f to 2.0f and the translate to -10.0f.

But i dont get it. If i try to translate the cube to -20.0f(Z-as) then i cant see the cube. I think its something with the Depth filter.. can some one please help me out of this. ??

### #4Reedbeta

DevMaster Staff

• 5340 posts
• LocationSanta Clara, CA

Posted 12 June 2005 - 04:00 PM

Ahh. Probably your far plane was set too close, so everything was getting culled.
reedbeta.com - developer blog, OpenGL demos, and other projects

### #5evl_one

New Member

• Members
• 3 posts

Posted 13 June 2005 - 07:05 AM

Reedbeta said:

Ahh. Probably your far plane was set too close, so everything was getting culled.

Thx it working :D

D@mn you guys are very helpfull.

grtz

evl_one

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users