View Full Version : OpenGL SolidTeapot() how to place it in 3d world
08-18-2011, 10:12 AM
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?
08-18-2011, 11:14 AM
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
08-18-2011, 11:51 AM
yeah, i am familair with glTranslate()
but when i tried doing that with the teapot it didnt respond. the code i used is below:
08-18-2011, 12:37 PM
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....
08-18-2011, 01:03 PM
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 :(
08-18-2011, 01:21 PM
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.
08-18-2011, 02:53 PM
Ok, got it, so how would i place (translate) the teapot before i call it?
08-18-2011, 02:57 PM
By issuing glTranslatef before the gludSolidTeapot command.
08-18-2011, 03:52 PM
wow, that works, can't believe I didnt think of that.
thanks mate :)
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.