Bug 500 - OpenGL 4.0/4.1 core context creation fails if done via getGL4() method
Summary: OpenGL 4.0/4.1 core context creation fails if done via getGL4() method
Status: VERIFIED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 2
Hardware: pc_x86_64 windows
: --- normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2011-05-22 17:40 CEST by Job Zwiers
Modified: 2011-12-02 08:04 CET (History)
2 users (show)

See Also:
Type: ---
SCM Refs:
4a77b439ca85a29c1cf5ac5043c4ef03c4206e0d
Workaround: ---


Attachments
test program showing a bug for getGL4() method (2.69 KB, text/plain)
2011-08-03 11:42 CEST, Job Zwiers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Job Zwiers 2011-05-22 17:40:23 CEST
The following method for creating an OGL 4 context fails:

public void init(GLAutoDrawable drawable) {
GL4 gl = drawable.getGL().getGL4();

The Exception: 
----------------------------------------------------------------------
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Not a GL4 implementation
     [java] at jogamp.opengl.gl4.GL4bcImpl.getGL4(GL4bcImpl.java:32456)
     [java] at firstopengl.OGL4Test.init(OGL4Test.java:173)
     [java] at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:132)
     [java] at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:151)
     [java] at javax.media.opengl.awt.GLCanvas$InitAction.run(GLCanvas.java:872)
     [java] at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:328)
     [java] at javax.media.opengl.awt.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:785)
     [java] at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:389)
     [java] at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:488)
     [java] at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
...
------------------------------------------------------------------------

Hardware: NVidia GTX 460, driver 270.61(whql),  Win7 64 bits 
Jogl builds used for the test: b391, b392 
Jogl profile selected with:
GLProfile glp = GLProfile.get(GLProfile.GL4);


The following workaround is ok:
GL4 gl = (GL4)drawable.getGL(); 

This yields a context reported by  glGetString(GL4.GL_VERSION) as OGL4.1)

A similar call for GL3 works fine:
GL3 gl = drawable.getGL().getGL3(); // Ok, but of course OGL3.3)

======================================================================
The following is a printout for gl.getContext().toString():

    [java] GL context: jogamp.opengl.windows.wgl.WindowsOnscreenWGLContext [OpenGL 4.1, options 0x25, 4.1 (core profile, any, new) - 4.1.0, handle 0x20000, jogamp.opengl.gl4.GL4bcImpl@1a42792,
     [java] 	Drawable: jogamp.opengl.windows.wgl.WindowsOnscreenWGLDrawable[Realized true,
     [java] 	Factory   jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory@2200d5,
     [java] 	handle    0xffffffff93011a9c,
     [java] 	Window    JAWT-Window[windowHandle 0x100eec, surfaceHandle 0xffffffff93011a9c, bounds [ 8 / 30  624 x 362 ], pos 8/30, size 624x362, visible true, lockedExt false,
     [java] 	config AWTGraphicsConfiguration[AWTGraphicsScreen[AWTGraphicsDevice[type AWT[subType null], connection \Display0, unitID 0, awtDevice D3DGraphicsDevice[screen=0], handle 0x0], idx 0],
     [java] 	chosen    GLCaps[7 arb: on-scr, rgba 8/8/8/0, opaque, accum-rgba 16/16/16/16, dp/st/ms: 24/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]],
     [java] 	requested GLCaps[on-scr, rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms: 16/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]],
     [java] 	sun.awt.Win32GraphicsConfig@1632847[dev=D3DGraphicsDevice[screen=0],pixfmt=7],
     [java] 	encapsulated WindowsWGLGraphicsConfiguration[DefaultGraphicsScreen[WindowsGraphicsDevice[type Windows, connection decon, unitID 0, handle 0x0], idx 0], pfdID 7, ARB-Choosen true,
     [java] 	requested GLCaps[on-scr, rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms: 16/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]],
     [java] 	chosen    GLCaps[7 arb: on-scr, rgba 8/8/8/0, opaque, accum-rgba 16/16/16/16, dp/st/ms: 24/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]]]],
     [java] 	awtComponent AWT-GLCanvas[Realized true,
     [java] 	jogamp.opengl.windows.wgl.WindowsOnscreenWGLDrawable,
     [java] 	Realized true,
     [java] 	Factory   jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory@2200d5,
     [java] 	handle    0xffffffff93011a9c,
     [java] 	Drawable size 624x362,
     [java] 	AWT pos 8/30, size 624x362,
     [java] 	visible true,
     [java] 	AWTGraphicsConfiguration[AWTGraphicsScreen[AWTGraphicsDevice[type AWT[subType null], connection \Display0, unitID 0, awtDevice D3DGraphicsDevice[screen=0], handle 0x0], idx 0],
     [java] 	chosen    GLCaps[7 arb: on-scr, rgba 8/8/8/0, opaque, accum-rgba 16/16/16/16, dp/st/ms: 24/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]],
     [java] 	requested GLCaps[on-scr, rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms: 16/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]],
     [java] 	sun.awt.Win32GraphicsConfig@1632847[dev=D3DGraphicsDevice[screen=0],pixfmt=7],
     [java] 	encapsulated WindowsWGLGraphicsConfiguration[DefaultGraphicsScreen[WindowsGraphicsDevice[type Windows, connection decon, unitID 0, handle 0x0], idx 0], pfdID 7, ARB-Choosen true,
     [java] 	requested GLCaps[on-scr, rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms: 16/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]],
     [java] 	chosen    GLCaps[7 arb: on-scr, rgba 8/8/8/0, opaque, accum-rgba 16/16/16/16, dp/st/ms: 24/0/0, dbl, mono  , hw, GLProfile[GL4/GL4]]]]]]]]
Comment 1 Kai Giebeler 2011-06-21 00:27:21 CEST
I'm experiencing a very similar result using jogl-2.0-b23-20110303-windows-amd64
Hardware, OS and Drivers are all the same.

Default Profile: GL4bc
GL-Class: GL4bcImpl
Context Version: 3.0 (compatibility profile, any, old) - 4.1.0
but: getGL3(), getGL3bc(), getGL4() and getGL4bc() fail

I've attached a detailed extract of what JOGL allows/disallows.

My creation method (I'm relative new to JOGL, so I hope there's no newbie-mistake inside)
AbstractGraphicsDevice device = GLProfile.getDefaultDevice();
GLProfile glProfile = GLProfile.getDefault(device);
GLContext glContext = GLDrawableFactory.getFactory(glProfile).create.createExternalGLContext();

--------- SNIP ---------
AbstractGraphicsDevice.DEFAULT_CONNECTION  = decon
AbstractGraphicsDevice.DEFAULT_UNIT        = 0
AbstractGraphicsDevice.EXTERNAL_CONNECTION = excon
device = WindowsGraphicsDevice[type Windows, connection decon, unitID 0, handle 0x0]
device.getConnection = decon
device.getHandle = 0
device.getType = Windows
device.getUniqueID = Windows_decon_0
device.getUnitID = 0

GLContext.getMaxMajor              = 4
GLContext.getMaxMinor(getMaxMajor) = 1
GLContext.isGL2Available(device) = true
GLContext.isGL3Available(device) = true
GLContext.isGL3bcAvailable(device) = true
GLContext.isGL4Available(device) = true
GLContext.isGL4bcAvailable(device) = true
GLContext.isGLES1Available(device) = false
GLContext.isGLES2Available(device) = false
GLContext.isValidGLVersion(1, 0) = true
GLContext.isValidGLVersion(1, 1) = true
GLContext.isValidGLVersion(1, 2) = true
GLContext.isValidGLVersion(1, 3) = true
GLContext.isValidGLVersion(1, 4) = true
GLContext.isValidGLVersion(1, 5) = true
GLContext.isValidGLVersion(2, 0) = true
GLContext.isValidGLVersion(2, 1) = true
GLContext.isValidGLVersion(3, 0) = true
GLContext.isValidGLVersion(3, 1) = true
GLContext.isValidGLVersion(3, 2) = true
GLContext.isValidGLVersion(3, 3) = true
GLContext.isValidGLVersion(4, 0) = true
GLContext.isValidGLVersion(4, 1) = true
GLProfile.glAvailabilityToString =
GLAvailability[
  Native[
    GL4bc true[4.1 (compatibility profile, any, new)],
    GL4 true[4.1 (core profile, any, new)],
    GL3bc true[3.3 (compatibility profile, any, new)],
    GL3 true[3.3 (core profile, any, new)],
    GL2 true[3.0 (compatibility profile, any, new)],
    GL2ES1 true,
    GLES1 false,
    GL2ES2 true,
    GLES2 false
  ],
  Profiles[
    GLProfile[GL2ES2/GL2],
    GLProfile[GL2ES1/GL2],
    GLProfile[GL2/GL2],
    GLProfile[GL4/GL4],
    GLProfile[GL3/GL3],
    GLProfile[GL4bc/GL4bc],
    GLProfile[GL4bc/GL4bc],
    GLProfile[GL2GL3/GL2],
    GLProfile[GL3bc/GL3bc],
    ,
    default GLProfile[GL4bc/GL4bc]
  ]
]
GLProfile.getDefaultDesktopDevice = WindowsGraphicsDevice[type Windows, connection decon, unitID 0, handle 0x0]
GLProfile.getDefaultDevice        = WindowsGraphicsDevice[type Windows, connection decon, unitID 0, handle 0x0]
GLProfile.getDefaultEGLDevice     = EGLGraphicsDevice[type EGL, connection decon, unitID 0, handle 0x0]
GLProfile.isAWTAvailable    = true
GLProfile.isGL2Available    = true
GLProfile.isGL2ES1Available = true
GLProfile.isGL2ES2Available = true
GLProfile.isGL3Available    = true
GLProfile.isGL3bcAvailable  = true
GLProfile.isGL4Available    = true
GLProfile.isGL4bcAvailable  = true
GLProfile.isGLES1Available  = false
GLProfile.isGLES2Available  = false

glprofile = GLProfile[GL4bc/GL4bc]
glprofile.getGLImplBaseClassName = jogamp.opengl.gl4.GL4bc
glprofile.getImplName            = GL4bc
glprofile.getName                = GL4bc
glprofile.hasGLSL  = true
glprofile.isGL2    = true
glprofile.isGL2ES1 = true
glprofile.isGL2ES2 = true
glprofile.isGL2GL3 = true
glprofile.isGL3    = true
glprofile.isGL3bc  = true
glprofile.isGL4    = true
glprofile.isGL4bc  = true
glprofile.isGLES1  = false
glprofile.isGLES2  = false
glprofile.usesNativeGLES  = false
glprofile.usesNativeGLES1 = false
glprofile.usesNativeGLES2 = false

glcontext = jogamp.opengl.windows.wgl.WindowsExternalWGLContext[
  OpenGL 3.0,
  options 0x22,
  3.0 (compatibility profile, any, old) - 4.1.0,
  handle 0x20000,
  jogamp.opengl.gl4.GL4bcImpl@7290cb03,
  Drawable: jogamp.opengl.windows.wgl.WindowsExternalWGLContext$Drawable[
    Realized true,
    Factory   jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory@6cb8,
    handle    0x40011b9a,
    Window    WrappedSurface[
      config WindowsWGLGraphicsConfiguration[
        DefaultGraphicsScreen[
          DefaultGraphicsDevice[
            type Windows,
            connection decon,
            unitID 0,
            handle 0x0
          ],
          idx 0
        ],
        pfdID 7,
        ARB-Choosen true,
        requested GLCaps[
          7 arb: on-scr,
          rgba 8/8/8/0,
          opaque,
          accum-rgba 16/16/16/16,
          dp/st/ms: 24/0/0,
          dbl,
          mono  ,
          hw,
          GLProfile[GL4bc/GL4bc]
        ],
        chosen    GLCaps[
          7 arb: on-scr,
          rgba 8/8/8/0,
          opaque,
          accum-rgba 16/16/16/16,
          dp/st/ms: 24/0/0,
          dbl,
          mono  ,
          hw,
          GLProfile[GL4bc/GL4bc]
        ]
      ],
      displayHandle 0x0,
      surfaceHandle 0x40011b9a,
      size 0x0
    ]
  ]
] 
glcontext.getGLVersion      = 3.0 (compatibility profile, any, old) - 4.1.0
glcontext.getGLVersionMajor = 3
glcontext.getGLVersionMinor = 0

glcontext.getGL().class            = class jogamp.opengl.gl4.GL4bcImpl
glcontext.getGL() instanceof GL2   = true
glcontext.getGL().getGL(): Ok
glcontext.getGL() instanceof GL2   = true
glcontext.getGL().getGL2() Ok
glcontext.getGL() instanceof GL2ES1 = true
glcontext.getGL().getGL2ES1() Ok
glcontext.getGL() instanceof GL2ES2 = true
glcontext.getGL().getGL2ES2() Ok
glcontext.getGL() instanceof GL2GL3 = true
glcontext.getGL().getGL2GL3() Ok
glcontext.getGL() instanceof GL3   = true
glcontext.getGL().getGL3(): Not a GL3 implementation
glcontext.getGL() instanceof GL3bc = true
glcontext.getGL().getGL3bc(): Not a GL3bc implementation
glcontext.getGL() instanceof GL4   = true
glcontext.getGL().getGL4(): Not a GL4 implementation
glcontext.getGL() instanceof GL4bc = true
glcontext.getGL().getGL4bc(): Not a GL4bc implementation
glcontext.getGL() instanceof GL4bc = false
glcontext.getGL().getGLES1(): Not a GLES1 implementation
glcontext.getGL() instanceof GL4bc = false
glcontext.getGL().getGLES2(): Not a GLES2 implementation
--------- SNAP ---------
Comment 2 Sven Gothel 2011-07-23 02:55:20 CEST
I cannot confirm this bug, since we use GL4 ctx a long time ago on linux/windows
w/ appropriate GPUs ..

Your logs might say that you have requested a GL4 ctx, but for some reason it is not,
and no exception has been thrown at getGL4() ?

NV GTX 460 supports GL4 AFAIK.
So does it's driver on windows.

Please attach your test application, or better a unit test.

Thank you.
Comment 3 Sven Gothel 2011-07-23 02:57:33 CEST
BTW, we already have a simple unit test for those GLProfiles here:
  jogl/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java

Maybe you can test that one on your machine and/or create a modified version of it,
reproducing the bug you experience.
Its much simpler to understand the issue having a unit test ..
Comment 4 Job Zwiers 2011-08-03 11:42:04 CEST
Created attachment 262 [details]
test program showing a bug for getGL4() method

Small test program showing a bug when using the combination 
GLProfile.get(GLProfile.GL4)  and later on  GL4 gl = drawable.getGL().getGL4();
Comment 5 Job Zwiers 2011-08-03 11:50:32 CEST
I could run the junit test (except for a few lines in the first test which seem to require some android.content.Context class which I apparantly don't have)

The test completes ok, but it would not trigger this bug, since it is only
the particular *combination* of GLProfile.get(GLProfile.GL4) for profile selction and later on GL4 gl = drawable.getGL().getGL4() for obtaining a
GL4 context. Replacing the latter line with GL4 gl = (GL4) drawable.getGL();
for instancce works ok. Alternatively, selecting the profile with 
GLProfile glp = GLProfile.getDefault(); also avaoid this bug (I think it selects a GL4bc rather than a GL4 profile). 

For triggering this bug in the junit test I guess we need a revised dumpVersion/DumpGLInfo, so I created a small test program instead.
Comment 6 Sven Gothel 2011-08-23 15:03:55 CEST
fixed (jogl: 4a77b439ca85a29c1cf5ac5043c4ef03c4206e0d)

sorry, it was copy/paste code bug. thx for being persistent demonstrating it.