How can I zoom Text

Hi I use OpenGL with Jogl. I want to zoom text. I try to do it by changing glOrtho parameters in 2D but it does not. How can I do it.

When you call glOrtho you set an orthogonal projection, that means that whatever the distance between an object and the eye, it will always be rendered with the same size. To simulate a zoom effect you may need to set perspective projection and change de field of view (see glFrustum).

Instead of using perspective you can just scale the text, of course.

Hi,

I guess scaling wouldn’t work… Because, as far as I know, the image size is specified in pixels and not in size. The same would go for lines and points. In these two, you need to specify the size with a call to glLineWidth() or glPointSize().

In the end, wouldn’t it depend on what you are using to render the text?

I change glOrtho and write text below but it does not zoom. How can I do it. Please write sample code

/// Change Ortho
float zoom = 1.0f/(zoomResult/100);
float w = 0.5f * width * zoom;
float h = 0.5f * height * zoom;
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-w, w, h, -h, -1000, 1000);

// write Text
gl.glRasterPos2i(500, 500);
glut.glutBitmapString(GLUT.BITMAP_TIMES_ROMAN_24, “Hello”);


// write Text
gl.glRasterPos2i(500, 500);
glut.glutBitmapString(GLUT.BITMAP_TIMES_ROMAN_24, "Hello"); 

:slight_smile:

ok that do NOT work. You using Bitmap fonts. The Bitmap is like stamp in the Framebuffer. 1:1. 1 Pixel in Bitmap -> 1 Pixel in Frambuffer.
IMO there is no posibility to Scale this type of text.

Use Texture Text or 3D Texte instead.

for blitting pixels directly use glPixelZoom to control it.

How can I use 3D or Texture Text ,Can yuo give an example

_NK47: are you shure?
IMO PixelZoom is PixelTransfer state but Bitmap do not run over PixelTransfer.

validatoreb:
http://nehe.gamedev.net/lesson.asp?index=03
http://nehe.gamedev.net/lesson.asp?index=04

Download this program -> http://www.angelcode.com/products/bmfont/
Generate a texture with the font.
Parse the font descriptor file.
Draw a quad for every character.

You can find some tutorial on the site.

“_NK47: are you shure?
IMO PixelZoom is PixelTransfer state but Bitmap do not run over PixelTransfer.”
what bitmap you mean? im sure if you move pixel blocks from CPU to GPU (can be a grocery shopping list encoded in pixels) then the glPixelZoom will affect them. if you mean the glBitmap function then same here. any other display aka texturing is controlled via glScale.

ok when moving pixel blocks from CPU to GPU, but bitmap data are NOT pixel data. So they not affektet by PixelTransfer or PixelZoom.
Pixelzoom ist part of the Pixelrasterization but bitmap rasterization is a complete other state.

Pixel Data: defines a color value for a Pixel (RGB, RGBA, INDEX, …)
Bitmap data: defines a bool value … Pixel Set or not.

edit: however Bitmap and Pixelzoom are both DEPRECATED in 3.0 :wink:

don’t understand a word actually. bool value? pixel set or not? do you talk about monochrome bitmaps with either a BIT set or not? what is that all about?

OpenGL / glBitmap …
these have nothing to do with bmp files or sth like that.
OpenGL understand bitmaps as Bit - Maps. As maps where for every pixel a Bit is set or not. Bitmap fonts use this Posibilty to stamp the font into the Frambuffer. Color ist set befor Rasterpos call wit glColor … because a bitmap has no color. Bitmaps are like polygon or line stiple only on the Frambuffer.

Best you read the readbook under Bitmaps / glBitmap. That’s going too far to explain this here all.

A possible solution is to use stroke fonts instead of bitmap fonts. They aren’t as pretty as bitmap fonts AND, in addition to scaling, they will rotate with the other objects in your scene. If the rotations are acceptable, then I suggest using glut stroke fonts. Been talking to someone else about this topic lately and have some code that demonstrates both bitmap and stroke fonts here . See lines 28-32 and line 107 for the stroke font stuff. This code generates a scene in which both bitmap and stroke fonts are utilized. You can rotate the scene using the arrow keys. I leave it up to you to experiment with scaling the scene. You’ll see that the stroke font rotates and scales with the other 3D objects in the scene. A screen grab can be seen at Screen Grab

so you are talking about monochrome bitmaps. bitmap is somewhat of a term that can be interpretted differently. just a map of bits is not enough these days. thanks for the reference but don’t need to dig in, quite slow and quite oldschool.

sorry for offtopic, thought glPixelZoom is way to go here.

_NK47, have you read the glPixelZoom specification? It is said that it is related to glDrawPixels and glCopyPixels. I do not see here any link with rendering fonts. I also tried myself this function and as expected the font size does not change.
Anyway, even if it would work, the result would be awful and very pixelated…
So IMO, the way to go is to use some libraries like QuesoGLC which is specialized for this kind of thing. All is explained on the site validatoreb.
And one last thing, we are not here to provide off-the-shelf-working-code-sample, that is why, I suggest you to start reading about opengl and stop random programming.

read it. also read glBitmap. says, the bitmap image is interpreted like image data for the glDrawPixels command. nothing said about glPixelZoom though. anyways, haven’t used it for a long time and was wrong, deprecated.

i go with FTGL font rendering from textures.