java - glRotatef works on multiple objects -
basicly want open door , thought of using glrotatef. problem is affecting every object drawn after it. know how stop ?
door.class
public static void draw(texture door) { door.bind(); if(door_test.state == "out" && d != 90){ glrotatef(i, 0, 1, 0); i+=5; } glbegin(gl_quads); glcolor3f(1f, 1f, 1f);gltexcoord2f(0,0);glvertex3f(-2,3, -15); glcolor3f(1f, 1f, 1f);gltexcoord2f(0,1);glvertex3f(-2,-3, -15); glcolor3f(1f, 1f, 1f);gltexcoord2f(1,1);glvertex3f(2,-3, -15); glcolor3f(1f, 1f, 1f);gltexcoord2f(1,0);glvertex3f(2,3, -15); glend(); }
when rotate, rotates entire scene. rotate single object, rotate entire scene, draw object, rotate screen back.
glrotatef(i, 0, 1, 0); // draw object. glrotatef(-i, 0, 1, 0);
as reto koradi pointed out, if continually might have floating point rounding errors accumulate on time. holyblackcat's answer offers better solution.
Comments
Post a Comment