Reputation: 1303
Basically I create a 2d object in 3d space in OpenGL in C++. The way it's created it lies in y axis. How do I move it so it'll lie in x axis? I tried glRotatef and glTranslatef but it doesn't work. Anyone can help?
Update: I am actually making a solar system. The planets lie in x axis. But every time I try to draw the orbit for them by calling the following function, the circle always appear in y axis. I want it to be in x axis to coincide with the planet. I hope that clears things up.
void drawOrbit(float radius)
{
glBegin(GL_POLYGON_BIT);
glRotatef(90,1, 1.2, 1.0);
for (int i=0; i<360; i++)
{
float degInRad = i*DEG2RAD;
glVertex3f(radius * cos(degInRad), radius * sin(degInRad), 0.0);
glVertex3f(cos(degInRad)*radius,sin(degInRad)*radius, 0.1);
}
glScalef(0.5, 0.5, 0.5);
glTranslatef(-1.2, 1.2, 1.2);
glRotatef(60, 1.0, 1.2, 1.0);
glEnd();
}
Upvotes: 1
Views: 604
Reputation: 734
All scale/translate/rotate operations have to be done before glBegin, in reverse order. spirit: you first define the camera, then you go up to the objects in their local space.
Upvotes: 1