Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problem building mipmaps on OSX  (Read 3075 times)
0 Members and 1 Guest are viewing this topic.
Offline abegel

Senior Newbie




Java games rock!


« Posted 2005-04-26 04:46:56 »

I'm having a problem building a 2D mipmap on JOGL 1.1b10 on OSX 10.3.9 (Powerbook G4 ATI Radeon 9700 card). No matter what image I send to the function, it keeps giving me a GL_INVALID_VALUE exception inside of an internal call to glTexImage2D. Here's the code:

           glu.gluBuild2DMipmaps( texture.target,
                                      texture.dstPixelFormat,
                                      texture.width,
                                      texture.height,
                                      texture.srcPixelFormat,
                                      GL.GL_UNSIGNED_BYTE,
                                      texture.byteBuffer );

where, texture.target is GL_TEXTURE_2D, dstPixelFormat is GL_RGBA, srcPixelFormat is GL_RGBA, width and height are 256 and byteBuffer points to image data loaded from a PNG file (which looks ok with Preview).

The error I get is this:

Initializing new texture 22 - /Users/abegel/Developer/eandl/starlogo-tng/build/models/hulk/blue.png
building mipmap for image width: 256 height: 256
net.java.games.jogl.GLException: glGetError() returned the following error codes after a call to glTexImage2D(): GL_INVALID_VALUE
       at net.java.games.jogl.DebugGL.checkGLGetError(DebugGL.java:13901)
       at net.java.games.jogl.DebugGL.glTexImage2D(DebugGL.java:10554)
       at net.java.games.jogl.impl.mipmap.Mipmap.closestFit(Mipmap.java:259)
       at net.java.games.jogl.impl.mipmap.Mipmap.gluBuild2DMipmaps(Mipmap.java:676)
       at net.java.games.jogl.impl.GLUImpl.gluBuild2DMipmapsJava(GLUImpl.java:587)
       at net.java.games.jogl.impl.GLUImpl.gluBuild2DMipmaps(GLUImpl.java:823)
       at torusworld.TextureManager.initTexture(TextureManager.java:186)
       at torusworld.TextureManager.initNewTextures(TextureManager.java:137)
       at torusworld.TorusWorld.drawTurtle(TorusWorld.java:2076)
       at torusworld.TorusWorld.renderMobileObject(TorusWorld.java:2024)
       at torusworld.TorusWorld.renderMobileObjects(TorusWorld.java:1957)
       at torusworld.TorusWorld.drawIt(TorusWorld.java:1874)
       at torusworld.TorusWorld.display(TorusWorld.java:1249)
       at net.java.games.jogl.impl.GLDrawableHelper.display(GLDrawableHelper.java:74)
       at net.java.games.jogl.GLCanvas$DisplayAction.run(GLCanvas.java:241)
       at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:292)
       at net.java.games.jogl.impl.macosx.MacOSXOnscreenGLContext.invokeGL(MacOSXOnscreenGLContext.java:84)

Using Apple's OpenGL Profiler, I found the arguments for the offending glTexImage2D() call at the end of this sequence (the calls above it are definitely my own that happen before the gluBuild2DMipmap code):


/* context 0x023a9800 */ glGenTextures(14, 0x49ff88ec);
/* context 0x023a9800 */ glGetError(); /* returns: GL_ZERO */
/* context 0x023a9800 */ glBindTexture(GL_TEXTURE_2D, 18);
/* context 0x023a9800 */ glGetError(); /* returns: GL_ZERO */
/* context 0x023a9800 */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
/* context 0x023a9800 */ glGetError(); /* returns: GL_ZERO */
/* context 0x023a9800 */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
/* context 0x023a9800 */ glGetError(); /* returns: GL_ZERO */
/* context 0x023a9800 */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
/* context 0x023a9800 */ glGetError(); /* returns: GL_ZERO */
/* context 0x023a9800 */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
/* context 0x023a9800 */ glGetError(); /* returns: GL_ZERO */
/* context 0x023a9800 */ glGetString(GL_VERSION);
/* context 0x023a9800 */ glGetError(); /* returns: GL_ZERO */
/* context 0x023a9800 */ glTexImage2D(GL_PROXY_TEXTURE_2D, 1, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0x00000000);
/* context 0x023a9800 */ glGetError(); /* returns: GL_INVALID_VALUE */

Any idea what I can do to debug this further? This works perfectly with the same JOGL on a PC running WinXP with an NVidia card.

Thanks,

Andrew
Offline ozak

Junior Devvie




Java demon has no respect for bad code!!!


« Reply #1 - Posted 2005-04-26 09:19:23 »

I got the same error. It appears your textures should be power of 2 in size. Then it works for me on ATI cards.

Want to do multiplayer? Why not try my free Socky socket server?
It's scriptable through JavaScript!
Check it out at http://www.furi.dk/socky
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #2 - Posted 2005-04-26 13:03:29 »

Does it work if you specify the system property -Djogl.glu.nojava on the command line? That would indicate a bug in the Java port of the mipmap routines and in that case I'd appreciate it if you could file a bug with the Issue Tracker on the JOGL home page and attach your example texture and a small test program.

Does the behavior change if you run with -Xint?

Is that output from exactly the source image you're specifying? It looks like it's at level 1 but the image size is 64x64; if you have a 256x256 base image then mipmap level 1 should be 128x128. Maybe that's the problem. The log and image size computation routines are really simple, so it's surprising if they're producing incorrect results.

I noticed the Apple OpenGL profiler seems to be reporting strange arguments like GL_PROXY_TEXTURE_2D instead of GL_TEXTURE_2D; I assume this is due to how the profiler works. Does JOGL's TraceGL report similar arguments?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ozak

Junior Devvie




Java demon has no respect for bad code!!!


« Reply #3 - Posted 2005-04-26 15:37:22 »

It is a problem with the texture size not being a power of two.
I just thought that the glu mipmap thingie took care of that. Guess not Smiley

Want to do multiplayer? Why not try my free Socky socket server?
It's scriptable through JavaScript!
Check it out at http://www.furi.dk/socky
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #4 - Posted 2005-04-26 16:13:30 »

Why do you think it is a problem with the texture size not being a power of two? His input image is 256x256.
Offline abegel

Senior Newbie




Java games rock!


« Reply #5 - Posted 2005-04-26 17:34:18 »

Added -Djogl.glu.nojava makes my program succeed. And I miswrote earlier. The original texture is 128x128, not 256x256.

According to the Java code in mipmap.Mipmap.closestFit() in Mipmap.java:259, the GL_PROXY_TEXTURE_2D argument to glTexImage2D() is passed explicitly and on purpose.

I haven't used JOGL's TraceGL before. I'll read up on it and figure out how to use it.

I'll also report this as a bug on the Issue tracker.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #6 - Posted 2005-04-26 19:19:13 »

Please do file the bug. However it looks like this is the intended behavior of the GLU code, both the original C and the Java port. If proxy textures aren't supported by the hardware (and it looks like they aren't on ATI cards) then the code is supposed to go to a fallback path which doesn't attempt to figure out whether the subsampled texture will fit in texture memory. If you take out the DebugGL does your program work with the Java port of the GLU routines? We might need to add an API to disable the DebugGL's error checking around calls like this, or try to rewrite this part of the GLU routines to not generate GL errors.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #7 - Posted 2005-04-26 19:31:03 »

Actually on further examination it looks like it is probably a driver bug that ATI hardware raises an error upon receiving a target of GL_PROXY_TEXTURE_2D.
Offline abegel

Senior Newbie




Java games rock!


« Reply #8 - Posted 2005-06-04 06:00:24 »

I just tried my code with JOGL 1.1b12 and there's been progress! With the java version of the glu library, some of my mipmaps are built correctly!

The ones that fail are mipmaps made from 1x1 textures. There's a bug in the algorithm in BuildMipmap.java:gluBuild2DMipmapLevelsCore() when width, height, widthPowerOf2 and heightPowerOf2 are equal to 1. We enter the if statement (if (width == newwidth && height == newheight)) and get down to the switch(type) statement where I'm passing in GL.GL_UNSIGNED_BYTE, so we call HalveImage.halveImage_ubyte() with width and height = 1. But halveImage_ubyte() has an assertion that width and height can't both be 1 so we fail.

There's obviously a bug in the control flow here. Here's a stack trace of the error:

Caused by: java.lang.AssertionError
        at net.java.games.jogl.impl.mipmap.HalveImage.halveImage_ubyte(HalveImage.java:95)
        at net.java.games.jogl.impl.mipmap.BuildMipmap.gluBuild2DMipmapLevelsCore(BuildMipmap.java:365)
        at net.java.games.jogl.impl.mipmap.Mipmap.gluBuild2DMipmaps(Mipmap.java:719)
        at net.java.games.jogl.impl.GLUImpl.gluBuild2DMipmapsJava(GLUImpl.java:587)
        at net.java.games.jogl.impl.GLUImpl.gluBuild2DMipmaps(GLUImpl.java:823)
        at torusworld.TextureManager.initTexture(TextureManager.java:196)
        at torusworld.TextureManager.initNewTextures(TextureManager.java:146)
        at torusworld.TorusWorld.drawTurtle(TorusWorld.java:2111)
        at torusworld.TorusWorld.renderMobileObject(TorusWorld.java:2059)
        at torusworld.TorusWorld.renderMobileObjects(TorusWorld.java:1990)
        at torusworld.TorusWorld.drawIt(TorusWorld.java:1907)
        at torusworld.TorusWorld.display(TorusWorld.java:1275)
        at net.java.games.jogl.impl.GLDrawableHelper.display(GLDrawableHelper.java:74)
        at net.java.games.jogl.GLCanvas$DisplayAction.run(GLCanvas.java:249)
        at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:292)
        at net.java.games.jogl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:266)
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #9 - Posted 2005-06-04 19:08:40 »

Could you file a bug with the JOGL Issue Tracker and attach the texture and code snippet you're calling gluBuild2DMipmaps with?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #10 - Posted 2005-06-05 05:49:43 »

I'm pretty sure I found the bug (a missing return statement in BuildMipmap.gluBuild2DMipmapLevelsCore() and just checked in a fix - untested, however. If you have the time to write up a small test case that would be helpful. Regardless, the fix will be in the next JOGL release.
Offline abegel

Senior Newbie




Java games rock!


« Reply #11 - Posted 2005-06-06 01:23:46 »

Yep, Ken, that change to BuildMipmap.java fixed it. Thanks!

BTW, I really want to submit a test case, but can't easily build one out of my code (it's way too big and involves C and Java in addition to the jogl stuff). Sorry about that.

Andy
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (24 views)
2014-11-25 12:00:59

SHC (23 views)
2014-11-25 11:53:45

Norakomi (21 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (68 views)
2014-11-07 19:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!