PDA

View Full Version : Create objects and keep them based on the data from outside?



orchis
11-23-2005, 04:52 PM
hi,
I want to get the float data from visual basic program in fixed period and creat objects by these data. How can i keep and display the different objects?

float y;
void CALLBACK readdata( float x)
{
y=x;
}
drawobjects()
{

gltranslatef(0,0,y);
glutSolidCube(1.0);
}
//end

as describe above,the argc y changes from time to time. So ,how to model ten Cubes across z axis?

thank you very much.

Zulfiqar Malik
11-23-2005, 10:53 PM
This is not an advanced question!

Use matrix stacks e.g.
// draw first cube
glPushMatrix();
glTranslatef(0, 0, y1);
DrawCube(...);
glPopMatrix();

// draw second cube
glPushMatrix();
glTranslatef(0, 0, y2);
DrawCube(...);
glPopMatrix();

I hope you can figure out the rest.
I answered this in hope that you will post such questions on the beginner's forum in the future.