From: Mark M. <pat...@lm...> - 2003-03-19 22:15:22
|
All, I have a working gl4Java application, but I am trying to add some texture mapping to it. I thought I have all my calls in order, but the textured polygons (actually Quads) are pure white. The application is pure 2D, no depth buffering, no lighting, and no normals defined. I was hoping to find a simple, short texture mapping demo application (no applets) that used textured mapping from, let's say, a hardcoded array of bytes representing the texture. I can't seem to find a good example. Any suggestions on my bug or a good example to study? (I already looked through the demos that come zipped from GL4Java, and I tried RonsDemos and MiscDemos, but they don't have a simple, straight forward RGB texture application that I could find.) Any help is greatly appreciated. -Mark |
From: Max G. <gi...@ye...> - 2003-03-20 11:36:40
|
I think it would be easier if you would post your code so others can see what's wrong with it. A ready to compile and run example would be best. I don't have any simple examples around but you can take a look at XMage's renderer at http://xmage.sourceforge.net and see how texturing is done there. Pieces of code you might be interested in are in class xmage.turbine.Renderer: line 179 and 416 - general setup line 610 - actual rendering line 953 - building texture objects HTH, Max |
From: Mark M. <pat...@lm...> - 2003-03-20 18:27:45
|
I got a few responses to my texture mapping question, so I thought I would address them all at once. -First let me say thank you for the references and the example code for texture mapping. -I was looking for GL4Java code, and I got a good example. Thanks William. -I already thought that someone would ask me to post my code. Unfortunately our total application is fairly big (~30,000 lines), so I would have to take some real time to carve out a reasonably sized piece which exhibits the behavior. However, if I continue to have trouble, I guess I could submit a code snippet that does not run, but shows my design. -Since my original posting, I noticed that all texture mapping examples in GL4Java were showing as pure white textures on my machine (Dual Pentium 4, with Wildcat III 6110). But other PCs in the office were running the texture mapping examples just fine. Our application still shows as pure white on ALL machines. Something is still wrong with my code, and I'm about to look into that now. -I was sent a GL4Java example that showed some brick textures, and surprisingly, that worked on all our machines, including the Wildcat III 6110. Go figure! ;-) Thanks again. |
From: Mark M. <pat...@lm...> - 2003-03-21 20:11:01
|
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(); } } glc.getGLContext().gljFree(); // Must unlock OpenGL context } private void constructDisplayList() { destroyDisplayList(); // 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 displayListId = gl_.glGenLists( 1 ); // Ask OpenGL for a unique Id if( displayListId > 0 ) { gl_.glNewList( displayListId, GLEnum.GL_COMPILE ); renderGeometry(); gl_.glEndList(); } else { isValidPatch = false; System.err.println( "TexturedPatch2d.constructDisplayList() - " + "can't generate a valid display list Id: " + displayListId + "\n" ); } glc.getGLContext().gljFree(); // Must unlock OpenGL context } Mark Montana wrote: > I got a few responses to my texture mapping question, so I thought I would > address them all at once. > > -First let me say thank you for the references and the example code for > texture mapping. > > -I was looking for GL4Java code, and I got a good example. Thanks William. > > -I already thought that someone would ask me to post my code. Unfortunately > our total application is fairly big (~30,000 lines), so I would have to take > some real time to carve out a reasonably sized piece which exhibits the > behavior. However, if I continue to have trouble, I guess I could submit a > code snippet that does not run, but shows my design. > > -Since my original posting, I noticed that all texture mapping examples in > GL4Java were showing as pure white textures on my machine (Dual Pentium 4, > with Wildcat III 6110). But other PCs in the office were running the texture > mapping examples just fine. Our application still shows as pure white on ALL > machines. Something is still wrong with my code, and I'm about to look into > that now. > > -I was sent a GL4Java example that showed some brick textures, and > surprisingly, that worked on all our machines, including the Wildcat III 6110. > Go figure! ;-) > > Thanks again. > > ------------------------------------------------------- > This SF.net email is sponsored by: Tablet PC. > Does your code think in ink? You could win a Tablet PC. > Get a free Tablet PC hat just for playing. What are you waiting for? > http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en > _______________________________________________ > gl4java-usergroup mailing list > gl4...@li... > https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup |
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 |
From: Pepijn V. E. <pep...@lu...> - 2003-03-23 11:34:57
|
OpenGL does not require square textures. If in practice it is necessary =20= to use square textures, it's a driver/hardware limitation. The problem is probably that your hardware can't handle textures that =20= are that big. A lot of consumer level cards can only handle textures up =20= to 1024x1024. You can query this maximum value using glGetIntegerv( =20 GL_MAX_TEXTURE_SIZE ). Pepijn Van Eeckhoudt On zondag, maa 23, 2003, at 11:38 Europe/Brussels, Florent Geffroy =20 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=A0: > 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. >> >> > = -----------------------------------------------------------------------=20= > ----------------- >> >> 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 > |
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 |
From: Mark M. <pat...@lm...> - 2003-03-27 03:04:01
|
Here is a summary of my progress and remaining issues. Any feedback is greatly appreciated. (1) I verified that square textures are not a requirement on my hardware = or drivers. (2) I used glGetIntegerv( GL_MAX_TEXTURE_SIZE, valueArray) to query the m= ax supported texture size on two of our machines: -PC with Wildcat III 6110 is reporting a max size of 1024 (which expla= ins why my 2048x1024 texture generates an error upon load) -PC with GeForce 2 Ultra is reporting a max size of 2048 (my large tex= ture actually works on this machine) [These results are VERY surprising since the Wildcat card is much more expensive than the GeForce 2] (3) I am considering breaking textures into smaller pieces if they are la= rger then the max supported size. However, breaking a texture (within memory) = in the horizontal direction is slightly complicated (since the 1-dimensional array is row-major). Then I have to recompute (my already pre-computed) texture coordinates to work with multiple textures. Finally, I am using LINEAR mag-filters. I assume that I have to do something tricky to get th= e texel-average to look good at texture boundaries (such as overlapping 1 o= r 2 texels on each edge from the next texture...then play with the texture cr= ds again to line it up correctly). I am NOT looking forward to doing all tha= t. Am I making this more complicated than it needs to be? Is there a simplie= r way to break and render textures? (4) Back to the textures being too dark. I am currently using MODULATE, a= nd the underlying color is pure white (again, 2D, no lighting, no normals). = The texture is still too dark. The same texture looks good in our Java3D disp= lay, because we are using a Java3D mechanism related to combining fragments an= d anisotropic filtering. In the GL4Java side, I decided to give the BLEND texture mode a try. When I use that, I only get the pure blend color (no texture). I enabled blending and I used glBlendFunc() to play with the blending methods. (I would supply some sample code here, but I already deleted that failed attempt.) Thanks again for any advice. -Mark 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 |
From: Pepijn V. E. <pep...@lu...> - 2003-03-27 09:34:09
|
> (4) Back to the textures being too dark. I am currently using MODULATE, and > the underlying color is pure white (again, 2D, no lighting, no normals). The > texture is still too dark. The same texture looks good in our Java3D display, > because we are using a Java3D mechanism related to combining fragments and > anisotropic filtering. In the GL4Java side, I decided to give the BLEND > texture mode a try. When I use that, I only get the pure blend color (no > texture). I enabled blending and I used glBlendFunc() to play with the > blending methods. (I would supply some sample code here, but I already > deleted that failed attempt.) > What happens when you use REPLACE? And if you disable the texture, is the polygon pure white? Pepijn > Thanks again for any advice. > -Mark > > |