decoupled internal render resolution from window size more
This commit is contained in:
parent
ca38735484
commit
4a25dc4694
|
@ -40,8 +40,12 @@ public interface IWindow {
|
||||||
|
|
||||||
void setDebug(boolean on);
|
void setDebug(boolean on);
|
||||||
|
|
||||||
|
void setRenderSize(Vec2i size);
|
||||||
|
|
||||||
void setScaler(String scaler);
|
void setScaler(String scaler);
|
||||||
|
|
||||||
|
void setWindowSize(Vec2i size);
|
||||||
|
|
||||||
boolean shouldClose();
|
boolean shouldClose();
|
||||||
|
|
||||||
void startFrame();
|
void startFrame();
|
||||||
|
|
|
@ -17,7 +17,8 @@ public class Test3D extends BaseGame {
|
||||||
Model model;
|
Model model;
|
||||||
|
|
||||||
public Test3D() {
|
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",
|
System.out.printf("assimp version: %d.%d.%d\n",
|
||||||
Assimp.aiGetVersionMajor(),
|
Assimp.aiGetVersionMajor(),
|
||||||
Assimp.aiGetVersionMinor(),
|
Assimp.aiGetVersionMinor(),
|
||||||
|
@ -25,8 +26,8 @@ public class Test3D extends BaseGame {
|
||||||
);
|
);
|
||||||
trans = 255;
|
trans = 255;
|
||||||
var path = "C:\\stream\\models\\Dani.vrm";
|
var path = "C:\\stream\\models\\Dani.vrm";
|
||||||
//path = "C:\\stream\\models\\Amber_Arakada_V5_Blendshape.glb";
|
path = "C:\\stream\\models\\Amber_Arakada_V5_Blendshape.glb";
|
||||||
//path = "C:\\stream\\models\\Temp Chan 3.glb";
|
path = "C:\\stream\\models\\Temp Chan 3.glb";
|
||||||
var bytes = engine.loadBytes(path);
|
var bytes = engine.loadBytes(path);
|
||||||
model = new Model(bytes, window);
|
model = new Model(bytes, window);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.danitheskunk.skunkworks;
|
package com.danitheskunk.skunkworks;
|
||||||
|
|
||||||
import com.danitheskunk.skunkworks.audio.ISample;
|
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.NodeSprite;
|
||||||
import com.danitheskunk.skunkworks.nodes.NodeText;
|
import com.danitheskunk.skunkworks.nodes.NodeText;
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
|
|
||||||
public class TestNode extends BaseGame {
|
public class TestNode extends BaseGame {
|
||||||
private final ISample kick;
|
private final ISample kick;
|
||||||
|
@ -14,15 +14,23 @@ public class TestNode extends BaseGame {
|
||||||
float[] axes;
|
float[] axes;
|
||||||
|
|
||||||
public TestNode() {
|
public TestNode() {
|
||||||
super(new Vec2i(1280, 720), "Skunkworks");
|
super(new Vec2i(1920, 1080), "Skunkworks");
|
||||||
|
|
||||||
kick = loadSample("demoassets/kick.wav");
|
kick = loadSample("demoassets/kick.wav");
|
||||||
var font = window.loadFontTileset("fonts/ega-8x14.png");
|
var font = window.loadFontTileset("fonts/ega-8x14.png");
|
||||||
var font2 = window.loadFontTTF("fonts/LiberationSans-Regular.ttf", 24.0f);
|
var font2 = window.loadFontTTF("fonts/m3x6.ttf", 12.7f);
|
||||||
text = new NodeText(font, "Hello World! this is an extra long test meow meow nya nya! nyaaa!");
|
var str =
|
||||||
text2 = new NodeText(font2, "Hello World! this is an extra long test meow meow nya nya! nyaaa!");
|
"As Gauntlet of Power enters the battlefield, choose a color.\n" +
|
||||||
text.setMaxSize(new Vec2i(100, 100));
|
"\n" +
|
||||||
text2.setMaxSize(new Vec2i(100, 100));
|
"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 = new NodeSprite();
|
||||||
sprite.setTexture(loadTexture("demoassets/card.png"));
|
sprite.setTexture(loadTexture("demoassets/card.png"));
|
||||||
sprite.setPos(new Vec2f(100, 100));
|
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() {
|
void doThing() {
|
||||||
sprite.tweenPos(new Vec2f(800, 400), 120).delay(60).then(() -> {
|
sprite.tweenPos(new Vec2f(800, 400), 120).delay(60).then(() -> {
|
||||||
System.out.println("yay! got there! now lets go home");
|
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
|
@Override
|
||||||
protected void update(double delta) {
|
protected void update(double delta) {
|
||||||
text.setPos(new Vec2f(640 + 640 * gamepad.getAxis(0), 360 + 360 * gamepad.getAxis(1)));
|
text.setPos(new Vec2f(
|
||||||
text2.setPos(new Vec2f(440 + 640 * gamepad.getAxis(0), 360 + 360 * gamepad.getAxis(1)));
|
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)) {
|
if(gamepad.getButtonPressed(0)) {
|
||||||
playSample(kick);
|
playSample(kick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new TestNode().run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,12 +154,22 @@ public class Window extends BaseWindow {
|
||||||
pipeline2D.setDebug(on);
|
pipeline2D.setDebug(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRenderSize(Vec2i size) {
|
||||||
|
framebuffer.setSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setScaler(String scaler) {
|
public void setScaler(String scaler) {
|
||||||
super.setScaler(scaler);
|
super.setScaler(scaler);
|
||||||
mouse.setScaler(scalers.get(scaler));
|
mouse.setScaler(scalers.get(scaler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWindowSize(Vec2i size) {
|
||||||
|
glfwSetWindowSize(window, size.getX(), size.getY());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldClose() {
|
public boolean shouldClose() {
|
||||||
return shouldClose;
|
return shouldClose;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.danitheskunk.skunkworks.nodes;
|
package com.danitheskunk.skunkworks.nodes;
|
||||||
|
|
||||||
import com.danitheskunk.skunkworks.Vec2i;
|
import com.danitheskunk.skunkworks.Vec2i;
|
||||||
|
import com.danitheskunk.skunkworks.gfx.Color;
|
||||||
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||||
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
||||||
|
|
||||||
|
@ -8,6 +9,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NodeText extends Node {
|
public class NodeText extends Node {
|
||||||
|
private Color color;
|
||||||
private IFont font;
|
private IFont font;
|
||||||
private List<String> lines;
|
private List<String> lines;
|
||||||
private Vec2i maxSize;
|
private Vec2i maxSize;
|
||||||
|
@ -18,6 +20,7 @@ public class NodeText extends Node {
|
||||||
maxSize = Vec2i.ZERO;
|
maxSize = Vec2i.ZERO;
|
||||||
lines = new ArrayList<>();
|
lines = new ArrayList<>();
|
||||||
setText(text);
|
setText(text);
|
||||||
|
color = Color.WHITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void layoutText() {
|
private void layoutText() {
|
||||||
|
@ -44,11 +47,15 @@ public class NodeText extends Node {
|
||||||
public void render(IRenderContext rc) {
|
public void render(IRenderContext rc) {
|
||||||
Vec2i pos = getAbsolutePos().toVec2i();
|
Vec2i pos = getAbsolutePos().toVec2i();
|
||||||
for(var line : lines) {
|
for(var line : lines) {
|
||||||
rc.drawString(pos, line, font);
|
rc.drawString(pos, line, font, color);
|
||||||
pos = Vec2i.add(pos, new Vec2i(0, font.getLineHeight()));
|
pos = Vec2i.add(pos, new Vec2i(0, font.getLineHeight()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFont(IFont font) {
|
public void setFont(IFont font) {
|
||||||
this.font = font;
|
this.font = font;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue