Skip to main content
Changed code to do divison on floats to prevent precision loss from floor (integer) division.
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61

Okay, I finally figured it out!

I changed

Matrix.orthoM(projection, 0, 0, windowWidth, 0, windowHeight, -1, 1);

to

float ratio = static_cast<float>(windowWidth) / static_cast<float>(windowHeight); Matrix.orthoM(projection, 0, 0, (float) windowWidth / (float) windowHeightratio, 0, 1, -1, 1); 

I then had to scale my projection matrix to make it a lot smaller with Matrix.scaleM(projection, 0, 0.05f, 0.05f, 1.0f);.

I then added an offset to the modelview translations to simulate a camera so that I could center on the action (so Matrix.translateM(modelview, 0, quadX, quadY, 0); was changed to Matrix.translateM(modelview, 0, quadX + camX, quadY + camY, 0);)

Thanks for the help, all!

Okay, I finally figured it out!

I changed

Matrix.orthoM(projection, 0, 0, windowWidth, 0, windowHeight, -1, 1);

to

Matrix.orthoM(projection, 0, 0, (float) windowWidth / (float) windowHeight, 0, 1, -1, 1); 

I then had to scale my projection matrix to make it a lot smaller with Matrix.scaleM(projection, 0, 0.05f, 0.05f, 1.0f);.

I then added an offset to the modelview translations to simulate a camera so that I could center on the action (so Matrix.translateM(modelview, 0, quadX, quadY, 0); was changed to Matrix.translateM(modelview, 0, quadX + camX, quadY + camY, 0);)

Thanks for the help, all!

Okay, I finally figured it out!

I changed

Matrix.orthoM(projection, 0, 0, windowWidth, 0, windowHeight, -1, 1);

to

float ratio = static_cast<float>(windowWidth) / static_cast<float>(windowHeight); Matrix.orthoM(projection, 0, 0, ratio, 0, 1, -1, 1); 

I then had to scale my projection matrix to make it a lot smaller with Matrix.scaleM(projection, 0, 0.05f, 0.05f, 1.0f);.

I then added an offset to the modelview translations to simulate a camera so that I could center on the action (so Matrix.translateM(modelview, 0, quadX, quadY, 0); was changed to Matrix.translateM(modelview, 0, quadX + camX, quadY + camY, 0);)

Thanks for the help, all!

Changed code to do divison on floats to prevent precision loss from floor (integer) division.
Source Link

Okay, I finally figured it out!

I changed

Matrix.orthoM(projection, 0, 0, windowWidth, 0, windowHeight, -1, 1);

to

float ratio = windowWwidth / windowHeight; Matrix.orthoM(projection, 0, 0, ratio(float) windowWidth / (float) windowHeight, 0, 1, -1, 1); 

I then had to scale my projection matrix to make it a lot smaller with Matrix.scaleM(projection, 0, 0.05f, 0.05f, 1.0f);.

I then added an offset to the modelview translations to simulate a camera so that I could center on the action (so Matrix.translateM(modelview, 0, quadX, quadY, 0); was changed to Matrix.translateM(modelview, 0, quadX + camX, quadY + camY, 0);)

Thanks for the help, all!

Okay, I finally figured it out!

I changed

Matrix.orthoM(projection, 0, 0, windowWidth, 0, windowHeight, -1, 1);

to

float ratio = windowWwidth / windowHeight; Matrix.orthoM(projection, 0, 0, ratio, 0, 1, -1, 1); 

I then had to scale my projection matrix to make it a lot smaller with Matrix.scaleM(projection, 0, 0.05f, 0.05f, 1.0f);.

I then added an offset to the modelview translations to simulate a camera so that I could center on the action (so Matrix.translateM(modelview, 0, quadX, quadY, 0); was changed to Matrix.translateM(modelview, 0, quadX + camX, quadY + camY, 0);)

Thanks for the help, all!

Okay, I finally figured it out!

I changed

Matrix.orthoM(projection, 0, 0, windowWidth, 0, windowHeight, -1, 1);

to

Matrix.orthoM(projection, 0, 0, (float) windowWidth / (float) windowHeight, 0, 1, -1, 1); 

I then had to scale my projection matrix to make it a lot smaller with Matrix.scaleM(projection, 0, 0.05f, 0.05f, 1.0f);.

I then added an offset to the modelview translations to simulate a camera so that I could center on the action (so Matrix.translateM(modelview, 0, quadX, quadY, 0); was changed to Matrix.translateM(modelview, 0, quadX + camX, quadY + camY, 0);)

Thanks for the help, all!

Source Link

Okay, I finally figured it out!

I changed

Matrix.orthoM(projection, 0, 0, windowWidth, 0, windowHeight, -1, 1);

to

float ratio = windowWwidth / windowHeight; Matrix.orthoM(projection, 0, 0, ratio, 0, 1, -1, 1); 

I then had to scale my projection matrix to make it a lot smaller with Matrix.scaleM(projection, 0, 0.05f, 0.05f, 1.0f);.

I then added an offset to the modelview translations to simulate a camera so that I could center on the action (so Matrix.translateM(modelview, 0, quadX, quadY, 0); was changed to Matrix.translateM(modelview, 0, quadX + camX, quadY + camY, 0);)

Thanks for the help, all!