Display 16-bit huge mage

Started by
0 comments, last by BionicBytes 15 years, 11 months ago
Hi I tried to display huge image using openGL library. As the width and height is restricted to 2^n, I scaled the size with glScaleImage(..) and and tried to display by glTexImage2D(..). It displays complete white.. Moreover my image size is 16-bit/pixel variety. Can anyone give me the solution????
Advertisement
What image size are you saying is huge?
OpenGL on modern H/W can handle texture images of 4K x 4K and the new NVidia 8800 series can handle 8K x 8K. Many other cards cannot.
In addition - there may be different limits depending upon if the texture is square texture or not. Typcially, many OGL cards have smaller texture size support for non-square textures.

So- first you should determine a sensible minimum size your application is going to support. You can determine this at runtime by using:

Some c# example code below - which will report the max texture size for Cubes, 3D textures, regular square textures and rectangle textures.
int iMaxTexture3DSize, iMaxTexture2DSize, iMaxTextureCubeSize, iTexMaxRectSize;glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, out iMaxTexture3DSize);glGetIntegerv (GL_MAX_TEXTURE_SIZE, out iMaxTexture2DSize);			glGetIntegerv (GL_MAX_CUBE_MAP_TEXTURE_SIZE, out iMaxTextureCubeSize);glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, out iTexMaxRectSize);



If your huge texture will not fit - consider uploading only a viewable portion. For example: suppose your source data image is 10k x 10k. Create a dyanmic 1k x 1k opengl texture and upload a chunk (or a tile) of your source data to the opengl texture. When the user 'requests' to view the next tile - use opengl and a data pointer to your original image data to upload the next tile and so on.



Some simple code to create a dynamic texture is:

iWidth = iHeight = 1024;int format = GL.GL_RGBA;		// initial valueint target = GL.GL_TEXTURE_2D;		// E.G. GL_TEXTURE_2DGl.glGenTextures (1,out iTextureID);Gl.glBindTexture(target, iTextureID);int errorCode = Gl.glGetError();			Gl.glTexParameteri(target, Gl.GL_TEXTURE_WRAP_R, Gl.GL_CLAMP_TO_EDGE);Gl.glTexParameteri(target, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE);Gl.glTexParameteri(target, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE);Gl.glTexParameteri(target, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST);Gl.glTexParameteri(target, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);// NOTICE THE USE OF THE ZERO POINTER - THIS IS TELLS OPENGL ITS DYNAMICGl.glTexImage2D (Gl.GL_TEXTURE_2D,0,format,stInfo.iWidth,stInfo.iHeight,0,baseType,iMappedDataType,IntPtr.Zero);


Now .. to update a chunk of this texture you simply call glTexCopy2D() or one of its variants.





This topic is closed to new replies.

Advertisement