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  
  [JOGL2]Little patch suggestions for GLJPanel  (Read 871 times)
0 Members and 1 Guest are viewing this topic.
Offline Fancy

Senior Newbie





« Posted 2010-01-09 17:00:49 »

Hi,

I tried to use GL3 with the GLJPanel, but it gives me an exception:

1  
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Not a GL2 implementation[..]


So I looked at the source code of the GLJPanel Class and found three little pieces of code that need to be changed to make GLJPanel compatible with GL3 and GL2.

The first two are easy:

1  
2  
3  
4  
573c573
<         getGL().getGL2().glViewport(viewportX, viewportY, panelWidth, panelHeight);
---
>         getGL().getGL().glViewport(viewportX, viewportY, panelWidth, panelHeight);



1  
2  
3  
4  
816c816
<           GL2 gl = getGL().getGL2();
---
>           GL gl = getGL().getGL();


The third one is a little ugly, but maybe there is a better jogl way for doing the same:

1  
2  
3  
4  
5  
831c831,833
<           gl.glReadBuffer(GL2.GL_FRONT);
---
>           if(getGL().isGL3()) getGL().getGL3().glReadBuffer(GL2.GL_FRONT);
>           else getGL().getGL2().glReadBuffer(GL2.GL_FRONT);




Additionally, I had a problem with the width of the GLJPanel. This problem is irrespectively from GL2/GL3 and seems to be the same as described here: http://www.java-gaming.org/topics/using-gljpanel-on-jogl-2-0/21772/view.html

I debug this, but the panel and the offscreenImage had the right size. The pBuffer is big enough, too. But the offscreenImage had a black strip on the right side. So I do not really know where the problem exactly is, but this work around works here:

1  
2  
3  
4  
5  
1094,1095c1096
<         pbufferWidth = getNextPowerOf2(panelWidth);
<         pbufferHeight = getNextPowerOf2(panelHeight);
---
>         pbufferWidth = pbufferHeight = Math.max(getNextPowerOf2(panelWidth), getNextPowerOf2(panelHeight));


(I think this need a little more research)


If you want to try this, you can download the whole GLJPanel.java from here: http://too-late.de/snippets/GLJPanel.java

It will be very nice if one of the jogl maintainer can look over this suggestions, make it jogl conform and use a little bit of it in the official source.


Thanks and best regards,
Fancy
Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2010-01-09 20:58:49 »

Quote
1  
2  
>           if(getGL().isGL3()) getGL().getGL3().glReadBuffer(GL2.GL_FRONT);
>           else getGL().getGL2().glReadBuffer(GL2.GL_FRONT);


This could be:
1  
getGL().getGL2GL3().glReadBuffer(GL2.GL_FRONT);


The GL2GL3 profile is the profile intersection between GL2 and GL3, which I find very useful in situations such as this.

Offline Fancy

Senior Newbie





« Reply #2 - Posted 2010-01-10 19:25:44 »

This could be:
1  
getGL().getGL2GL3().glReadBuffer(GL2.GL_FRONT);


The GL2GL3 profile is the profile intersection between GL2 and GL3, which I find very useful in situations such as this.

Oh yes, that's much clearer! (I never noticed the GL2GL3 profile before.)

Best regards,
Fancy
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!
 
Get high quality music tracks 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 (132 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (231 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.166 seconds with 21 queries.