🔒 Locked
Texture rotation problem
Advertisement
Original Post
hi there. well, here is my problem. let's say i have a planar mesh made up of severel triangles, with the righ texture coordinates(meaning that, when i apply a texture, it applies to my mesh like to a single quad, with mesh corners to texture corners). now i'm trying to rotate the texture around the mesh middle point, so i write; glMatrixMode(GL_TEXTURE); glTranslate(0.5, 0.5, 0); glRotate(myAngle, 0.0, 0.0, 1.0); glTranslate(-0.5, -0.5, 0); glMatrixMode(GL_MODELVIEW); the texture is rotating indeed, but an unwanted efect appears, it is getting skewed really bad. to test it, there is a little rectangle drawn in the middle of the texture. when the texture is rotating, the rectangle becames a parallelogram, then a long rectangle(crossing textures' borders) then another parallelogram and then the normal rectangle. i pretty understood that this is a normal thing to happen, but can anyone tell me how to avoid it?
hi there. thanks for looking to my problem. so a few answers first:
1.yes, i am pushing and popping the texture matrix
2.no, GL_REPEAT, GL_CLAMP and all other modes are doing the same result
3.no, is not about parallel projection
4.some screenshots, as you request
1.initial state

2.after aprox.80-90 degrees of rotation

3.after aprox 200 degrees of rotation

that's it. i hop it helps
1.yes, i am pushing and popping the texture matrix
2.no, GL_REPEAT, GL_CLAMP and all other modes are doing the same result
3.no, is not about parallel projection
4.some screenshots, as you request
1.initial state
2.after aprox.80-90 degrees of rotation
3.after aprox 200 degrees of rotation
that's it. i hop it helps
A bit offtopic: You actualy have to put images on some server to show them. You can't just link to C:\image.jpg.
This works fine for me:
Enigma
#include <GL/glut.h>#include "Texture.h"float angle = 0;void reshape(int width, int height){ if (height == 0) { height = 1; } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, width, height); gluPerspective(45.0f, GLfloat(width) / GLfloat(height), 0.1f, 50.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}Texture tex;void display(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0, 0, -25); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glTranslatef(0.5, 0.5, 0); glRotatef(angle, 0, 0, 1); glTranslatef(-0.5, -0.5, 0); angle += 1; glMatrixMode(GL_MODELVIEW); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(-5, -5); glTexCoord2f(1, 0); glVertex2f(5, -5); glTexCoord2f(1, 1); glVertex2f(5, 5); glTexCoord2f(0, 1); glVertex2f(-5, 5); glEnd(); glutSwapBuffers();}int main(int argc, char** argv){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(0, 0); glutInitWindowSize(512,512); glutCreateWindow("Texture Rotation Test"); glutReshapeFunc(reshape); glutDisplayFunc(display); glutIdleFunc(display); tex.loadBmp("img3.bmp"); glEnable(GL_TEXTURE_2D); glutMainLoop(); return 0;}Enigma
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement