View Full Version : How can I zoom Text
01-22-2009, 04:41 AM
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.
01-22-2009, 10:17 AM
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).
01-22-2009, 11:35 AM
Instead of using perspective you can just scale the text, of course.
01-22-2009, 02:31 PM
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?
01-22-2009, 11:48 PM
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.glOrtho(-w, w, h, -h, -1000, 1000);
// write Text
01-23-2009, 12:38 AM
// write Text
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.
01-23-2009, 01:50 AM
for blitting pixels directly use glPixelZoom (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pixelzoom.html) to control it.
01-23-2009, 03:45 AM
How can I use 3D or Texture Text ,Can yuo give an example
01-23-2009, 03:56 AM
_NK47: are you shure?
IMO PixelZoom is PixelTransfer state but Bitmap do not run over PixelTransfer.
01-23-2009, 04:00 AM
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.
01-23-2009, 06:11 AM
"_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.
01-23-2009, 07:07 AM
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.
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 ;)
01-23-2009, 09:03 AM
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?
01-23-2009, 10:37 AM
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.
How can I use 3D or Texture Text ,Can yuo give an example 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 (http://pastebin.com/m1ebde529) . 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 (http://imagebin.ca/view/yUHFXD13.html)
01-23-2009, 12:46 PM
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.
01-23-2009, 02:54 PM
_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 (http://quesoglc.sourceforge.net) 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.
01-24-2009, 03:18 AM
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 (http://ftgl.wiki.sourceforge.net/) font rendering from textures.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.