PixelZoom problem

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

Concider drawing it as a textured quad instead.

Can you point me at a bit of code that shows how to do this?

Thanks,
Simon

Here 's an introduction to texturing.

Examples anyone? http://nehe.gamedev.net :slight_smile:

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

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.

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?

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 …

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);

Post the strings you get from
glGetString(GL_VENDOR);
glGetString(GL_RENDERER);
glGetString(GL_VERSION);

Microsoft Corporation
GDI Generic
1.1.0

That means it’s a Microsoft bug.
I wouldn’t hold my breath for a fix.
Go and buy a decent graphics board. :slight_smile: