Hello!
Im making a small Engine using Box2D and GLFW. But for some reason, everything is rendered quarterly only. Which mean they are rendered at left-bottom side:
(The ball should be in the center of the screen, and when i move, the platform just got cut off when it reached the middle of the screen)
This is my reshape code:
void Reshape(GLFWwindow*, int w, int h)
{
engine.width = w;
engine.height = h > 0 ? h : 1;
glViewport(0, 0, engine.width, engine.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float aspect = float(engine.width) / float(engine.height);
if (engine.width >= engine.height)
{
glOrtho(-engine.camera.zoom * aspect + engine.camera.position.x,
engine.camera.zoom * aspect + engine.camera.position.x,
-engine.camera.zoom + engine.camera.position.y,
engine.camera.zoom + engine.camera.position.y, -1.0, 1.0);
}
else
{
glOrtho(-engine.camera.zoom + engine.camera.position.x,
engine.camera.zoom + engine.camera.position.x,
-engine.camera.zoom / aspect + engine.camera.position.y,
engine.camera.zoom / aspect + engine.camera.position.y, -1.0, 1.0);
}
glMatrixMode(GL_MODELVIEW);
}
my camera class:
class Camera {
public:
float zoom = 5;
Vector2 position = Vector2(0, 0);
void Update(); // Basically call the Reshape function provided above^^^
void SetPosition(Vector2 position) {
this->position = position;
Update();
}
};
my set resize callback function:
glfwSetWindowSizeCallback(engine.gameWin, Reshape);
Please help me! Im so confused, it worked fine on Windows but not on MacOS.