Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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  
  Crosscompiler Java -> GLSL?  (Read 7099 times)
0 Members and 1 Guest are viewing this topic.
Offline krasse
« Posted 2010-05-26 11:45:28 »

Hi!

I got a bit inspired by Google's GWT and their crosscompilation (source-to-source translation) from Java to JavaScript and thought about doing the same for Java to GLSL.

Are you aware of any existing projects that can do this?

Personally, I think it is a fantastic idea because then you could debug your (emulated and slow) shaders using e.g. Eclipse and then just translate and get the (fast) shader code.

Offline cylab

JGO Ninja


Medals: 45



« Reply #1 - Posted 2010-05-26 22:29:13 »

Actually GLSL and Java are so different in scope, verbosity and data access, that such a thing could hardly be useful.

Mathias - I Know What [you] Did Last Summer!
Offline krasse
« Reply #2 - Posted 2010-05-27 14:12:51 »

Actually GLSL and Java are so different in scope, verbosity and data access, that such a thing could hardly be useful.

I am still optimistic, but you might be right Smiley

There would have to be special Java classes for each primitive GLSL type (+ in, out and all other interfacing types) and a lot of other restrictions. I think that the debugging and coding part would be so much easier and the possibility to translate to different versions would make it useful anyway.

You use Netbeans and (perhaps develop?) the OpenGL tools right? Are there any similar tools for Eclipse?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2010-05-27 14:32:18 »

It might be more useful to make a GLSL->bytecode compiler, so that you could at least step through a shader in the Eclipse debugger.

Cas Smiley

Offline krasse
« Reply #4 - Posted 2010-05-27 21:24:06 »

It might be more useful to make a GLSL->bytecode compiler, so that you could at least step through a shader in the Eclipse debugger.

Cas Smiley

Hmm, good idea!

Got any good Java GLSL parser somewhere?

I'll go look in the Netbeans OpenGL tools and see if there is one with which you can traverse the AST.

Online Roquen
« Reply #5 - Posted 2010-12-21 06:49:35 »

The biggest problem is converting scalar code into vector (SIMD).  You could make a classes that mimic the GPU types, but then you might as well directly write GPU code.  If you want to be able to debugger shader code, there are tools for that.
Offline krasse
« Reply #6 - Posted 2010-12-26 09:40:20 »

If there is a very good tool available for GPU code that supports refactoring and immediate feedback through continuous compilation and all that nice Eclipse/Netbeans-like stuff, I would certainly prefer that. Besides, it very nice to be able to simulate different GPUs in software. You could for example simulate several different GPUs without owning the actual hardware. Such an effort will require the combined forces of 1000 gods though Wink

Offline gouessej
« Reply #7 - Posted 2010-12-26 09:59:26 »

krasse, even a simple Java dialect to write GLSL shaders would be interesting on my view. It would be fine if we could choose which GLSL version it should support in order to use the proper keywords. If a shader is modified, it should simply reset it (glShaderSource) and recompile it, shouldn't it?

Offline edeal

Senior Newbie


Medals: 3



« Reply #8 - Posted 2012-11-29 12:20:50 »

I'm trying to make Java2GLSL.(used ASM)
About 3weeks to work, and soon i make the alpha version.

Concept. (Current progress)

Java Code
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
VertexShader vtxShader = new VertexShader() {
   public void main() {
      mat4 mat1 = new mat4();
      mat4 mat2 = new mat4();
      gl_Position = mat1.mult(mat2).mult((vec4)gl_Position);
   }
};
StringWriter writer = new StringWriter();
J2GLSLConverter glslConverter = new J2GLSLConverter();
//glslConverter.debugOpCodeStack = true;
glslConverter.compile( writer, vtxShader );
System.out.println( writer.toString() );


Output GLSL Code
1  
2  
3  
4  
5  
6  
void main(  )
{
   mat4 mat1;
   mat4 mat2;
   gl_Position = mat1 * mat2 * gl_Position;
}

Offline krasse
« Reply #9 - Posted 2012-11-29 13:04:23 »

Cool!
I had forgot about this thread. It was back in the good old days when I had the "do absolutely everything in Java"-syndrome Smiley

Still think it is a great idea though!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #10 - Posted 2012-11-29 13:32:27 »

Nice try  Grin

Offline Danny02
« Reply #11 - Posted 2012-11-29 16:16:24 »

I just can't see the benefit of this

If I would want to generate shader code on the fly, there would be many simpler ways to do it.

Debugging shaders with Java?  I don't think that you could do anything usefull with it.

I'm quite happy right now with my shader hot-reload function and auto binding system I have
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 783
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #12 - Posted 2012-11-29 17:29:37 »

I'm quite happy right now with my shader hot-reload function and auto binding system I have
Your point is that you don't need public solution X, because you developed private solution Y. How does that help us? Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Danny02
« Reply #13 - Posted 2012-11-29 18:48:50 »

I'm quite happy right now with my shader hot-reload function and auto binding system I have
Your point is that you don't need public solution X, because you developed private solution Y. How does that help us? Smiley

all my stuff is opensource and accessable at github. It might not be that well documented and so on. I would be happy to discuss, share and help with things like that. I just wanted to point out my take on shader development.


Update: some additional thoughts, I liked the netbeans opengl pack which gave autocomplete, code highlighting + compiler warnings for GLSL, but it somehow don't work for me anymore. There is also GeDebugger(?) out there (now owned by AMD) which is made into a visual studio plugin, but return as a standalone also I think. The last time I tried it with JOGL it didn't quite work, but I guess with some experimenting we should get it to run.
Offline gouessej
« Reply #14 - Posted 2012-11-29 21:49:21 »

Update: some additional thoughts, I liked the netbeans opengl pack which gave autocomplete, code highlighting + compiler warnings for GLSL, but it somehow don't work for me anymore.
Netbeans OpenGL pack is no more maintained, I'm really sorry.

There is also GeDebugger(?) out there (now owned by AMD) which is made into a visual studio plugin, but return as a standalone also I think. The last time I tried it with JOGL it didn't quite work, but I guess with some experimenting we should get it to run.
Please ask some help on the official JogAmp forum. As far as I know, Sven succeeded in using multiple tools to do that, including one from Nvidia.

Thank you for sharing your source code.

Offline edeal

Senior Newbie


Medals: 3



« Reply #15 - Posted 2012-12-13 09:08:00 »

I released the alpha version.

Check this
http://code.google.com/p/j2glsl/

Source code (SVN)
http://j2glsl.googlecode.com/svn/trunk/

And there included example of using j2glsl.
Offline Danny02
« Reply #16 - Posted 2012-12-13 09:21:05 »

it is indeed a very interesting project.
Looking forward for support of modern GLSL.

Have to think if this can be of use for me in anyway.

one plus of it would be compile time type checking, does it do that(how verbose is your error output btw?)
Offline davedes
« Reply #17 - Posted 2012-12-13 09:30:40 »

Aside from error checking when writing the shaders, are there any other benefits? Undecided

I think a more elegant solution for this would be an IDE plugin or standalone tool that has auto-correct and automatic error checking as you type (for e.g. "error assigning vec3 to vec2").

Offline edeal

Senior Newbie


Medals: 3



« Reply #18 - Posted 2012-12-13 10:25:20 »

Quote
I think a more elegant solution for this would be an IDE plugin or standalone tool that has auto-correct and automatic error checking as you type (for e.g. "error assigning vec3 to vec2").
Yeah i think so too. Maybe IDE plugin has better solution.

Quote
one plus of it would be compile time type checking, does it do that(how verbose is your error output btw?)
No.
That shader java code must be compiled. It is why i used ASM.
Currently, It is throw simple exception. But i will add more error-checking code in the future.

in addition my english is terrible. sorry about that.  Cry
Offline krasse
« Reply #19 - Posted 2012-12-13 11:27:45 »

Aside from error checking when writing the shaders, are there any other benefits? Undecided

I think a more elegant solution for this would be an IDE plugin or standalone tool that has auto-correct and automatic error checking as you type (for e.g. "error assigning vec3 to vec2").

If you can also implement the operations and create a software shader, I think that you also get the benefit of debugging.

Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #20 - Posted 2012-12-13 11:55:52 »

I think a more elegant solution for this would be an IDE plugin or standalone tool that has auto-correct and automatic error checking as you type (for e.g. "error assigning vec3 to vec2").
This should be easy in Swing. The editor for the TableLayout DSL (which is now obsolete (the DSL is obsolete, TableLayout is still very much alive Smiley)) does it using RSyntaxTextArea:
http://table-layout.googlecode.com/svn/wiki/jws/editor.jnlp
After an edit it tries to compile, catches any exception, determines the line and column for the error, and applies red squiggly underlines. RSyntaxTextArea makes error underlines, syntax highlighting, code completion, auto indent, curly brace matching, line wrap, etc very easy. Also the author is very responsive to requests. Source for the editor is here:
https://code.google.com/p/table-layout/source/browse/branches/v1/tablelayout-editor/src/com/esotericsoftware/tablelayout/swing/TableLayoutEditor.java#52

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.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (32 views)
2014-08-22 19:31:30

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

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

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

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

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

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

BurntPizza (49 views)
2014-08-09 21:09:32
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!