Finishing work on font renderer and working UIRenderer
This commit is contained in:
parent
a061b267f7
commit
857f5eec64
@ -66,7 +66,7 @@ public class NewInputTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void applyWindowSize(Window window) {
|
private void applyWindowSize(Window window) {
|
||||||
int scale = 0;
|
int scale = 2;
|
||||||
guiShader.get().proView.set(new Matrix4f().ortho(0, 0, window.width() >> scale, window.height() >> scale, 1000, -1000));
|
guiShader.get().proView.set(new Matrix4f().ortho(0, 0, window.width() >> scale, window.height() >> scale, 1000, -1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,7 @@ public abstract non-sealed class GuiComponent extends FlagObject implements ICas
|
|||||||
animator = null;
|
animator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateComponent() {
|
protected void updateComponent() {
|
||||||
children.forEach(GuiComponent::updateComponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderComponent(IUIRenderer renderer, int mouseX, int mouseY, float partialTicks) {
|
protected void renderComponent(IUIRenderer renderer, int mouseX, int mouseY, float partialTicks) {
|
||||||
@ -83,6 +82,14 @@ public abstract non-sealed class GuiComponent extends FlagObject implements ICas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void tickComponent(GuiComponent comp) {
|
||||||
|
if(comp.renderer != null && comp.renderer.overrideTick()) {
|
||||||
|
comp.renderer.updateComponent(comp);
|
||||||
|
}
|
||||||
|
else comp.updateComponent();
|
||||||
|
comp.children.forEach(GuiComponent::tickComponent);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean renderComponent(GuiComponent comp, IUIRenderer renderer, int mouseX, int mouseY, float partialTicks) {
|
public static boolean renderComponent(GuiComponent comp, IUIRenderer renderer, int mouseX, int mouseY, float partialTicks) {
|
||||||
if(!comp.isVisible()) return false;
|
if(!comp.isVisible()) return false;
|
||||||
comp.updateAnimations(partialTicks);
|
comp.updateAnimations(partialTicks);
|
||||||
|
@ -4,4 +4,6 @@ import speiger.src.coreengine.rendering.gui.renderer.IUIRenderer;
|
|||||||
|
|
||||||
public interface IComponentRenderer<T extends GuiComponent> {
|
public interface IComponentRenderer<T extends GuiComponent> {
|
||||||
public void renderComponent(T component, IUIRenderer renderer, int mouseX, int mouseY, float particalTicks);
|
public void renderComponent(T component, IUIRenderer renderer, int mouseX, int mouseY, float particalTicks);
|
||||||
|
public default boolean overrideTick() { return false; }
|
||||||
|
public default void updateComponent(T component) {}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class GuiContainer implements IComponentScreen, IInteractableContainer {
|
|||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
for(Object2BooleanMap.Entry<GuiComponent> entry : container) {
|
for(Object2BooleanMap.Entry<GuiComponent> entry : container) {
|
||||||
entry.getKey().updateComponent();
|
GuiComponent.tickComponent(entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ public class GLFunctions {
|
|||||||
GL45.glTextureSubImage2D(texture, mipmaps, 0, 0, width, height, externalFormat, dataFormat, pixels);
|
GL45.glTextureSubImage2D(texture, mipmaps, 0, 0, width, height, externalFormat, dataFormat, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void upload2DSubImage(int texture, int level, int xoffset, int yoffset, int width, int height, ITextureFormatType format, IGLDataType type, long pixels) {
|
public static void upload2DSubImage(int texture, int level, int xoffset, int yoffset, int width, int height, ITextureFormatType format, IGLDataType type, long pixels) {
|
||||||
// if(format.internal()) throw new IllegalArgumentException("Format ["+format.glValue()+"] is internal");
|
// if(format.internal()) throw new IllegalArgumentException("Format ["+format.glValue()+"] is internal");
|
||||||
upload2DSubImage(texture, level, xoffset, yoffset, width, height, format.glValue(), type.glValue(), pixels);
|
upload2DSubImage(texture, level, xoffset, yoffset, width, height, format.glValue(), type.glValue(), pixels);
|
||||||
|
10
src/main/resources/assets/base/font/rainyhearts/font.json
Normal file
10
src/main/resources/assets/base/font/rainyhearts/font.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"type": "free-ttf",
|
||||||
|
"regular": {
|
||||||
|
"file": "font/rainyhearts/rainyhearts.ttf",
|
||||||
|
"oversample": 2,
|
||||||
|
"shadowOffset": 1,
|
||||||
|
"skip": "",
|
||||||
|
"offset": { "x": 0, "y": 0 }
|
||||||
|
}
|
||||||
|
}
|
BIN
src/main/resources/assets/base/font/roboto/Roboto-ExtraLight.ttf
Normal file
BIN
src/main/resources/assets/base/font/roboto/Roboto-ExtraLight.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/assets/base/font/roboto/Roboto-Light.ttf
Normal file
BIN
src/main/resources/assets/base/font/roboto/Roboto-Light.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/assets/base/font/roboto/Roboto-Regular.ttf
Normal file
BIN
src/main/resources/assets/base/font/roboto/Roboto-Regular.ttf
Normal file
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"type": "free-ttf",
|
"type": "free-ttf",
|
||||||
"regular": {
|
"regular": {
|
||||||
"file": "font/roboto/rainyhearts.ttf",
|
"file": "font/roboto/Roboto-Light.ttf",
|
||||||
"oversample": 2,
|
"oversample": 2,
|
||||||
"shadowOffset": 1,
|
"shadowOffset": 1,
|
||||||
"skip": "",
|
"skip": "",
|
||||||
|
@ -9,7 +9,5 @@ uniform sampler2D texture;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 color = pass_color * texture2D(texture, pass_tex);
|
frag_color = pass_color * texture2D(texture, pass_tex);
|
||||||
if(color.a < 0.25) discard;
|
|
||||||
frag_color = color;
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user