c++ - glTranslatef moves diagonally instead of on major axes -


i want move object on x axis on key press. looks moving diagonally(up left , down right) here code : key press code :

switch(key) { case 'a': x++; break;  case 'b': x--; break; } 

on opengl part :

glmatrixmode(gl_projection);     glloadidentity();    gluperspective(30, 1 , 1 , 1000);     glmatrixmode(gl_modelview); glloadidentity();   glulookat(100, 100, 100, 0, 0, 0,  0, 1, 0); gltranslatef(x;0,0); 

why gltranslatef working strangely, how can fix this? thanks.

you're rotating before translate. rotate entire coordinate space , "translation along x axis" different.

in future, make sure translate, scale, rotate. way each transformation intend without being manipulated prior transformation. suggest matrices, coordinate spaces, , opengl bit more.

also, gltranslatef , other matrix stack functions deprecated. modern opengl.

edit:

glulookat rotation face @ point. so, there rotation involved. switch them around if don't want this. also, isn't full code, it's missing glmatrixmode calls.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -