-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support for entity rotations through model matricies
- Loading branch information
Showing
5 changed files
with
56 additions
and
28 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
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
31 changes: 31 additions & 0 deletions
31
...ook/src/main/java/dk/sebsa/spellbook/graphics/opengl/renderer/GLSpriteEntityRenderer.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,31 @@ | ||
package dk.sebsa.spellbook.graphics.opengl.renderer; | ||
|
||
import dk.sebsa.spellbook.asset.Identifier; | ||
import dk.sebsa.spellbook.graphics.opengl.components.SpriteRenderer; | ||
import dk.sebsa.spellbook.math.Rect; | ||
import dk.sebsa.spellbook.math.Vector2f; | ||
|
||
/** | ||
* Renders 2D objects in batches | ||
* (Same as GL2DRender just with model matricies) | ||
* | ||
* @author sebs | ||
* @since 1.0.0 | ||
*/ | ||
public class GLSpriteEntityRenderer extends GLSpriteRenderer { | ||
public GLSpriteEntityRenderer(Identifier shaderI) { | ||
super(shaderI); | ||
shader.createUniform("mModel"); | ||
} | ||
|
||
public void drawSprite(SpriteRenderer sr) { | ||
Rect uvRect = sr.getSprite().getUV(); | ||
|
||
Vector2f size = new Vector2f(sr.getSprite().getOffset().width, sr.getSprite().getOffset().height); | ||
|
||
drawQuad(new Rect(size.mul(sr.anchor).mul(-sr.scale), size.mul(sr.scale)), | ||
uvRect); | ||
shader.setUniform("mModel", sr.getEntity().transform.getMatrix2D()); | ||
flush(); | ||
} | ||
} |
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: 4 additions & 3 deletions
7
spellbook/src/main/resources/spellbook/shaders/SpellbookSprite.glsl
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