-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c66a63a
commit 163985c
Showing
15 changed files
with
219 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
...porter/src/main/java/com/shade/decima/ui/data/viewer/model/menu/ChangeBackgroundItem.java
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
modules/decima-ext-model-viewer/src/main/java/com/shade/decima/model/viewer/Image.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.shade.decima.model.viewer; | ||
|
||
import java.nio.Buffer; | ||
import java.util.Collection; | ||
|
||
public interface Image { | ||
enum ColorSpace { | ||
LINEAR, | ||
SRGB | ||
} | ||
|
||
interface Channel { | ||
String getName(); // R, G, B, A, etc. | ||
|
||
ColorSpace getColorSpace(); | ||
|
||
Buffer getData(); // ByteBuffer, ShortBuffer, etc. | ||
} | ||
|
||
String getFormatName(); | ||
|
||
int getWidth(); | ||
|
||
int getHeight(); | ||
|
||
Collection<Channel> getChannels(); | ||
|
||
// ImageDescriptor(channels=[ | ||
// (name=R, colorSpace=SRGB, type=uint8), | ||
// (name=G, colorSpace=SRGB, type=uint8), | ||
// (name=B, colorSpace=SRGB, type=uint8), | ||
// (name=A, colorSpace=LINEAR, type=uint8) | ||
// ]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...a-ext-model-viewer/src/main/java/com/shade/decima/model/viewer/renderer/GridRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.shade.decima.model.viewer.renderer; | ||
|
||
import com.shade.decima.model.viewer.Camera; | ||
import com.shade.decima.model.viewer.ModelViewport; | ||
import com.shade.decima.model.viewer.shader.GridShaderProgram; | ||
import com.shade.platform.model.Disposable; | ||
import com.shade.util.NotNull; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.lwjgl.opengl.GL11.*; | ||
|
||
public class GridRenderer extends QuadRenderer { | ||
private GridShaderProgram program; | ||
|
||
@Override | ||
public void setup() throws IOException { | ||
super.setup(); | ||
|
||
program = new GridShaderProgram(); | ||
} | ||
|
||
@Override | ||
public void render(float dt, @NotNull ModelViewport viewport) { | ||
final Camera camera = viewport.getCamera(); | ||
|
||
glEnable(GL_BLEND); | ||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
|
||
try (var program = (GridShaderProgram) this.program.bind()) { | ||
program.getView().set(camera.getViewMatrix()); | ||
program.getProjection().set(camera.getProjectionMatrix()); | ||
|
||
super.render(dt, viewport); | ||
} | ||
|
||
glDisable(GL_BLEND); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
super.dispose(); | ||
|
||
Disposable.dispose(program); | ||
program = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
...t-model-viewer/src/main/java/com/shade/decima/model/viewer/renderer/ViewportRenderer.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
...xt-model-viewer/src/main/java/com/shade/decima/model/viewer/shader/GridShaderProgram.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.shade.decima.model.viewer.shader; | ||
|
||
import com.shade.gl.Attribute; | ||
import com.shade.gl.Shader; | ||
import com.shade.gl.Shader.Type; | ||
import com.shade.gl.ShaderProgram; | ||
import com.shade.gl.UniformMat4; | ||
import com.shade.util.NotNull; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public class GridShaderProgram extends ShaderProgram { | ||
private final UniformMat4 view; | ||
private final UniformMat4 projection; | ||
|
||
public GridShaderProgram() throws IOException { | ||
super( | ||
Map.of( | ||
Shader.fromResource("grid.vert"), Type.VERTEX, | ||
Shader.fromResource("grid.frag"), Type.FRAGMENT | ||
), | ||
Map.of( | ||
"in_position", Attribute.Semantic.POSITION | ||
) | ||
); | ||
|
||
this.view = UniformMat4.create(this, "view"); | ||
this.projection = UniformMat4.create(this, "projection"); | ||
} | ||
|
||
@NotNull | ||
public UniformMat4 getView() { | ||
return view; | ||
} | ||
|
||
@NotNull | ||
public UniformMat4 getProjection() { | ||
return projection; | ||
} | ||
} |
Oops, something went wrong.