Advertisement

Lesson 36: Resizing the Window

Started by December 27, 2005 02:52 PM
1 comment, last by frankly_finkle 18 years, 8 months ago
I've been "ripping" lesson 36 and it's been a huge help to me but I am having some trouble with two things. Problem 1) Most windows automatically scale the viewport when the client window is resized (in window mode) - but lesson 36 has additional glViewport calls in RenderToTexture - and these seem to prevent normal resizing and scaling. Explained a different way - In most lessons, if you have something drawn in the middle of the window, and you resize the window - the thing will be redrawn in the middle of the new window, either larger or smaller. In lesson 36, if you have something drawn in the middle of the window, and you resize the window - it stays at the initial size of the window (say 640, by 480) - I have modified all the glViewport calls (except the first one in RenderToTexture) to use the current width and height of the screen instead of 640 by 480 as it was originally coded. Any help? Problem 2) I also want to capture the whole screen at full resolution into a texture, but when I try to call glCopyTexImage2D with an odd value like 800x600 (instead of a nice even binary number like 512x512) it takes like half a second to run. One idea is to capture the screen in even chunks 256 even though some of the textures might overlap... is there a better way?
1. in most tutorials the view port is set with glViewport(0, 0, width, height),
and with/height is continualy updated with the winsow size, thus alowing it to be rezized.

Lesson 36 on the other hand has a viewport staticly set to glViewport(0 , 0,640 ,480) in the RenderToTexture function, this makes it unable to resize because it overwrites the glViewport command in the ReSizeGLScene function.

In other words it's working as intended.
Changing the viewport to the updated size should solve the problem.

2.
Yea, either split the image into small chunks or use a large Power Of Two(POT) image.
for a res of 800x600 use a 1024x1024 texture or a grid of 4x3 256x256 textures or pice together any combination of POT textures.
The delay is because your GFX card has problems with npot textures.
Advertisement
I have changed every glViewport and gluPerspective call (which were hard-coded to 640x480) to use the new size of the window, but drawing still takes place in the original size of the viewport (anchored on the bottom left).

Does this have something to do with changing the viewport size after drawing to the screen? I noticed that if I comment out the second viewport call (after copying the screen to the texture) the screen does resize properly in window mode...

I suspect there is something more wrong than simply not using the correct screen size.

I thought that perhaps I could de-initialize and re-initiazlize the viewport but not for every resizing increment. Maybe .5 seconds after resizing stops...

I think I want to figure out a way to do the RenderToTexture function that does not involve resizing the screen each frame.

Thanks.

This topic is closed to new replies.

Advertisement