Hello all ,
how to zoom an image drawn using glDrawPixels... i am not able to do it using [i]gluPerspective[/i] or [i]gluLookAt[/i].
Thanks
schiz
Hello all ,
how to zoom an image drawn using glDrawPixels... i am not able to do it using [i]gluPerspective[/i] or [i]gluLookAt[/i].
Thanks
schiz
Don’t use glDrawPixels. Upload the picture as a texture, use this to texture a screen sized quad (in ortho mode) and adjust the texcoords according to your zoom level. Another possibility is leave texture coordinates constant and draw the quad in the desired size, the texture will get scaled accordingly. You might have to fiddle with interpolation modes and texture wrapping options to get the best results.
Caution: there is a limitation, that textures have to have a power of two size (512x512, 1024x1024, etc.), so keep that in mind while drawing the texture. Either prescale the texture so it fits in the texture dimension or just use the next power of two size (e.g. 1024x1024 for a 1024x768 picture) and adjust the texcoords to be in the range of the actual used pixels.
thank you … but is it okay on performance .
schiz
Using a texture is afaik the fastest way to handle raster images in OGL. The slowest part is to transfer the image to the graphics card.
Sorry hijaking the thread, but how do I get around this limitation? I’ve read things about (may be remembering poorly here) either having ARB extensions to circumvent this, or even OpenGL 2.0 having this limitation removed, and directly incorporating non power-of-two textures?
–Scott
Don’t know about OpenGL 2.0, but you are right, there is an ARB extension to overcome this limitation.
I however just live with it and use the next greater power of two dimension and tweak my texcoords while texturing to stay inside the smaller image contained in the texture. Of course this gives problems with tiling or texture repeat. In such a situation I prescale them in an image application and adjust the texcoord calculation to the biased aspect ratio accordingly.
Hi, I am using the com.sun.opengl.util.texture.TextureIO utilities to load and display textures (this is a higher-level service provider which abstracts you from manually managing textures at an OpenGL level) and this is working great to load and display non-power-of-2 textures, both on my Apple and on an older Windows 2000 test machine.
You simply load the texture (it takes care of either putting it in a larger power-of-2 square, or using specific OpenGL extensions to accomplish this, if available) and it simply provides you with the actual texture coordinates you should use to map it to, for example, a quad.
I am using this to render video (I create my texture objects directly from JMF video frama data) and it’s working great. Anybody also have success with this com.sun.* texture utils?
Dawid