Hello, I have this code:
void Reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-((float) width/ (float) height), ((float) width/ (float) height), -1.0, 1.0, 1.0, 100.0);
}
void Display()
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
GLfloat AmbientLight[] = { 0.2, 0.2, 0.2, 1.0 };
GLfloat DiffuseLight[] = { 0.8, 0.8, 0.8, 1.0 };
glLightfv(GL_LIGHT0, GL_AMBIENT, AmbientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, DiffuseLight);
GLfloat LightPosition[] = { 0.0, 1.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
GLfloat Material[] = { 1.0, 0.0, 0.0, 1.0 };
glMaterialfv(GL_FRONT, GL_AMBIENT, Material);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
if (flaga1 != true){
testWzorX = 0.0;
testWzorY = 0.4;
}
else {
testWzorX = -1 + (testX / width* 2);
testWzorY = 1 - (testY / height* 2);
}
glTranslatef(testWzorX, testWzorY, -1);
glutSolidSphere(0.1, 20, 20);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
And this in main:
glutInit(&argc, argv);
glutInitWindowSize(width, height);
glutCreateWindow("OpenGL");
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
I have a problem with this:
-When I move sphere to the corner. It is deformed like this:
s22.postimg.org/a63fn9v5d/Bez_nazwy_1.jpg
EDIT:
It turned out that I was to close to a camera… heh