OpenGL SolidTeapot() how to place it in 3d world

ok,

so i have a teapot in my 3d world.

however, from my only ever experiences of using the teapot, when drawn it only ever appears at the centre of the world.

is there any code to move it to my desired location in the 3d world?

thanks

Using glTranslate*() and glRotate*() is the easiest way to change an objects position and orientation in 3d space. You can also scale an object using glScale*().

How that works is explained in detail in the red book, v1.1 is available at http://fly.cc.fer.hr/~unreal/theredbook/chapter03.html

yeah, i am familair with glTranslate()

but when i tried doing that with the teapot it didnt respond. the code i used is below:

void teapot()
{
glPushMatrix();
glBegin();
glutSolidTeapot(2.0f);
glTranslate(10,5.0,10.0);
glPopMatrix();
glEnd();
}

try to change the glTranslate…
change the 10.0 to -10.0…
when you move the objects from screen to forward you use negative values…

Ok i am having a few problems with this code

  1. glBegin(THIS PART NEEDS FILLING!) <- any idea what to put for the teapot? cause it cant be gl_quads for example… or can it?
    2)even if i remove glBegin, the teapot is still at the centre :frowning:

First, glutSolidTeapot renders a teapot. Calling glBegin/End around it will not work; it does the equivalent of this internally.

Second, glTranslate and glPopMatrix cannot be called within glBegin/End.

Third, calling glTranslate after rendering does nothing. All calls are executed in the order given. Changing the translation after you’ve rendered the thing is unhelpful.

Ok, got it, so how would i place (translate) the teapot before i call it?

By issuing glTranslatef before the gludSolidTeapot command.

wow, that works, can’t believe I didnt think of that.

thanks mate :slight_smile: