Sprite without glOrtho
I've been trying to get sprites to work without the use of glOrtho. I got them to work fine for placing them on screen and converting my screen coordinates to the correct coord, having them face the camera etc. My problem is rotation. Obviously, I know that the rotation has to be on the origin but my problem is that when I try to rotate the sprite, it becomes distorted. A 90 degree rotation really squash the sprite, 45 degrees has it sort of looking sideway etc. Any help on this would be appreciated because it's really bugging me.
er.. u mentioned 'having them face the camera' but that would require rotation. So how did that work if this other rotation doesn't?
anyway, it looks like either a transformation order or transform state problem. Some existing code snippet would be handy to debug though, coz right now its just a random guess.
anyway, it looks like either a transformation order or transform state problem. Some existing code snippet would be handy to debug though, coz right now its just a random guess.
Well, I have a quad with say :
npos.UpperLeftCorner.X = -0.5;
npos.UpperLeftCorner.Y = 0.5;
npos.LowerRightCorner.X = 0.5;
npos.LowerRightCorner.Y = -0.5;
I slap a texture on it, and rotate it with glRotatef. Anyway, I've given it some thought and I guess it was obvious. The screen is say 1.0 in length from the center of the screen in both directions. Now, I have to convert the "normal" x,y coordinates for a 640x480 window to fit 1 for 640 and 1 for 480 ratio. That works perfectly, but when I rotate it, the relative value of the "1" I used is shifting from say 640:1 toward 480:1.
Meh, it's obvious in retrospective but I just whish someone else using irrlicht had figured out before why it wasn't working and left traces of the answer too :p.
PS: Thanks a lot for the help =)
npos.UpperLeftCorner.X = -0.5;
npos.UpperLeftCorner.Y = 0.5;
npos.LowerRightCorner.X = 0.5;
npos.LowerRightCorner.Y = -0.5;
I slap a texture on it, and rotate it with glRotatef. Anyway, I've given it some thought and I guess it was obvious. The screen is say 1.0 in length from the center of the screen in both directions. Now, I have to convert the "normal" x,y coordinates for a 640x480 window to fit 1 for 640 and 1 for 480 ratio. That works perfectly, but when I rotate it, the relative value of the "1" I used is shifting from say 640:1 toward 480:1.
Meh, it's obvious in retrospective but I just whish someone else using irrlicht had figured out before why it wasn't working and left traces of the answer too :p.
PS: Thanks a lot for the help =)
On another note, I can see that I could rotate my original screen coordinate myself and then translate them to ogl coordinates but I'd have to do that all the time in software. I was wondering if I couldn't just setup a matrix that would do the conversion instead? I really don't quite know how that would work tho ;(. I suppose I'd have to work on it but if someone knows the answer it would save me a lot of time =).
Edit: ok, it was pretty easy, sorry for the trouble :p
[Edited by - Dark Rain on October 20, 2005 6:58:12 AM]
Edit: ok, it was pretty easy, sorry for the trouble :p
[Edited by - Dark Rain on October 20, 2005 6:58:12 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement