-
Notifications
You must be signed in to change notification settings - Fork 2
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
bb1c7df
commit 1e7c24d
Showing
14 changed files
with
96 additions
and
113 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
2 changes: 0 additions & 2 deletions
2
src/library/java/gg/generations/rarecandy/pokeutils/CustomMaterialReference.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
2 changes: 0 additions & 2 deletions
2
src/library/java/gg/generations/rarecandy/pokeutils/DiffuseMaterialReference.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
2 changes: 0 additions & 2 deletions
2
src/library/java/gg/generations/rarecandy/pokeutils/MaskReferenceMaterial.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
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
7 changes: 7 additions & 0 deletions
7
src/library/java/gg/generations/rarecandy/renderer/loading/ITexture.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,7 @@ | ||
package gg.generations.rarecandy.renderer.loading; | ||
|
||
import java.io.Closeable; | ||
|
||
public interface ITexture extends Closeable { | ||
void bind(int slot); | ||
} |
49 changes: 0 additions & 49 deletions
49
src/library/java/gg/generations/rarecandy/renderer/loading/Texture.java
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
src/library/java/gg/generations/rarecandy/renderer/model/material/ImageSupplier.java
This file was deleted.
Oops, something went wrong.
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
63 changes: 63 additions & 0 deletions
63
src/main/java/gg/generations/rarecandy/renderer/loading/Texture.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,63 @@ | ||
package gg.generations.rarecandy.renderer.loading; | ||
|
||
import gg.generations.rarecandy.pokeutils.reader.TextureReference; | ||
import org.lwjgl.opengl.GL11C; | ||
import org.lwjgl.opengl.GL13C; | ||
import org.lwjgl.opengl.GL40; | ||
import org.lwjgl.system.MemoryUtil; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.function.Supplier; | ||
|
||
public class Texture implements ITexture, Supplier<ITexture> { | ||
|
||
public final String name; | ||
public int id; | ||
|
||
private boolean initalized = false; | ||
|
||
private final BufferedImage image; | ||
|
||
public Texture(TextureReference reference) { | ||
name = reference.name(); | ||
image = reference.data(); | ||
|
||
} | ||
|
||
public void bind(int slot) { | ||
assert (slot >= 0 && slot <= 31); | ||
GL13C.glActiveTexture(GL13C.GL_TEXTURE0 + slot); | ||
GL11C.glBindTexture(GL11C.GL_TEXTURE_2D, this.id); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
GL40.glDeleteTextures(id); | ||
} | ||
|
||
@Override | ||
public ITexture get() { | ||
if(!initalized) { | ||
id = GL11C.glGenTextures(); | ||
|
||
var buffer = TextureReference.read(image); | ||
|
||
GL11C.glBindTexture(GL11C.GL_TEXTURE_2D, this.id); | ||
GL11C.glTexImage2D(GL11C.GL_TEXTURE_2D, 0, GL11C.GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL11C.GL_RGBA, GL11C.GL_UNSIGNED_BYTE, buffer); | ||
|
||
GL11C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_S, GL11C.GL_REPEAT); | ||
GL11C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_T, GL11C.GL_REPEAT); | ||
|
||
GL11C.glTexParameterf(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_NEAREST); | ||
GL11C.glTexParameterf(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_NEAREST); | ||
|
||
MemoryUtil.memFree(buffer); | ||
|
||
initalized = true; | ||
} | ||
|
||
return this; | ||
} | ||
} |
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