PDA

View Full Version : PixelZoom problem



simonskid
09-22-2006, 12:04 AM
Hi,

I'm trying to use PixelZoom/DrawPixels to display Maps (the sort you use to find your way around) in Bitmap form onto an orthographic display of gridlines.

After calculating the right (fractional) PixelZoom values, I find that glPixelZoom will modify these to close, but significantly different, values, where the discrepancy is enough to cause noticeable Map-scaling errors. ie. using glGet shows that the values of the arguments I use in glPixelZoom are different from the values stored?

==================================

GLfloat Mapzoom;

/* some scaling calculations, leading to something like ... */

MapZoom = 0.22631626;

printf ( "%f", MapZoom ) shows correct value.

glPixelZoom ( MapZoom, MapZoom );

glGetFloatv ( GL_ZOOM_X, &MapZoom );
printf ( "%f", MapZoom ) shows 0.22656250.
glGetFloatv ( GL_ZOOM_Y, &MapZoom );
printf ( "%f", MapZoom ) shows 0.22656250.

==================================

Does anyone know what causes this behaviour and how I can avoid it / work around it? Its not due to precision differences between float/double - tried that. (I've also tried enabling glBlend incase it was attempting to use a fixed ratio dependent on Bitmap size, and no difference). Lastly, its not a specific bug on my graphics card, as I've tried it on a couple of different machines.

Thanks,
S

Bob
09-22-2006, 12:26 AM
Concider drawing it as a textured quad instead.

simonskid
09-22-2006, 01:25 AM
Can you point me at a bit of code that shows how to do this?

Thanks,
Simon

Bob
09-22-2006, 02:00 AM
Here (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06) 's an introduction to texturing.

k_szczech
09-22-2006, 02:03 AM
Examples anyone? http://nehe.gamedev.net :)

simonskid
09-22-2006, 02:34 AM
The maps I'm loading seem to be larger than most of the objects used in the texturing examples. The code examples for texturing give a maximum width/height of 256 pixels for images - my map tiles are generally about 4000x4000 pixels, and I couldn't reasonably reduce them much.

Does that mean I have to treat them as a large number of smaller objects for texturing?

Thanks,
S

Bob
09-22-2006, 02:49 AM
It doesn't say that textures cannot be larger than 256, it says you should not make them larger for compatibility reasons. But then again, the tutorial is from the previous millennuim (late 1990, but still).

Query the largest possible texture size with glGetInteger and GL_MAX_TEXTURE_SIZE. Even very old hardware by toddays standards supports up to 1024x1024, and modern hardware up to 4096x4096. So it may be possible to fit it in one texture. If not, split it into several textures. A 4x4 grid of 1024x1024 textures for example.

simonskid
09-22-2006, 01:06 PM
Thanks, I'll try some texture mapping.

For future reference, does anyone know the reason for the non-intuitive behaviour of glPixelZoom (see above), or know of any flags that can be set to specify exact fractional zooms?

simonskid
09-27-2006, 01:47 AM
When texture-mapping a large countryside map in several pieces (which I'd like to avoid resizing as far as possible), anyone know what the comparative advantages of using GL_TEXTURE_RECTANGLE_ARB compared to GL_TEXTURE_2D are? The first seems to be the obvious choice, buit I've heard of problems handling texture arrays with RECTANGLE_ARB on some cards ...

Relic
09-27-2006, 06:41 AM
Originally posted by simonskid:
For future reference, does anyone know the reason for the non-intuitive behaviour of glPixelZoom (see above) Which OpenGL implementation was this?
Post the strings you get from
glGetString(GL_VENDOR);
glGetString(GL_RENDERER);
glGetString(GL_VERSION);

simonskid
09-27-2006, 11:55 AM
Post the strings you get from
glGetString(GL_VENDOR);
glGetString(GL_RENDERER);
glGetString(GL_VERSION);


Microsoft Corporation
GDI Generic
1.1.0

Relic
09-27-2006, 10:13 PM
That means it's a Microsoft bug.
I wouldn't hold my breath for a fix.
Go and buy a decent graphics board. :)