JAVA - LWJGL - Texture rotation -


can tell me real quick how rotate texture var degrees in lwjgl when have coordinates , origin? well, looks right now: x/y center of texture.

public void render(float x, float y) {     glpushmatrix();     texture.bind();      gltranslatef(x - xorigin, y - yorigin, 0);      //this false. ignore     //glrotatef(45f, 0f, 0f, 1f);      glbegin(gl_quads);     {         gltexcoord2f(0, 0);         glvertex2f(0, 0);          gltexcoord2f(0, width);         glvertex2f(0, height);          gltexcoord2f(texture.getwidth(), texture.getheight());         glvertex2f(width, height);          gltexcoord2f(texture.getwidth(), 0);         glvertex2f(width, 0);     }     glend();      glpopmatrix(); } 

thanks

if want rotate textures need change uv coordinates, thereby rearranging gltexcoord2f(u, v) though rearranging them rotate them 90deg/1.57rad per rearrange, though if want smaller rotations of texture, can calculate u, v coordinates using trigonometry cos , sin functions.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -