8000 Compiling Java classes to GLSL · Issue #1 · jglrxavpok/JLSL · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Compiling Java classes to GLSL #1
Open
@jarble

Description

@jarble

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 al 4FF3 so be initialized:

Rectangle shape = new(1.0,1.0);
float area = area(shape);

Would it be feasible to implement this feature in JLSL?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0