Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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  
  creating a GL3 object in QtJambi  (Read 1511 times)
0 Members and 1 Guest are viewing this topic.
Offline voodoogiant

Senior Newbie





« Posted 2010-10-08 05:42:04 »

I'm having some difficulty getting a GL3 context now that I've
switched to QtJambi.  When casting my gl object to GL using getGL3, it
throws the error "javax.media.opengl.GLException: Not a GL3
implementation".

This is my original code when I was using swing...
GLProfile profile = GLProfile.get(GLProfile.GL3)
GLCapabilities glCaps = new GLCapabilities(profile)
glCaps.setPBuffer(true)
GLPBuffer pbuffer =
GLDrawableFactory.getFactory(profile).createGLPbuffer(glCaps,

      new DefaultGLCapabilitiesChooser(),

      1, 1, null)
canvas = new GLCanvas(glCaps, new DefaultGLCapabilitiesChooser(),
PanelGL.pbuffer.getContext(), null)

Switch to QtJambi, I have the following code:


   GLProfile profile = GLProfile.get(GLProfile::GL3)
   GLCapabilities glCaps = GLCapabilities.new(profile)
   glCaps.setPBuffer(true)
   factory = GLDrawableFactory.getFactory(profile)
   ctx = factory.createExternalGLContext
   gl = ctx.getGL.getGL3

This last line throws an error.  I've seen this page
(http://www.java-gaming.org/index.php?action=printpage;topic=21064.0),
which solves the issue, but it's passing something to a GLCanvas
constructor, which is swing.  Is there an equivalent setup in QtJambi
to get me a GL3 object?
Offline gouessej

JGO Ninja


Medals: 33
Projects: 1


TUER


« Reply #1 - Posted 2010-10-08 12:34:47 »

Hi!

Don't cast your object, rather call GLContext.getCurrentGL().getGL3() (as you already do). DefaultGLCapabilitiesChooser does not depend on Swing:
1  
2  
3  
4  
5  
package javax.media.opengl;

import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindowException;
import com.jogamp.opengl.impl.Debug;


Which build of JOGL 2 beta do you use?

Offline voodoogiant

Senior Newbie





« Reply #2 - Posted 2010-10-08 18:20:12 »

So you're saying GLContext.getCurrentGL().getGL3() provides different functionality than ctx.getGL.getGL3()?  Should I not be using an external context then?  I was hoping to eventually have the OpenGL context shared across multiple windows like I did with swing, but was trying to keep this simple for now.  Are there any QtJambi examples out there that use a GL3 implementation? 

I believe I'm using the latest nightly JOGL build.  Here are the jars I'm using...
http://code.google.com/p/sunshine/source/browse/#hg/lib/jogl-2.0-linux-i586
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline voodoogiant

Senior Newbie





« Reply #3 - Posted 2010-10-09 17:05:19 »

Adding GLContext.getCurrentGL().getGL3() at the end of my initializeGL function returns an error saying there's not context current

1  
Exception in thread "main" javax/media/opengl/GLContext.java:159:in `getCurrentGL': javax.media.opengl.GLException: No OpenGL context current on this thread (NativeException)


1  
2  
3  
4  
5  
6  
7  
8  
9  
  public void initializeGL() {
    profile = GLProfile.get(GLProfile.GL3)
    glCaps = GLCapabilities.new(profile)
    glCaps.setPBuffer(true)
    factory = GLDrawableFactory.getFactory(profile)
    ctx = factory.createExternalGLContext()
    gl = GLContext.getCurrentGL().getGL3()
    //gl = ctx.getGL.getGL3
}
Offline gouessej

JGO Ninja


Medals: 33
Projects: 1


TUER


« Reply #4 - Posted 2010-10-09 17:34:04 »

So you're saying GLContext.getCurrentGL().getGL3() provides different functionality than ctx.getGL.getGL3()?  Should I not be using an external context then?  I was hoping to eventually have the OpenGL context shared across multiple windows like I did with swing, but was trying to keep this simple for now.  Are there any QtJambi examples out there that use a GL3 implementation? 

I believe I'm using the latest nightly JOGL build.  Here are the jars I'm using...
http://code.google.com/p/sunshine/source/browse/#hg/lib/jogl-2.0-linux-i586
No, JOGL 2 is rather there:
http://jogamp.org/deployment/autobuilds/
I have no example of use with both JOGL 2 and QtJambi. Personally I use JOGL 2 with Ardor3D and/or Eclipse RCP/SWT, I have found a good tutorial about it:
http://wadeawalker.wordpress.com/2010/10/09/tutorial-a-cross-platform-workbench-program-using-java-opengl-and-eclipse/

Adding GLContext.getCurrentGL().getGL3() at the end of my initializeGL function returns an error saying there's not context current
initializeGL() seems to be called when the OpenGL context is not current, it should be called in the init method of GLEventListener.

Offline voodoogiant

Senior Newbie





« Reply #5 - Posted 2010-10-11 19:11:36 »

I'm not using a GLEventListener.  I'm using a QGLWidget.  I ended up having to call makeCurrent in the objects initializeGL call, which seemed to resolve the siutation.  I added notes of how to do it (in JRuby) in a blog post (http://strattonbrazil.blogspot.com/2010/10/incorporating-scala-java-sbt-jogl-qt.html).
Offline gouessej

JGO Ninja


Medals: 33
Projects: 1


TUER


« Reply #6 - Posted 2010-10-15 01:06:34 »

I'm not using a GLEventListener.  I'm using a QGLWidget.  I ended up having to call makeCurrent in the objects initializeGL call, which seemed to resolve the siutation.  I added notes of how to do it (in JRuby) in a blog post (http://strattonbrazil.blogspot.com/2010/10/incorporating-scala-java-sbt-jogl-qt.html).
Thank you very much for this tip  Grin

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

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (111 views)
2013-05-17 21:29:12

alaslipknot (120 views)
2013-05-16 21:24:48

gouessej (150 views)
2013-05-16 00:53:38

gouessej (143 views)
2013-05-16 00:17:58

theagentd (156 views)
2013-05-15 15:01:13

theagentd (140 views)
2013-05-15 15:00:54

StreetDoggy (184 views)
2013-05-14 15:56:26

kutucuk (208 views)
2013-05-12 17:10:36

kutucuk (208 views)
2013-05-12 15:36:09

UnluckyDevil (214 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.147 seconds with 21 queries.