PDA

View Full Version : Transformations using a vertex array



legendkiller
11-01-2004, 07:11 AM
I have created an object using a vertex array as follows.


void draw_pot(void){
GLdouble ShapeVertexArray[30] = {95,80,80,130,140,130,125,80};
glBegin(GL_POLYGON);
for (int i=0;i<4;i++)
glVertex2d(ShapeVertexArray[2*i],ShapeVertexArray[2*i+1]);
glEnd();

}I then call the function.


void DrawGLScene(GLvoid) {


glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(0.5,1,1);
glPushMatrix();
draw_pot();-function called.
glrotatef(90,1,0,0);
glPopMatrix;
glColor3f(0,1,0);
draw_stem();
//drawCircle();
draw_petal();
glFlush();As you can see i have tried to draw the pot and then create another instance of the pot in a different place but have been unsuccessful.

Any ideas?

gmeed
11-01-2004, 09:07 AM
In the code in your post, you only draw it once. Did you mean to call draw_pot again between the rotate and popmatrix calls?

p.s. careful with the terminology - you're storing vertices in an array, but you aren't using it as a vertex array, as in glDrawArrays.

legendkiller
11-01-2004, 09:16 AM
I did mean to call it again. How do i store it in a vertex array instead of an array?

legendkiller
11-01-2004, 09:34 AM
How do i use glDrawArrays?

Aeluned
11-01-2004, 09:44 AM
oh c'mon...

there's documentation all over the place...
google 'glDrawArrays', you'll get mucho hits.

opcode
11-02-2004, 06:55 AM
Do yourself a favor and buy the red book.

http://www.amazon.com/exec/obidos/tg/det...=glance&s=books (http://www.amazon.com/exec/obidos/tg/detail/-/0321173481/ref=pd_bxgy_img_2/102-4465387-7633754?v=glance&s=books)

Then, do us all a favor and buy the blue book.

http://www.amazon.com/exec/obidos/tg/det...=glance&s=books (http://www.amazon.com/exec/obidos/tg/detail/-/032117383X/ref=pd_bxgy_img_2/102-4465387-7633754?v=glance&s=books)

You'll be rockin' with vertex arrays in no time, you may even use display lists too.