Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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  
  Shaders written in GLSL?  (Read 1957 times)
0 Members and 1 Guest are viewing this topic.
Offline Chagma

Senior Newbie





« Posted 2010-02-15 09:37:04 »

Is it possible with either JOGL or LWGL to use shaders written in the OpenGL shading language GLSL?  If not, how do you write shaders for use in Java/OpenGL software?
Offline indexunknown

Junior Member





« Reply #1 - Posted 2010-02-15 09:47:19 »

http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/opengl/basicshaders
Offline Chagma

Senior Newbie





« Reply #2 - Posted 2010-02-15 09:54:02 »

Wow, thanks for the quick response!

Do you know if such a thing is also possible in JOGL?  I am probably going to have to use JOGL because I need my game to be able to run inside a JPanel and I don't think LWJGL can do that (?).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2010-02-15 10:01:01 »

Yes, it can (see AWTGLCanvas or Display.setParent() in the LWJGL APIs).

Cas Smiley

Offline xinaesthetic

Senior Member


Medals: 1



« Reply #4 - Posted 2010-02-15 10:26:18 »

Wow, thanks for the quick response!

Do you know if such a thing is also possible in JOGL?  I am probably going to have to use JOGL because I need my game to be able to run inside a JPanel and I don't think LWJGL can do that (?).
I'd be sceptical about using JOGL to render a game in a JPanel... it tends to be slow, unless you use the OpenGL Swing pipeline, in which case it tends not to work reliably.
Offline Chagma

Senior Newbie





« Reply #5 - Posted 2010-02-15 10:28:35 »

Oh, can you be more specific?  What do you mean by "not to work reliably"?
Offline xinaesthetic

Senior Member


Medals: 1



« Reply #6 - Posted 2010-02-15 10:59:45 »

See this demo, for example:
http://weblogs.java.net/blog/campbell/archive/2006/10/easy_2d3d_mixin.html

The OpenGL pipeline enabled version doesn't work on my laptop with a decent-ish graphics card, up to date drivers and JRE etc.  I just tried it now, and the window appears white (resizing causes the newly exposed parts of the panel to appear black).  I'm sure I've other examples using a similar method, none of which worked.  So, I'd trust that technique about as far as I can throw it.  Maybe someone will come to its defence.

On the other hand, the version without Java2D OpenGL pipeline wasn't as slow as I feared; about 30-40 fps with the window at its default size, dropping to 10 when maximised to 1920x1080.  That might be usable enough after all.
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #7 - Posted 2010-02-15 11:09:06 »

The main issue is the way the GL renders to a buffer and then the buffer has to be rendered into the JPanel, it being a lightweight component. You can solve this by doing away with lightweight components and going straight to a Canvas but you'll run in to a few glitches if you overlay any other lightweight components on it. In practice, this almost is never a problem until you use a JMenu of some sort, which you have to work around by specifying that it's heavyweight. The problem is allegedly completely fixed in JDK7 which will allow proper layering of lightweight and heavyweight components, and I'm sure I spotted something in the latest 6_018 update to do with this as well...

Cas Smiley

Offline Chagma

Senior Newbie





« Reply #8 - Posted 2010-02-15 11:11:07 »

OK, thanks for the info.  I also cannot get any demo of the Java2D/OpenGL pipeline to work on a couple of machines.

Anyway, my original question stands: can GLSL shaders be used with JOGL?  We have established that it can be done with LWJGL but I'd like to know the situation with JOGL too.
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2010-02-15 11:14:10 »

Yes, they work.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #10 - Posted 2010-02-15 11:16:35 »

Oh, can you be more specific?  What do you mean by "not to work reliably"?
On a few machines, you may have a noticeable performance hit by using GLJPanel rather than GLCanvas or a native window.

Offline gouessej
« Reply #11 - Posted 2010-02-15 11:18:43 »

OK, thanks for the info.  I also cannot get any demo of the Java2D/OpenGL pipeline to work on a couple of machines.

Anyway, my original question stands: can GLSL shaders be used with JOGL?  We have established that it can be done with LWJGL but I'd like to know the situation with JOGL too.
Yes it works fine with JOGL. I used it some years ago Smiley

Offline Chagma

Senior Newbie





« Reply #12 - Posted 2010-02-15 11:20:02 »

Yes, they work.

Cas Smiley

I have to say I am impressed with the speed and quality of responses in this forum!

So are they implemented in basically the same way as with LWJGL?
Offline princec

JGO Kernel


Medals: 362
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2010-02-15 12:08:15 »

Pretty much, yes. In fact neither of the two bindings actually "implement" anything, they just pass it through to the driver with the minimum of overhead and fuss.

Cas Smiley

Offline xinaesthetic

Senior Member


Medals: 1



« Reply #14 - Posted 2010-02-15 12:09:04 »

On a few machines, you may have a noticeable performance hit by using GLJPanel rather than GLCanvas or a native window.
The trouble is if you specify OpenGL pipeline (to get higher performance rendering due to not having to copy buffers the whole time) sometimes rather than a performance hit, you get a complete failure to render any graphics.  So unless it's acceptable for the application to only work on specific machines, that's one to avoid.  The new compositing stuff sounds promising.

op: If you take a look in the JOGL demos I'm sure there's some examples with GLSL.

If only all threads got such a positive response Wink
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.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!