Bitmap&Zoom

Hi all,
I just began playing with OpenGL. I experimented with the code sample with some tutorials. What I want to do now is a bitmap viewer with the ability to zoom, rotate, and stuff like this. I could do a viewer that shows the bitmap at exactly the same size but don’t know how to zoom in and out ( I want the bitmap to be viewed at the original size then zooming can be applied with the ability to go back to the normal size).

With
gluPerspective(45.0f, 1.0, 0.1f, 100.0f);
and
glTranslatef(0.0f, 0.0f, zoom);
I could zoom in and out (by changing the “zoom” var) but could not view the bitmap at the original size!!

HELP PLEASE,

thanks in advance

I dont fully understand what you want but I’ll give it a stab:

I think you should map your bitmap to a polygon, and draw it using X,Y,Z transformations to move it left/right, up/down, forward/backward.

Thanks a lot. Honestly, I don’t understand every line of the code I have.

Here is what I’m doing:
int InitGLGLvoid)
{
if (!LoadGLTextures())
{
return FALSE;
}

glEnable(GL_TEXTURE_2D);

return TRUE;
}

int LoadGLTextures()
{
// prepare
// Load The Bitmap
if (TextureImage[0]=LoadBMP(“bitmap.bmp”))
{
// OK
glGenTextures(1, &texture[0]);
// Create The Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3,
TextureImage[0]->sizeX, TextureImage[0]-
>sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE,
TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}

// Free The Image Structure

return Status;
}

GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
{
// both dims are power of 2
glViewport(0, 0, width, height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0f, 1.0, 0.1f, 100.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(0.0f, 0.0f, zoom);
glBindTexture(GL_TEXTURE_2D, texture[0]);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();

return TRUE;
}

Using the code above, the bitmap is shown (not normal size!) and I can zoom in and out by changing the “zoom” var.
Now if I comment the gluPerspective call line from the ReSizeGLScene function (called once at init), and set zoom = 0.0f, the bitmap is shown in the normal size (very good) but changing the zoom var now do not affect the view (no zoom in / out !!)

thanks again for any comment

Why not use scalef?

Thanks for all,
I managed to do the zooming. I works accuratly now by changing the following functions parameters:
glTexCoord2f(A,B);
glVertex3f((±)C,(±)C,1.0f);

glScalef is more direct.

BUT now i need to scroll the magnified image, I need to see the hidden parts after zooming. I do that now by changing the view port (glViewPort) but the result is not right, the image is cut and resized again!!

thanks,

Malakh.

You can try gluLookat(). This will allow you to focus on the section of the image you want.

I made the zoom and pan functionality using only glViewPort; changing the view port in response to both zoom and pan operations. It works good, but is this a good appraoch and safe to use? does it has any drawbacks?

thanks,

malakh.