View Full Version : View bitmaps
06-03-2005, 03:07 AM
I am new to OpenGL. What I want to do is pretty simple. I have a large bitmap which will be displayed on an OpenGL window and the user will be able to zoom in out, and pan the bitmap freely. What is the best way to do this? Can you give me simple code examples? It is important that I do this with OpenGL.
06-03-2005, 03:19 AM
You will find lots of tutorials if you browse around a little on this website, a quick search on google will also help you out.
When you have loaded your image into ram you could put it as a texture on a quad and then it is pretty easy to get panning and zooming going.
Texture tutorials (http://nehe.gamedev.net/lesson.asp?index=02)
06-05-2005, 11:29 PM
Thanks for the tip. I succeeded in loading the image on a quad as texture, but I am complete new to OpenGL concepts. Can you please provide some samples for panning and zooming?
06-06-2005, 01:18 AM
If you just want to pan and zoom the quad and does not have anything else you can just move the quad in X/Y direction to pan/tilt and move it along the Z axis to zoom in and out (use glTranslate).
Another way is to keep the quad fixed and use gluLookAt to move the "camera" to get the same effect, this works of course if you have more objects visible also, but to make real zooming you should change the field of view (fov) parameter that you pass to gluPerspective, a higher value zoom out and a smaller value zoom in.
You will find tutorials about transformations in the same place as you found the texture tutorials.
06-06-2005, 01:40 AM
put glTranslate (x,y) and glScale rigth before drawing the quad.
For more details on this, search for "opengl transformation and matrices" tutorials.
As well on the official GL FAQ :
06-06-2005, 05:45 AM
Can you please post some example code or direct to some samples on the web? NeHe's site does not have any example on what I am trying to do.
Also can I do this using glDrawPixels? Because it is faster.
06-06-2005, 06:28 AM
You can also draw the pixels to the screen using glDrawPixels(), but it's alotta slower than using textures(atleast, that's what they told me)
And there's another way to zoom in and out:
(searching my red-book what it was again)...
06-06-2005, 10:55 PM
I know you are fed up with me :) I am close to what I achieve my goal. It takes time to get familiar to OpenGL concepts.
I am now able to pan by moving the camera on the x, y axes using glTranslate. However, I cannot move on the z axis. No matter how much I move by glTranslatef(0.0f, 0.0f, z), the output is always the same. Do I have to use some other functions? Can you give me some tips on zooming.
06-07-2005, 03:15 AM
Zooming with gltranslate on z will only work with a perspective projection. But will be more complex to handle.
The easiest is to use glScaled(x,y,z) with x=y=z in your case. 1.O won't change anything, 2.0 will enlarge to twice the size, 0.5 will reduce it etc.
Good luck !
06-07-2005, 04:12 AM
glScale was just what I needed :) Thank you all for the help.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.