PDA

View Full Version : problem with viewport



Swift
03-20-2003, 12:01 AM
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.

nexusone
03-20-2003, 05:41 AM
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.....

http://www.opengl.org/discussion_boards/ubb/smile.gif



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.

Swift
03-20-2003, 04:21 PM
The following are code for Drawing Main Scene :

Would this give you are better picture?

void GLDraw: http://www.opengl.org/discussion_boards/ubb/biggrin.gifrawScene()
{

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.

nexusone
03-20-2003, 06:54 PM
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:
The following are code for Drawing Main Scene :

Would this give you are better picture?

void GLDraw: http://www.opengl.org/discussion_boards/ubb/biggrin.gifrawScene()
{

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.

Swift
03-20-2003, 10:26 PM
Yes, I am using gluPerspective function to Zoom in and out of my drawing. Is this the cause of the problem? Thanks.

Iceplode
03-23-2003, 08:31 AM
How about try using glTranslate* to "zoom" instead.

Mazy
03-23-2003, 02:49 PM
change the perspective is more accurat that translate, you dont use binoculars and run closer to the object you are looking at, are you ? http://www.opengl.org/discussion_boards/ubb/smile.gif

Pops
03-23-2003, 07:44 PM
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.

Swift
03-24-2003, 04:05 PM
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'?

Swift
03-24-2003, 09:05 PM
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.

acerb
03-25-2003, 12:09 AM
Hi,

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

acerb

Swift
03-25-2003, 04:00 AM
Since perspective is the correct way. What could be the cause of my problem. Thanks for the help.

Swift
03-25-2003, 04:02 AM
Since perspective is the correct way. What could be the cause of my problem. Thanks to all.

Swift
03-26-2003, 06:39 PM
I remember the problem shows. Even if I am not using perspective

Swift
03-26-2003, 09:57 PM
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.

shinpaughp
03-26-2003, 10:56 PM
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.

Swift
04-01-2003, 10:50 PM
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.