Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (499)
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 1101 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.

 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (26 views)
2014-04-14 17:35:47

Porlus (42 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (224 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!