Starting The Game Programming -Part3
hi gamers,
The opengl basic concept continues...
In order to resize the drawing according to the size of the window opengl
uses glortho(left, right, bottom, top , near, far) function...
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
x,y is the lower right corner of the screen
Usually x and y will both be zero, but you can use viewports to render more than one drawing in different areas of a window. The viewport defines the area within the window in actual screen coordinates that OpenGL can use to draw in
NOTE:
OpenGL’s default method for counting the x coordinate is the same; however, it counts the y coordinate from bottom to top—just the opposite of Windows
its like eg:
here the function Changesize( w, h) w=width and h = height is the updated height
when the window gets resized
void CALLBACK ChangeSize( GLsizei w , GLsizei h)
{
if ( h ==0 )
{
h = 1;
}
glViewport (0 , 0 ,w ,h);
glLoadIdentity();
//when the window gets resized vertically then the top portion is updated
if( w <>
glOrtho( 0.0f , 250.0f,0.0f ,250.0f * h/w ,1.0f ,-1.0f);
else
//when the window gets resized horizontally the the right portion is updated
glOrtho( 0.0f , 250.0f * w/h ,0.0f ,250.0f ,1.0f ,-1.0f);
}
The opengl basic concept continues...
In order to resize the drawing according to the size of the window opengl
uses glortho(left, right, bottom, top , near, far) function...
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
x,y is the lower right corner of the screen
Usually x and y will both be zero, but you can use viewports to render more than one drawing in different areas of a window. The viewport defines the area within the window in actual screen coordinates that OpenGL can use to draw in
NOTE:
OpenGL’s default method for counting the x coordinate is the same; however, it counts the y coordinate from bottom to top—just the opposite of Windows
its like eg:
here the function Changesize( w, h) w=width and h = height is the updated height
when the window gets resized
void CALLBACK ChangeSize( GLsizei w , GLsizei h)
{
if ( h ==0 )
{
h = 1;
}
glViewport (0 , 0 ,w ,h);
glLoadIdentity();
//when the window gets resized vertically then the top portion is updated
if( w <>
glOrtho( 0.0f , 250.0f,0.0f ,250.0f * h/w ,1.0f ,-1.0f);
else
//when the window gets resized horizontally the the right portion is updated
glOrtho( 0.0f , 250.0f * w/h ,0.0f ,250.0f ,1.0f ,-1.0f);
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home