View Full Version : Auto downsampling using OpenGL?

02-25-2005, 08:19 AM

I have a 400x400 RGB array

I would like to use drawPixel to draw on the screen with resolution (200x200, 300x300, etc.)

Is it possible to do this automatically?

Thanks. :)

02-25-2005, 10:21 PM
Yes, use glOrtho projection along with glTexImage2D (to load the texture). Then all you need to do is map the texture to the size of quad you want to use.

Of course power of 2 dimensions may be a factor if your video card does not support one of the texture rectangle extensions.

02-25-2005, 11:16 PM
but glTexImage2D seems only support texture with same width and height?

how about if my image is to resize to, say, 400x200 -> 200x100

how to maintain the aspect ratio?

thanks :)

02-26-2005, 04:53 AM
I finally find out that the drawPixel wll auto convert to fit the viewport for me:


glDrawPixels( WindowWidth, WindowHeight, GL_RGB, GL_FLOAT, frameBuffer);


frameBuffer = float[ WindowWidth * x * WindowHeight * y * 3]

x & y = 1,2,3,...

but using this approach, will there be any side effect?


02-26-2005, 05:43 AM
but using the above approach does not take the advantage of higher resolution, say for antialiasing

Or any simple method to enhance the scale down effect?


02-26-2005, 08:38 PM
If your card/driver supports ARB_texture_rectangle then glTexImage2D can load a non power of 2 2D texture. With or without the extension the dimensions do not have to be the same. If it doesn't support one of the texture_rectangle extensions then the width and height must be a power of 2 though not necessarily the same.