Bug 1226

Summary: GLPixelBuffer.GLPixelAttributes.getPixelFormat() doesn't handle glDataType GL_UNSIGNED_INT_8_8_8_8_REV
Product: [JogAmp] Jogl Reporter: Kendzi <kendzi>
Component: coreAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: major CC: charismarangos, gouessej, sgothel
Priority: ---    
Version: 2.3.2   
Hardware: pc_x86_64   
OS: linux   
Type: DEFECT SCM Refs:
84ece839cae076e69a8b56b6b8ef266153afaac6
Workaround: ---
Attachments: Some strange error after compiling jogl...

Description Kendzi 2015-09-22 23:02:31 CEST
I found one problem during the migration to jogl 2.3.1. For some reason code for crating new drawable texture fails with an error. I try to create empty canvas to draw on it later:

The code: 
   TextureRenderer tr = new TextureRenderer(128, 128, true, true);

And the error is: 
com.jogamp.opengl.GLException: Could not find PixelFormat for format and/or type: PixelAttributes[fmt 0x80e1, type 0x8367, null]
	at com.jogamp.opengl.util.GLPixelBuffer$GLPixelAttributes.<init>(GLPixelBuffer.java:494) ~[jogl-all-2.3.1.jar:2.3.1]
	at com.jogamp.opengl.util.GLPixelBuffer$GLPixelAttributes.<init>(GLPixelBuffer.java:460) ~[jogl-all-2.3.1.jar:2.3.1]
	at com.jogamp.opengl.util.texture.awt.AWTTextureData.createFromImage(AWTTextureData.java:217) ~[jogl-all-2.3.1.jar:2.3.1]
	at com.jogamp.opengl.util.texture.awt.AWTTextureData.<init>(AWTTextureData.java:127) ~[jogl-all-2.3.1.jar:2.3.1]
	at com.jogamp.opengl.util.awt.TextureRenderer.init(TextureRenderer.java:636) ~[jogl-all-2.3.1.jar:2.3.1]
	at com.jogamp.opengl.util.awt.TextureRenderer.<init>(TextureRenderer.java:139) ~[jogl-all-2.3.1.jar:2.3.1]
	at com.jogamp.opengl.util.awt.TextureRenderer.<init>(TextureRenderer.java:130) ~[jogl-all-2.3.1.jar:2.3.1]
	at kendzi.jogl.texture.builder.BwFileTextureBuilder.loadTextureRenderer(BwFileTextureBuilder.java:102) ~[kendzi3d.jar:?]
Comment 1 Julien Gouesse 2015-09-23 12:35:46 CEST
Where is the image file?
Comment 2 Kendzi 2015-09-23 14:01:33 CEST
The error is generated in constructor of class TextureRenderer. That constructor don't take any image as argument. And I would like to crate empty canvas only. So it is no image file here.
Comment 3 Julien Gouesse 2015-09-23 15:19:36 CEST
Please provide a small example. Which profile do you use?

The problem occurs here:
https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java#L636
https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java#L217

I don't know why GL.GL_BGRA and GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV are supported to build a pixel attribute.
Comment 4 Julien Gouesse 2015-09-23 15:36:29 CEST
It should return a pixel format:
https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java#L278

Maybe this post helps to understand what "_REV" means in GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:
https://lists.apple.com/archives/mac-opengl/2007/Nov/msg00134.html
Comment 5 Julien Gouesse 2015-09-23 15:40:59 CEST
This answer might help:
http://stackoverflow.com/a/28121321
Comment 6 Kendzi 2015-09-23 16:35:28 CEST
I'm using GL2 profile. Example code you can find here:

https://gist.github.com/kendzi/ef37408e22cfe3af5f6e
Comment 7 Kendzi 2015-09-23 16:36:48 CEST
Additionally that same error is thrown on Windows 7 64
Comment 8 Kendzi 2015-09-24 13:23:14 CEST
So as I understand the bug is that pixel format GL_UNSIGNED_INT_8_8_8_8_REV is missing in switch right?
https://github.com/sgothel/jogl/blob/1744cccaa63fa27b399b032c7767de2115ba2c7a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java#L279

Because as I check the image is created as glFormat: GL.GL_BGRA, glDataType: GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV.
Comment 9 Sven Gothel 2015-09-26 07:42:22 CEST
commit 84ece839cae076e69a8b56b6b8ef266153afaac6:

GLPixelBuffer.GLPixelAttributes.getPixelFormat() doesn't handle glDataType GL_UNSIGNED_INT_8_8_8_8_REV


+++

Note: Please test and either set to verify if working
or reopen if issue still exists!
Comment 10 Kendzi 2015-09-26 22:49:57 CEST
I try to test your fix. To do that I download source code of JOGL. To compile it I install additional retired packages using command from manual:
apt-get install openjdk-7-jre openjdk-7-jdk ant git-all p7zip-full gcc libgl1-mesa-dev libglu1-mesa-dev xorg-dev libice-dev libsm-dev libx11-dev libxext-dev libxxf86vm-dev libxinerama-dev libxrandr-dev libxrender-dev libxcursor-dev libudev-dev libc6-dev g++ libstdc++6 libstdc++-4.9-dev

After that my application stop to working in eclipse. Each time I run it I get an error:

# A fatal error has been detected by the Java Runtime Environment:
# Problematic frame:
# C  [libpthread.so.0+0x9c84]  pthread_mutex_lock+0x4

I don't have idea how to fix that. I will be grateful for any advice.
Comment 11 Kendzi 2015-09-26 22:51:52 CEST
Created attachment 749 [details]
Some strange error after compiling jogl...
Comment 12 Julien Gouesse 2015-09-27 00:27:05 CEST
Please use this build:
http://jogamp.org/deployment/archive/master/gluegen_896-joal_622-jogl_1450-jocl_1093/
Comment 13 Sven Gothel 2015-09-27 02:10:27 CEST
*** Bug 1157 has been marked as a duplicate of this bug. ***
Comment 14 Kendzi 2015-09-27 10:06:56 CEST
I really would like to test you fix but after next few hours is not working...

First, I solved the problem with segment fault. After hours of trials I fount that it is caused by some magic JAVA_TOOL_OPTIONS environment value:
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
It looks that it added by Ubuntu by default and after compiling JOGL localy it started crashing. I really don't wont to know why and don't care. I simply force to clean that environment variable and I'm finally able to run my application...

The second problem is that I downloaded you build and is not working. After trials I decompiled file jogl-all.jar from your build and found:
http://jogamp.org/deployment/archive/master/gluegen_896-joal_622-jogl_1450-jocl_1093/jar/jogl-all.jar

    case 32992: 
        if (5121 == paramInt2) {
          localPixelFormat = PixelFormat.BGR888;
        }
        break;
      case 32993: 
        switch (paramInt2)
        {
        case 32821: 
          localPixelFormat = PixelFormat.ARGB8888;
          break;
        case 5121: 
          localPixelFormat = PixelFormat.BGRA8888;
        }
        break;
      }
      return localPixelFormat;
    }

So your fix is missing there...
Comment 15 Sven Gothel 2015-09-27 15:00:38 CEST
(In reply to Kendzi from comment #14)
> I really would like to test you fix but after next few hours is not
> working...
> 
> First, I solved the problem with segment fault. After hours of trials I
> fount that it is caused by some magic JAVA_TOOL_OPTIONS environment value:
> Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
> It looks that it added by Ubuntu by default and after compiling JOGL localy
> it started crashing. I really don't wont to know why and don't care. I
> simply force to clean that environment variable and I'm finally able to run
> my application...

Horrible situation, sorry to hear that.
Oh well .. is it really one of the Ubuntu packages doing that?

Since I tried compiling w/ vanilla Debian 8 and Ubuntu 15 lately:
  <http://jogamp.org/doc/misc/HowTo-JogAmp-BuildTest-Debian8.1.0-Ubuntu15.04-64bit.txt>

Usually I use Debian .. of course :)

> 
> The second problem is that I downloaded you build and is not working. After
> trials I decompiled file jogl-all.jar from your build and found:
> http://jogamp.org/deployment/archive/master/gluegen_896-joal_622-jogl_1450-
> jocl_1093/jar/jogl-all.jar
> 
>     case 32992: 
>         if (5121 == paramInt2) {
>           localPixelFormat = PixelFormat.BGR888;
>         }
>         break;
>       case 32993: 
>         switch (paramInt2)
>         {
>         case 32821: 
>           localPixelFormat = PixelFormat.ARGB8888;
>           break;
>         case 5121: 
>           localPixelFormat = PixelFormat.BGRA8888;
>         }
>         break;
>       }
>       return localPixelFormat;
>     }
> 
> So your fix is missing there...

This is correct .. sorry for the confusion.

Well, another build is underway, will aggregate it later tonight.
Comment 16 Sven Gothel 2015-09-27 22:07:30 CEST
(In reply to Sven Gothel from comment #15)
> 
> > 
> > So your fix is missing there...
> 
> This is correct .. sorry for the confusion.
> 
> Well, another build is underway, will aggregate it later tonight.

available:

<http://jogamp.org/deployment/archive/master/gluegen_896-joal_622-jogl_1451-jocl_1094/>

also deployed to out local maven as 2.3.2-rc-20150927
Comment 17 Kendzi 2015-09-29 19:39:02 CEST
I tested and is working fine