View Full Version : big images with OpenGL
03-11-2003, 12:55 AM
I'd like to display large images for a software using 2k, 3k or even 4k images. Using native API is quiet slow (Linux, Windows...).
I've chosen to use OpenGL and hardware accelration to get it worked. I've tied a way to implement it, but i'm definitly sure it's not the best.
I'd like to know your suggestions ?
Regarding the function glDrawPixel() don't even think about it !
Tanks a lot,
03-11-2003, 02:22 AM
Load the image as a texture and draw a textured quad to present your image.
If it's too small you can use color write masks and multiple luminance textures to draw larger images. I've done this for 4kx4k textures on pretty low end hardware. You could do this with multitexture now too instead of multipass with writemasks, but writemasks are a nobrainer w.r.t. implementation.
Being a texture on a polygon then let's you do all sorts of fancy things very easily.
03-11-2003, 04:37 AM
i'am using im my current project 1600x1200-background images(prerendered) on a 800x600 screen. my solution: i split the original picture in 2^n sized textures and draw them simply using gluOrtho and textured quads. this way i am also able to draw non-2^n sized pictures and i have only to load the visible parts of my pixture into texmem...
(which is also an important point on a low-end-gfx-card)
03-11-2003, 08:29 AM
i'm working on displaying HUGE images in RAW format..i'm talking 16k x 16k...and providing zoom/pan/rotate, cursor placing etc. facilities.
i'm using the textured quad method..getting some pretty neat results..(see below)
current machine config. is P3 800 MHz..1 GB RAM, 3D Labs Oxygen GVX1 32 MB AGP, 256 MB tex. mem.
Now here's what i'm doing and i'd appreciate your comments and suggestions...
i'm loading the image as tiles of 2^n size...
that is tiles of 64x64...upto tiles of 2048 x 2048. the remaining pixels can either be neglected (obviously not desirable) or extra padding pixels added to make it a multiple of tile size.
-64x64 will be supported on any OpenGL impl.
-i'm was having some problems with the edges..
i used GL_CLAMP_TO_EDGE ...the edge problem is not that bad now..but its still there...when you zoom really close you see the lines.
-When more than a certain no. of tiles are on screen, the performance becomes poor. like from 50 fps to 5 fps!
Here are some performance stats with a 16k x 16k image...
Tile Size....FPS...Load Time (I/O +Disp.List)
64 x 64.....<0.75....105.8 s
128 x 128....4.44... 53.8 s
256 x 256....15-17...23.8 s
512 x 512....36 .....21 s
1024 x 1024..49......17.15 s
2048 x 2048..53......15.68 s
(sorry about the terrible formatting)
Changing magnification to Linear or Nearest Neighbor doesnt affect performance much..quality ofcourse is worse in the latter.
Basically i'm looking for alternative ways to display large images with zoom, pan, rotate etc.
I'm not doing ANY subsampling right now...i guess finally there will be an overview image presented in subsampled form..and a zoom window will give the actual pixels..tiled as described above...since a large no. of tiles on screen at one time makes performance really poor.
any idea why my tiles still show faint edges after GL_CLAMP_TO_EDGE?
[This message has been edited by OpenGHell (edited 03-11-2003).]
03-11-2003, 11:56 AM
You're going to have to play around with your texture coordinates to get rid of those edge problems. If your image is 64x64, you probably want your texture coordinates to go from (in pixel-space) (0.5, 0.5) to (63.5, 63.5). Or would that be (0.5, 0.5) to (64.5, 64.5)? Try both and see what happens.
03-11-2003, 12:17 PM
Your tiles show edges because of filtering issues. Basically your tiles need to overlap by one pixel for correct filtering. This is definitely not solvable by just shifting texture coordinates. It's a well known problem and has been explored in depth in terrain texture paging schemes.
This is what texture border images are for but they of course can be slow and/or waste memory.
The problem can seem almost intractible without borders when you consider MIP mapping because the overlap needs to be one pixel at each level of MIP and therefore varys in scale (borders give you this), perhaps you don't need this though for your application.
Once you realize the feint edges are related to edge filtering not including texels from adjecent tiles some solutions become apparent. Larger tiles is obviously one possible improvement, overlap is also a solution provided you don't minify with MIP mapping too much. Texture borders are a solution but tend to suffer from disadvantaged implementation. Other approaches may present themselves to you if you think some more about it. I'm not really at liberty to discuss these here.
If you simply have a background you want to scroll in 2D then you will get good quality if you try a pixel aligned approach with nearest neighbour filtering and moving the image by integer texel-pixel ammounts. This will need no borders will be high quality but is strictly a 2D approach.
[This message has been edited by dorbie (edited 03-11-2003).]
03-13-2003, 06:54 AM
probably, this can be interesting for you:
The TR (Tile Rendering) library is an OpenGL utility library for doing tiled rendering. http://www.mesa3d.org/brianp/TR.html
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.