OpenGL Scaling Matrix

Started by
3 comments, last by X Abstract X 14 years, 1 month ago
Hello, I'm trying to figure out how to perform scaling in OpenGL using my own scaling matrix but it isn't producing the expected results. Right now I've got my translations working but can't seem to scale properly. This is what I'm doing: I have a 4x4 identity matrix stored as a 16-element array of doubles. When I want to scale, I replace index 0 with the x-scaling factor, index 5 with the y-scaling factor and index 10 with the z-scaling factor. Then, I multiply the OpenGL modelview matrix by my scaling matrix. Am I doing something wrong? If it matters, I'm working in ortho.
Advertisement
Quote:When I want to scale, I replace index 0 with the x-scaling factor, index 5 with the y-scaling factor and index 10 with the z-scaling factor.

Then, I multiply the OpenGL modelview matrix by my scaling matrix.
That sounds right to me. In what way is it not working?
Well, I'm just drawing a simple triangle. The triangle will be moved/scaled way too big/out of view completely. I can't pinpoint exactly what is happening, it's kind of random.

Even if I multiply the modelview matrix by an identity matrix, the triangle becomes about 5x larger.

Edit: Solved and thanks for your reply.
Quote:Edit: Solved and thanks for your reply.
Multiplication order problem, perhaps?

Anyway, maybe you could post how you solved it (it could be useful to others who might read the thread).
It was just an error when setting up the identity matrices. Was accidentally filling it entirely with 1.0's.

This topic is closed to new replies.

Advertisement