See my code (in openGL, C++) the blue sphere is more wide [stretched], how can I fix it, I need translation without stretching: can you please fix my code to avoid stretching? my code:
#include <GL/glut.h>
static void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
}
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3d(0,0,1);
glPushMatrix();
glTranslatef(3.0, 0.0, -6.0);
glutSolidSphere(1,50,50);
glPopMatrix();
glColor3d(1,0,0);
glPushMatrix();
glTranslatef(0.0, 0.0, -6.0);
glutSolidSphere(1,50,50);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(1200,1200);
glutCreateWindow("gggggggggggg");
glutReshapeFunc(resize);
glClearColor(1,1,1,1);
glutDisplayFunc(display);
glutMainLoop();
}