Compare commits
3 Commits
aa68958a77
...
4a25dc4694
Author | SHA1 | Date |
---|---|---|
DaniTheSkunk | 4a25dc4694 | |
DaniTheSkunk | ca38735484 | |
DaniTheSkunk | 0323799a85 |
|
@ -40,8 +40,12 @@ public interface IWindow {
|
|||
|
||||
void setDebug(boolean on);
|
||||
|
||||
void setRenderSize(Vec2i size);
|
||||
|
||||
void setScaler(String scaler);
|
||||
|
||||
void setWindowSize(Vec2i size);
|
||||
|
||||
boolean shouldClose();
|
||||
|
||||
void startFrame();
|
||||
|
|
|
@ -17,7 +17,8 @@ public class Test3D extends BaseGame {
|
|||
Model model;
|
||||
|
||||
public Test3D() {
|
||||
super(new Vec2i(1920/4, 1080/4), "Skunkworks 3d test");
|
||||
super(new Vec2i(1920, 1080), "Skunkworks 3d test");
|
||||
window.setRenderSize(new Vec2i(1920/8, 1080/8));
|
||||
System.out.printf("assimp version: %d.%d.%d\n",
|
||||
Assimp.aiGetVersionMajor(),
|
||||
Assimp.aiGetVersionMinor(),
|
||||
|
@ -25,8 +26,8 @@ public class Test3D extends BaseGame {
|
|||
);
|
||||
trans = 255;
|
||||
var path = "C:\\stream\\models\\Dani.vrm";
|
||||
//path = "C:\\stream\\models\\Amber_Arakada_V5_Blendshape.glb";
|
||||
//path = "C:\\stream\\models\\Temp Chan 3.glb";
|
||||
path = "C:\\stream\\models\\Amber_Arakada_V5_Blendshape.glb";
|
||||
path = "C:\\stream\\models\\Temp Chan 3.glb";
|
||||
var bytes = engine.loadBytes(path);
|
||||
model = new Model(bytes, window);
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.danitheskunk.skunkworks;
|
||||
|
||||
import com.danitheskunk.skunkworks.audio.ISample;
|
||||
import com.danitheskunk.skunkworks.gfx.font.FontTileset;
|
||||
import com.danitheskunk.skunkworks.gfx.Color;
|
||||
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||
import com.danitheskunk.skunkworks.nodes.NodeSprite;
|
||||
import com.danitheskunk.skunkworks.nodes.NodeText;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class TestNode extends BaseGame {
|
||||
private final ISample kick;
|
||||
|
@ -14,15 +14,23 @@ public class TestNode extends BaseGame {
|
|||
float[] axes;
|
||||
|
||||
public TestNode() {
|
||||
super(new Vec2i(1280, 720), "Skunkworks");
|
||||
super(new Vec2i(1920, 1080), "Skunkworks");
|
||||
|
||||
kick = loadSample("demoassets/kick.wav");
|
||||
var font = window.loadFontTileset("fonts/ega-8x14.png");
|
||||
var font2 = window.loadFontTTF("fonts/LiberationSans-Regular.ttf", 24.0f);
|
||||
text = new NodeText(font, "Hello World! this is an extra long test meow meow nya nya! nyaaa!");
|
||||
text2 = new NodeText(font2, "Hello World! this is an extra long test meow meow nya nya! nyaaa!");
|
||||
text.setMaxSize(new Vec2i(100, 100));
|
||||
text2.setMaxSize(new Vec2i(100, 100));
|
||||
var font2 = window.loadFontTTF("fonts/m3x6.ttf", 12.7f);
|
||||
var str =
|
||||
"As Gauntlet of Power enters the battlefield, choose a color.\n" +
|
||||
"\n" +
|
||||
"Creatures of the chosen color get +1/+1.\n" +
|
||||
"\n" +
|
||||
"Whenever a basic land is tapped for mana of the chosen color, its controller adds an additional one mana of that color.\n";
|
||||
text = new NodeText(font, str);
|
||||
text2 = new NodeText(font2, str);
|
||||
text.setMaxSize(new Vec2i(300, 100));
|
||||
text2.setMaxSize(new Vec2i(200, 100));
|
||||
text2.setColor(Color.BLACK);
|
||||
text.setColor(Color.BLACK);
|
||||
sprite = new NodeSprite();
|
||||
sprite.setTexture(loadTexture("demoassets/card.png"));
|
||||
sprite.setPos(new Vec2f(100, 100));
|
||||
|
@ -33,6 +41,10 @@ public class TestNode extends BaseGame {
|
|||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TestNode().run();
|
||||
}
|
||||
|
||||
void doThing() {
|
||||
sprite.tweenPos(new Vec2f(800, 400), 120).delay(60).then(() -> {
|
||||
System.out.println("yay! got there! now lets go home");
|
||||
|
@ -41,17 +53,24 @@ public class TestNode extends BaseGame {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void render(IRenderContext rc) {
|
||||
rc.clear(Color.WHITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update(double delta) {
|
||||
text.setPos(new Vec2f(640 + 640 * gamepad.getAxis(0), 360 + 360 * gamepad.getAxis(1)));
|
||||
text2.setPos(new Vec2f(440 + 640 * gamepad.getAxis(0), 360 + 360 * gamepad.getAxis(1)));
|
||||
text.setPos(new Vec2f(
|
||||
640 + 640 * gamepad.getAxis(0),
|
||||
360 + 360 * gamepad.getAxis(1)
|
||||
));
|
||||
text2.setPos(new Vec2f(
|
||||
440 + 640 * gamepad.getAxis(0),
|
||||
360 + 360 * gamepad.getAxis(1)
|
||||
));
|
||||
if(gamepad.getButtonPressed(0)) {
|
||||
playSample(kick);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TestNode().run();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ public abstract class Filter {
|
|||
}
|
||||
|
||||
public void apply() {
|
||||
//shouldn't be calculating size ratio every frame,
|
||||
//but getting all the callbacks right is hard
|
||||
calcSizeRatio();
|
||||
|
||||
output.bind();
|
||||
input.bindTexture();
|
||||
program.use();
|
||||
|
@ -53,7 +57,6 @@ public abstract class Filter {
|
|||
if(!resizing) {
|
||||
output.setSize(input.getSize());
|
||||
}
|
||||
calcSizeRatio();
|
||||
}
|
||||
|
||||
public void setOutputSize(Vec2i size) {
|
||||
|
@ -61,7 +64,6 @@ public abstract class Filter {
|
|||
throw new RuntimeException("this filter doesn't allow output resizing");
|
||||
}
|
||||
output.setSize(size);
|
||||
calcSizeRatio();
|
||||
}
|
||||
|
||||
private void calcSizeRatio() {
|
||||
|
|
|
@ -154,12 +154,22 @@ public class Window extends BaseWindow {
|
|||
pipeline2D.setDebug(on);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderSize(Vec2i size) {
|
||||
framebuffer.setSize(size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScaler(String scaler) {
|
||||
super.setScaler(scaler);
|
||||
mouse.setScaler(scalers.get(scaler));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowSize(Vec2i size) {
|
||||
glfwSetWindowSize(window, size.getX(), size.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClose() {
|
||||
return shouldClose;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.danitheskunk.skunkworks.nodes;
|
||||
|
||||
import com.danitheskunk.skunkworks.Vec2i;
|
||||
import com.danitheskunk.skunkworks.gfx.Color;
|
||||
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
||||
|
||||
|
@ -8,6 +9,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class NodeText extends Node {
|
||||
private Color color;
|
||||
private IFont font;
|
||||
private List<String> lines;
|
||||
private Vec2i maxSize;
|
||||
|
@ -18,6 +20,7 @@ public class NodeText extends Node {
|
|||
maxSize = Vec2i.ZERO;
|
||||
lines = new ArrayList<>();
|
||||
setText(text);
|
||||
color = Color.WHITE;
|
||||
}
|
||||
|
||||
private void layoutText() {
|
||||
|
@ -44,11 +47,15 @@ public class NodeText extends Node {
|
|||
public void render(IRenderContext rc) {
|
||||
Vec2i pos = getAbsolutePos().toVec2i();
|
||||
for(var line : lines) {
|
||||
rc.drawString(pos, line, font);
|
||||
rc.drawString(pos, line, font, color);
|
||||
pos = Vec2i.add(pos, new Vec2i(0, font.getLineHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setFont(IFont font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue