From: <lec...@ya...> - 2003-03-23 10:38:44
|
I think the error occurs because your 2048*1024 texture is not a square. I think OpenGL can only handle square textures ! You'll need to add black rectangles on both parts of your image, in order to have a 2048*2048 one, and then play with the texture coordinates of your polygon... Hope this helps... --- Mark Montana <pat...@lm...> a écrit : > All, > > Follow up texture-mapping questions... > > First, I fixed my original problem that was causing > textures in my application to > be all white. I had a special initialization method > to set all the texture mapping > parameters. I forgot to surround those GL calls > with: > glc.getGLContext().gljMakeCurrent(); AND > glc.getGLContext().gljFree(); > A rather newbie-sounding mistake, but it's been a > while since I wrote rendering > code in GL4Java. I hate that you have to perform > those steps in the non-draw > methods, but I realize it is a necessary evil > (Magician had the same thing). > > On to my 2 new questions (somewhat more advanced): > > (Q1) I am loading fairly large textures of satellite > imagery of the Earth. Two of > them are 1024x1024 (powers of two) in RGB format. > These two images load and render > just fine. The third texture is 2048x1024 (also > powers of two) in RGB format. This > one gets a GL error during my call to > glTexImage2d(), and the error is "invalid > value." I determined that value that makes it > unhappy is the image width (2048). > If I lie to OpenGL and tell it that the width is > only1024, the image loads and > renders without an error (of course it looks screwed > up, but I expect that since I > lied about the true width). Any insight on why it > cannot handle the 2048 width? > > I know that it is not related to the hardware, > graphics card, graphics card > driver, or machine configuration. I know this > because our application is half > GL4Java and half Java3D. The Java3D display loads > the same exact textures and > renders them with no problem. I also do not think it > is related to the total > amount of texture memory available; again because > Java3D has no problem, and I can > disable the Java3D display and disable to two > 1024x1024 textures in the GL4Java > display...and the GL4Java display still gets the > same error on the 2048x1024 > texture. > > Could it have something to do with the OpenGL > context or configuration that I am > requesting??? > Could it be related to the fact that I am using > display-lists??? > > [[ I inserted my texture mapping method at the > bottom of this message. ]] > > (Q2) My textures are rendered in a 2D display, no > lighting, no normals, no > materials. The polygons underneath the texture are > white. The texture comes out > way to dark with GL_DECAL or GL_REPLACE. When I try > GL_MODULATE or GL_BLEND, it > gets really washed-out. We had this same exact > problem in the Java3D display with > these textures. We fixed it there by using some > texture-environment settings that > are unique to Java3D. (In other words, the Java3D > people used some of the more > advanced features of blending functions and/or > filters to create a new blending > equation that works well.) I was considering a > decompile of the Java3D code to see > how they did it, but I thought I would as for some > advice on this problem first. > > ---------------------------------------------------------------------------------------- > > My texture map initialization code (sorry for the > formatting if your mail tool > doesn't support fixed-width fonts): > > > private void initialize() > { > // Must make the GLComponent's OpenGL context > current when outside a > // GLEventListener callback method. Then don't > forget to unlock() it. > > glc.getGLContext().gljMakeCurrent(); // > Make current to call OpenGL > > > GeoTiffImage image = > geoTiffDef.getGeoTiffImage(); > Raster raster = image.getAsRaster(); > Object data = raster.getDataElements( > 0, 0, > > raster.getWidth(), > > raster.getHeight(), > > null ); > > if( ToolkitConstants.TK_DEBUG_PATCH2D == true > ) > { > if( raster.getTransferType() == > DataBuffer.TYPE_BYTE ) > System.out.println( "Texture storage > type = TYPE_BYTE"); > else > { > System.err.println( > "TexturedPatch2d.initialize() - " + > "What is the texture > storage type?"); > System.err.flush(); > } > > System.out.println( "Num data elements = " > + > > raster.getNumDataElements() ); > System.out.println( "Geotiff size = (" + > raster.getWidth() + ", " > + > raster.getHeight() + ")" ); > } > > > // Set unpacking to use 1 byte allignment > gl_.glPixelStorei( GLEnum.GL_UNPACK_ALIGNMENT, > 1 ); > > // Ask for valid, unused texture name > gl_.glGenTextures( 1, textureName ); > > // Bind a texture object to the name > gl_.glBindTexture( GLEnum.GL_TEXTURE_2D, > textureName[0] ); > > // Set clamping preferences > gl_.glTexParameteri( GLEnum.GL_TEXTURE_2D, > GLEnum.GL_TEXTURE_WRAP_S, > GLEnum.GL_CLAMP ); > gl_.glTexParameteri( GLEnum.GL_TEXTURE_2D, > GLEnum.GL_TEXTURE_WRAP_T, > GLEnum.GL_CLAMP ); > > // Set mag and min filter preferences > gl_.glTexParameteri( GLEnum.GL_TEXTURE_2D, > GLEnum.GL_TEXTURE_MAG_FILTER, > GLEnum.GL_NEAREST ); > gl_.glTexParameteri( GLEnum.GL_TEXTURE_2D, > GLEnum.GL_TEXTURE_MIN_FILTER, > GLEnum.GL_NEAREST ); > > gl_.glTexEnvi( GLEnum.GL_TEXTURE_ENV, > GLEnum.GL_TEXTURE_ENV_MODE, > GLEnum.GL_MODULATE ); // > GL_REPLACE, GL_BLEND, GL_DECAL > > gl_.glHint( > GLEnum.GL_PERSPECTIVE_CORRECTION_HINT, > GLEnum.GL_FASTEST ); > > // Define the 2D texture > gl_.glTexImage2D( GLEnum.GL_TEXTURE_2D, 0, > GLEnum.GL_RGB, > raster.getWidth()/2, > raster.getHeight(), > 0, GLEnum.GL_RGB, > GLEnum.GL_UNSIGNED_BYTE, > (byte[]) data ); > > > if( ToolkitConstants.TK_DEBUG_PATCH2D == true > ) > { > int errorCode = GLEnum.GL_NO_ERROR; > > if( (errorCode = gl_.glGetError()) != > GLEnum.GL_NO_ERROR ) > { > System.err.println( > "TexturedPatch2d.initialize() - " + > "GL Error: " + > glu_.gluErrorString(errorCode) ); > System.err.flush(); > } > } > > === message truncated === ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com |