Hello world ! I am beginner in openGL and really facing difficulties while learning it. I have a question and getting confused about the usage of GL_PROJECTIOn and GL_MODELVIEW and also about glLoadIdentity(). I am struggling, this concept has consumed several hours of mine. So from World, anyone who can remove my confusion where these concepts are used.

## All 3 Replies

A simple way to think about it is that GL_PROJECTION is to camera and GL_MODELVIEW is to world objects.

So if you use glTranslatef() in projection mode then you will be moving your viewing position or camera. And if you translate in modelview then you are moving the drawing point for objects.

glLoadIdentity() just takes the view that you passed into glMatrixMode() and loads it as the current matrix.

Thanks SFUO ! Now I understood the concept....can you help me in the below code ?:-
I stuck in a step for screen boundation for ball which is moving in counter clockwise direction..
How to apply screen boundation with coordinate system...Plzzz help me in this code...

``````if(posx<=1.0-radius && posy<=0.5)  // RIGHT EDGE RESTRICTION
{
dy=0.5-posy;     // +
glColor3f(1.0,0.0,1.0);   // COLOUR OF THE BALL
}
else
if(posx>=0.5 && posy<=(1.0-radius))  // TOP EDGE RESTRICTION
{
dx=0.5-posx;   // -
glColor3f(1.0,1.0,0.0);   // COLOUR OF THE BALL
}
else
if(posx>=0.0+radius && posy>=0.5)  // LEFT EDGE RESTRICTION
{
dy=(0.5-posy); //  -
glColor3f(0.0,1.0,1.0);   // COLOUR OF THE BALL
}
else
{
dx=0.5-posx;    // +
glColor3f(1.0,1.0,1.0);   // COLOUR OF THE BALL
}

dis=sqrt(dx*dx+dy*dy);  // Distance between Ball and Wall
speedx=dx/(dis*100);    // Normalizing x
speedy=dy/(dis*100);    // Normalizing y
posx+=speedx*v1;
posy+=speedy*v1;

glBegin(GL_POLYGON);
for (float angle = 0;angle<360;angle+=5)
{