From: Mark M. <pat...@lm...> - 2003-03-26 23:16:50
|
Should have included the following in my last posting... (again, I thank = you for any help you can provide) When Java3D queries the max-supported-texture-size on the Wildcat III 611= 0 machine (from within our application), it gets an answer of 2048. When GL4Java queries this value with glGetIntegerv(GL_MAX_TEXTURE_SIZE, ...) f= rom within our same application on the same machine, it gets an answer of 102= 4. What is up with that? Could the GLCapabilities be used to increase the ma= x supported texture size when the GLContext (state machine) is being create= d? Is GL4Java hardcoding this ceiling of 1024? Pepijn Van Eeckhoudt wrote: > OpenGL does not require square textures. If in practice it is necessary > to use square textures, it's a driver/hardware limitation. > The problem is probably that your hardware can't handle textures that > are that big. A lot of consumer level cards can only handle textures up > to 1024x1024. You can query this maximum value using glGetIntegerv( > GL_MAX_TEXTURE_SIZE ). > > Pepijn Van Eeckhoudt > > On zondag, maa 23, 2003, at 11:38 Europe/Brussels, Florent Geffroy > wrote: > > > 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 > > =E9crit : > 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 =3D > >> geoTiffDef.getGeoTiffImage(); > >> Raster raster =3D image.getAsRaster(); > >> Object data =3D raster.getDataElements( > >> 0, 0, > >> > >> raster.getWidth(), > >> > >> raster.getHeight(), > >> > >> null ); > >> > >> if( ToolkitConstants.TK_DEBUG_PATCH2D =3D=3D true > >> ) > >> { > >> if( raster.getTransferType() =3D=3D > >> DataBuffer.TYPE_BYTE ) > >> System.out.println( "Texture storage > >> type =3D TYPE_BYTE"); > >> else > >> { > >> System.err.println( > >> "TexturedPatch2d.initialize() - " + > >> "What is the texture > >> storage type?"); > >> System.err.flush(); > >> } > >> > >> System.out.println( "Num data elements =3D " > >> + > >> > >> raster.getNumDataElements() ); > >> System.out.println( "Geotiff size =3D (" + > >> 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 =3D=3D true > >> ) > >> { > >> int errorCode =3D GLEnum.GL_NO_ERROR; > >> > >> if( (errorCode =3D gl_.glGetError()) !=3D > >> GLEnum.GL_NO_ERROR ) > >> { > >> System.err.println( > >> "TexturedPatch2d.initialize() - " + > >> "GL Error: " + > >> glu_.gluErrorString(errorCode) ); > >> System.err.flush(); > >> } > >> } > >> > >> > > =3D=3D=3D message truncated =3D=3D=3D > > > > ___________________________________________________________ > > Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran=E7ais ! > > Yahoo! Mail : http://fr.mail.yahoo.com > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by:Crypto Challenge is now open! > > Get cracking and register here for some mind boggling fun and > > the chance of winning an Apple iPod: > > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > > _______________________________________________ > > gl4java-usergroup mailing list > > gl4...@li... > > https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup > > > > ------------------------------------------------------------ > Name: PGP.sig > PGP.sig Type: application/pgp-signature > Encoding: 7bit |