I have an input texture that is 852x640 and the output texture is 612x612. I pass the input through the shader and I want the result to scale and crop properly. I'm having trouble getting squareCoordinates , textureCoordinates and viewPorts to work together.
I donβt want to just crop, I want to scale it to maximize the maximum possible number of images. If I used Photoshop, I would do it in two steps (in OpenGL I try to do it in one step):
- Zoom in to 612x814
- Trim excess 101px on each side
I use standard square vertices and texture vertices:
static const GLfloat squareVertices[] = { -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, }; static const GLfloat squareTextureVertices[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f }
I donβt know exactly what viewPort should be.
source share