JLSL
JLSL copied to clipboard
Compiling Java classes to GLSL
In some cases, it should be possible to translate Java classes to GLSL structs, but I'm not sure if JLSL can do this yet. This is a simple Java class with instance methods that can be converted to GLSL:
public class Rectangle{
public float width;
public float height;
public Rectangle(float width,float height){
this.width = width;
this.height = height;
}
public float area(){
return this.width*this.height;
}
public float perimeter(){
return (this.width+this.height)*2.0;
}
}
Then the JLSL compiler's output might look like this:
struct Rectangle{
float width;
float height;
};
Rectangle new(float width,float height){
Rectangle self;
self.width = width;
self.height = height;
return self;
}
float area(Rectangle self){
return self.width*self.height;
}
float perimeter(Rectangle self){
return (self.width+self.height)*2.0;
}
An instance of the class could also be initialized:
Rectangle shape = new(1.0,1.0);
float area = area(shape);
Would it be feasible to implement this feature in JLSL?