Home » Android » android – OpenGL matrices – cannot figure correct ones

android – OpenGL matrices – cannot figure correct ones

Posted by: admin May 14, 2020 Leave a comment


Edit: Summarizing what I want to do, more concise:

Render a texture of size wi,hi to an output texture wo,ho, so that the aspect ratio of input texture is maintained, and it fits inside the output texture, eventually with black borders if aspect ratio is different. For this I want to use a perspective projection, as I may rotate or apply other transforms to the input texture.

Then I want this output texture to be displayed on screen, with size ws, hs, where hs may be larger than ws. Again, maintaining aspect ratio and fitting with black borders. Here an orthogonal projection should be enough, as only rendering to screen is required, no further processing.

I want to do it without hacks, in order to make my life easier in case I want later to rotate, scale the original texture. I can figure by trial and error how to modify the parameters to get what I want now, but would rather use each matrix in the way it is intended.

How to&Answers: