problem with viewport

Programming with Visual C++. After the first execution of the application the viewport would reduce it size. I do not know the cause of the problem. Please help.

I forgot my mind reading cap today, but I am guessing that it is something in your code that is doing it.

Post some code, so we can SEE what you are doing to cause this…

Originally posted by Swift:
Programming with Visual C++. After the first execution of the application the viewport would reduce it size. I do not know the cause of the problem. Please help.

The following are code for Drawing Main Scene :

Would this give you are better picture?

void GLDraw: rawScene()
{

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glHintGL_LINE_SMOOTH_HINT,GL_NICEST);
glEnable (GL_LINE_SMOOTH);
glEnable (GL_POINT_SMOOTH);

glLoadIdentity();
glTranslatef(cx, cy, cz);

if (pFrame != NULL)
{
if (pFrame->GotTestpoint)
{
GotDraw = Draw_One_Layer (temp_test_node->Top);
GotDraw = Draw_One_Layer(temp_test_node->Bottom) | | GotDraw ;
Draw_One_Layer(temp_test_node->Bottom);
}

if (pFrame->GotComponent)
{
GotDraw =  Draw_components(temp_component->Top) | | GotDraw ;
GotDraw =  Draw_components(temp_component->Bottom) | | GotDraw ;
}

if (pFrame->GotOutLine && GotDraw)
{	Draw_One_Layer(temp_outline);
Draw_Text();
}

}

Sometime it would produce a full view of the drawing. Thanks.

Are you doing something like the below code anywhere else besides your resize function

glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1, 1, 30);
glMatrixMode(GL_MODELVIEW); // make sure you are in this mode before drawing objects
glLoadIdentity();

Originally posted by Swift:
[b]The following are code for Drawing Main Scene :

Would this give you are better picture?

void GLDraw: rawScene()
{

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glHintGL_LINE_SMOOTH_HINT,GL_NICEST);
glEnable (GL_LINE_SMOOTH);
glEnable (GL_POINT_SMOOTH);

glLoadIdentity();
glTranslatef(cx, cy, cz);

if (pFrame != NULL)
{
if (pFrame->GotTestpoint)
{
GotDraw = Draw_One_Layer (temp_test_node->Top);
GotDraw = Draw_One_Layer(temp_test_node->Bottom) | | GotDraw ;
Draw_One_Layer(temp_test_node->Bottom);
}

if (pFrame->GotComponent)
{

GotDraw = Draw_components(temp_component->Top) | | GotDraw ;
GotDraw = Draw_components(temp_component->Bottom) | | GotDraw ;
}

if (pFrame->GotOutLine && GotDraw)
{	Draw_One_Layer(temp_outline);

Draw_Text();
}
}

Sometime it would produce a full view of the drawing. Thanks.[/b]

Yes, I am using gluPerspective function to Zoom in and out of my drawing. Is this the cause of the problem? Thanks.

How about try using glTranslate* to “zoom” instead.

change the perspective is more accurat that translate, you dont use binoculars and run closer to the object you are looking at, are you ?

Also, if you use translate to “zoom” closer to the object and then move left or right, you would have to scale the movement by the zoom factor which seems a really bad way to do it.

I have try using Translate to ‘zoom’ in however, I found that perspective give a better view of the drawing. So is there a way to resolve the viewport problem and use perspective to ‘zoom’?

I notice that on the first execution. The program would display the full drawing. However, on subsequence execution the program would display less and less of the drawing. To a point when it would display the full drawing again. Thanks. Sorry for the trouble.

Hi,

You should try glScalef also… However, perspective is the right way

acerb

Since perspective is the correct way. What could be the cause of my problem. Thanks for the help.

Since perspective is the correct way. What could be the cause of my problem. Thanks to all.

I remember the problem shows. Even if I am not using perspective

Is there a command to refresh the video memory space. This problem occurs when I close the application, then re-open it. Usually on the second opening of the application, the view area for the draw would reduce. Please help to resolve this problem. Thanks.

When you initially set your projection, are you doing something like this:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0,(float)x_size/(float)y_size,0.1,1000.0);
glViewport(0, 0, (GLsizei) x_size, (GLsizei) y_size);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);

Do you have it set up to resize the window at some point or call ChangeDisplaySettings, and fail to call glViewport again for the change in size? When a context is initially created, the viewport is set to the size of the window at the time of the context creation.

If messing with the glViewport function does not work, show more code. And, provide more detail as to what you are doing in your code.

Found that the problem is not in the code, but with the video card. The computer in my office is a on-board video card, which is the cause of the problem. Thanks for those who have help in my problem.