Hi guys I am really new in OpenGL-ES and I am developing a simple android application with NDK, and I just want to ask why the image is not fit after I set the width and height of it.
this is my
const int FIXED_WIDTH = 320; const int FIXED_HEIGHT = 568;
and this is how I set my
glViewport(0, 0, width, height); // Create a new perspective projection matrix. The height will stay the same // while the width will vary as per aspect ratio. float left = FIXED_WIDTH; float right = 0.0f; float bottom = FIXED_HEIGHT; float top = 0.0f; float near = 1.0f; float far = 50.0f; mProjectionMatrix = Matrix::newFrustum(left, right, bottom, top, near, far); // Position the eye in front of the origin. float eyeX = 0.0f; float eyeY = 0.0f; float eyeZ = 1.0f; // We are looking at the origin float centerX = 0.0f; float centerY = 0.0f; float centerZ = 0.0f; // Set our up vector. float upX = 0.0f; float upY = 1.0f; float upZ = 0.0f; // Set the view matrix. mViewMatrix = Matrix::newLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ); // model * view * projection mMVPMatrix->multiply(*mProjectionMatrix, *mViewMatrix);
After setting the
Matrix I thought that my point 0.0 will start at the top right corner of the device (This is my understanding of matrix). as you shown in the image.
and this is how I setup my
TextureGenerator* textureGenerator = new TextureGenerator(); textureGenerator->setSize(320.0f, 568.0f); // width and height textureGenerator->setTranslate(0.0f, 0.0f); // X and Y textureGenerator->setTextureId(GLUtils::loadTexture("bg.jpg")); mTextureCollection.push_back(textureGenerator);
then after I add some
texture this is the result.
This is the actual picture, size 320x568.
as you can see to the result of my doing, I don't know if my point 0.0 is starting at the center. Please someone help and explain to me why the texture is not fit, and if my
matrix is correctly set or not. Thank you.