Jump to content
  • Advertisement
Sign in to follow this  

Trouble with rendering a large image on a sphere

This topic is 3818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I got a small problem with a piece of software that I got from a friend of mine. The software is suppose to display a panoramic image using a sphere. The camera is placed inside the sphere and can be rotated with the mouse. The image that is to be rendered on the globe is large. It can be up to 8192 x 4096 in jpeg format. The used texture size at the moment is 64x64. Previously the program checked the video card to see what the largest texture, that could be loaded, would be. For this computer that is 2048. I downscaled it to 64 to be able to see the line pattern more clearly. The large image is loaded into memory after which is it scaled with the openGl function gluScaleImage( ) to get an image that is equal to a power of 2 in both height and width. For large images this could take a long time (5 to 30 seconds). I need to change that in the future. After the scale the large image is "cut" up into tiles and each tile is loaded into the video memory. The following code is used for that. **** SNIP **** void loadTile( struct texture_image *texture, int row, int col, int texID ) { int border =0; int skipRows; int tileWidth; int tileHeight; int skipPixels; glBindTexture( GL_TEXTURE_2D, texID ); tileWidth =texture->texWidthLevel0 / texture->texWidthTiles; tileHeight =texture->texHeightLevel0 / texture->texHeightTiles; skipPixels =col * tileWidth; skipRows =row * tileHeight; glPixelStorei( GL_UNPACK_ROW_LENGTH, texture->texWidthLevel0 ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, skipPixels ); glPixelStorei( GL_UNPACK_SKIP_ROWS, skipRows ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); // Load the texture[texID] into GFX card memory glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, tileWidth, tileHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, texture->texImageLevel ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); } Where: texture->texWidthLevel0 is the width of the texture in memory (atm 4096) texture->texWidthTiles is the # of tiles needed texture->texHeightLevel0 is the height of the texture in memory (atm 2048) texture->texHeightTiles is the # of tiles needed **** SNIP **** With the above code for glTexParameteri() I get strange artifacts around the border of each tile. It looks like the tile is shifted one pixel to the right and one pixel downwards and that pixel is added to the opposite side of the tile. Creating a line patron between all the tiles in the application. Now when I change the code as follows this line pattern is gone. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); But using the change also removed the blury effect you get when you use GL_LINEAR. The resulting image (especialy when you zoom in) is a collection of large pixels. Now I'am thinking that the routine that copies the tiles from the large texture isn't working as it suppose to be. I'am new to OpenGL and this the second project that I do using OpenGL. I made a screenshot that I'll post on a webside once I'am behind a computer with a functional ftp program. Anyone got any idea how to remove those lines from the rendering or a better solution to cut up the large image in smaller tiles to feed into the video memory.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!