diff --git a/Test.java b/Test.java index 177840b..905802f 100644 --- a/Test.java +++ b/Test.java @@ -1,11 +1,4 @@ import com.danitheskunk.skunkworks.*; -import com.danitheskunk.skunkworks.windows.*; -import com.sun.jna.Pointer; -import com.sun.jna.platform.win32.User32; -import com.sun.jna.platform.win32.WinDef; -import com.sun.jna.platform.win32.WinUser; - -import java.util.ArrayList; public class Test { public static void main(String[] args) { @@ -28,19 +21,19 @@ public class Test { var engine = new Engine(); var window = engine.openWindow(new Vec2i(1280, 720), "Skunkworks"); - //var img = engine.loadImage("C:\\Users\\dani\\Videos\\Screenshot 2022-06-25 17-00-59.png"); - //var tex2 = window.loadTexture("C:\\art\\pixel stuff.png"); - //var tileset = window.loadTextureArray("C:\\stream\\coding\\rlc\\tilemap.png", new Vec2i(16, 16)); - //var font = window.loadFontTileset("EGA8x14.png"); - //var font2 = window.loadFontTTF("fonts\\LiberationSans-Regular.ttf", 16*8.f); - //var tex = window.loadTexture(img); + var img = engine.loadImage("C:\\Users\\dani\\Videos\\Screenshot 2022-06-25 17-00-59.png"); + var tex2 = window.loadTexture("C:\\art\\pixel stuff.png"); + var tileset = window.loadTextureArray("C:\\stream\\coding\\rlc\\tilemap.png", new Vec2i(16, 16)); + var font = window.loadFontTileset("EGA8x14.png"); + var font2 = window.loadFontTTF("fonts\\LiberationSans-Regular.ttf", 16*8.f); + var tex = window.loadTexture(img); var slice = window.loadNineSlice("demoassets\\9slice-1.png"); //window.setDebug(true); while(!window.shouldClose()) { window.tick(); var renderContext = window.renderStart(); - /*renderContext.drawTextureRectangle( + renderContext.drawTextureRectangle( new Recti(0, 0, 1280, 720), tex ); @@ -57,7 +50,7 @@ public class Test { renderContext.drawString(new Vec2i(100, 100), "hello world mew", font); renderContext.drawString(new Vec2i(710, 140), "hello world mew", font2); - */ + renderContext.drawNineSlice(slice, new Recti(100, 100, 1080, 520)); window.renderFinish(renderContext); } diff --git a/com/danitheskunk/skunkworks/BaseWindow.java b/com/danitheskunk/skunkworks/BaseWindow.java index 315abfc..1f665ac 100644 --- a/com/danitheskunk/skunkworks/BaseWindow.java +++ b/com/danitheskunk/skunkworks/BaseWindow.java @@ -1,12 +1,15 @@ package com.danitheskunk.skunkworks; -import org.lwjgl.stb.STBTTFontinfo; -import static org.lwjgl.stb.STBTruetype.*; +import com.danitheskunk.skunkworks.gfx.Image; +import com.danitheskunk.skunkworks.gfx.NineSlice; +import com.danitheskunk.skunkworks.gfx.font.FontTTF; +import com.danitheskunk.skunkworks.gfx.font.FontTileset; +import com.danitheskunk.skunkworks.gfx.font.IFont; -abstract class BaseWindow implements IWindow { +abstract public class BaseWindow implements IWindow { protected final Engine engine; - BaseWindow(Engine engine) { + public BaseWindow(Engine engine) { this.engine = engine; } diff --git a/com/danitheskunk/skunkworks/Engine.java b/com/danitheskunk/skunkworks/Engine.java index c8a9c75..693aaeb 100644 --- a/com/danitheskunk/skunkworks/Engine.java +++ b/com/danitheskunk/skunkworks/Engine.java @@ -1,12 +1,15 @@ package com.danitheskunk.skunkworks; +import com.danitheskunk.skunkworks.backends.gl.Window; +import com.danitheskunk.skunkworks.gfx.GraphicsBackend; +import com.danitheskunk.skunkworks.gfx.Image; import org.lwjgl.BufferUtils; import java.io.FileInputStream; import java.io.IOException; import java.nio.ByteBuffer; -import static com.danitheskunk.skunkworks.GraphicsBackend.*; +import static com.danitheskunk.skunkworks.gfx.GraphicsBackend.*; public class Engine { private final GraphicsBackend graphicsBackend; @@ -40,7 +43,7 @@ public class Engine { public IWindow openWindow(Vec2i size, String title) { return switch(graphicsBackend) { - case OPENGL -> new GLWindow(size, title, this); + case OPENGL -> new Window(size, title, this); }; } } diff --git a/com/danitheskunk/skunkworks/ITexture.java b/com/danitheskunk/skunkworks/ITexture.java deleted file mode 100644 index d086e85..0000000 --- a/com/danitheskunk/skunkworks/ITexture.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.danitheskunk.skunkworks; - -public interface ITexture { - Vec2i getSize(); -} diff --git a/com/danitheskunk/skunkworks/IWindow.java b/com/danitheskunk/skunkworks/IWindow.java index 8b8fe25..0420890 100644 --- a/com/danitheskunk/skunkworks/IWindow.java +++ b/com/danitheskunk/skunkworks/IWindow.java @@ -1,5 +1,11 @@ package com.danitheskunk.skunkworks; +import com.danitheskunk.skunkworks.gfx.IRenderContext; +import com.danitheskunk.skunkworks.gfx.ITexture; +import com.danitheskunk.skunkworks.gfx.Image; +import com.danitheskunk.skunkworks.gfx.NineSlice; +import com.danitheskunk.skunkworks.gfx.font.IFont; + import java.util.List; public interface IWindow { diff --git a/com/danitheskunk/skunkworks/backends/gl/Program.java b/com/danitheskunk/skunkworks/backends/gl/Program.java new file mode 100644 index 0000000..ae89c8c --- /dev/null +++ b/com/danitheskunk/skunkworks/backends/gl/Program.java @@ -0,0 +1,38 @@ +package com.danitheskunk.skunkworks.backends.gl; + +import static org.lwjgl.opengl.GL46.*; + +public class Program { + Shader vertex; + Shader fragment; + int program; + public Program(String vertexSource, String fragmentSource) { + vertex = new Shader(vertexSource, GL_VERTEX_SHADER); + fragment = new Shader(fragmentSource, GL_FRAGMENT_SHADER); + program = glCreateProgram(); + glAttachShader(program, vertex.getShader()); + glAttachShader(program, fragment.getShader()); + + glLinkProgram(program); + } + + public void use() { + glUseProgram(program); + } + + public int getAttribLocation(String attrib) { + return glGetAttribLocation(program, attrib); + } + + public int getUniformLocation(String attrib) { + return glGetUniformLocation(program, attrib); + } + + public Shader getVertex() { + return vertex; + } + + public Shader getFragment() { + return fragment; + } +} diff --git a/com/danitheskunk/skunkworks/GLRenderContext.java b/com/danitheskunk/skunkworks/backends/gl/RenderContext.java similarity index 74% rename from com/danitheskunk/skunkworks/GLRenderContext.java rename to com/danitheskunk/skunkworks/backends/gl/RenderContext.java index ecd3d14..a8440fd 100644 --- a/com/danitheskunk/skunkworks/GLRenderContext.java +++ b/com/danitheskunk/skunkworks/backends/gl/RenderContext.java @@ -1,12 +1,17 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.backends.gl; -import static org.lwjgl.opengl.GL11.*; +import com.danitheskunk.skunkworks.*; +import com.danitheskunk.skunkworks.gfx.*; -class GLRenderContext extends BaseRenderContext implements IRenderContext{ - private final GLTextureAtlas atlas; +import static org.lwjgl.opengl.GL46.*; - public GLRenderContext(GLTextureAtlas atlas) { +class RenderContext extends BaseRenderContext implements IRenderContext { + private final TextureAtlas atlas; + private final int texCoordIndex; + + public RenderContext(TextureAtlas atlas, int texCoordIndex) { this.atlas = atlas; + this.texCoordIndex = texCoordIndex; } @Override @@ -62,7 +67,7 @@ class GLRenderContext extends BaseRenderContext implements IRenderContext{ @Override public void drawTextureRectangle(Recti rect, ITexture texture, Color color) { - var tex = (GLTexture)texture; + var tex = (Texture)texture; var tl = rect.getTopLeft(); var tr = rect.getTopRight(); @@ -82,18 +87,18 @@ class GLRenderContext extends BaseRenderContext implements IRenderContext{ ); //counterclockwise triangles - glTexCoord2d(tbl.getX(), tbl.getY()); + glVertexAttrib2d(texCoordIndex, tbl.getX(), tbl.getY()); glVertex2i(bl.getX(), bl.getY()); - glTexCoord2d(ttr.getX(), ttr.getY()); + glVertexAttrib2d(texCoordIndex, ttr.getX(), ttr.getY()); glVertex2i(tr.getX(), tr.getY()); - glTexCoord2d(ttl.getX(), ttl.getY()); + glVertexAttrib2d(texCoordIndex, ttl.getX(), ttl.getY()); glVertex2i(tl.getX(), tl.getY()); - glTexCoord2d(ttr.getX(), ttr.getY()); + glVertexAttrib2d(texCoordIndex, ttr.getX(), ttr.getY()); glVertex2i(tr.getX(), tr.getY()); - glTexCoord2d(tbl.getX(), tbl.getY()); + glVertexAttrib2d(texCoordIndex, tbl.getX(), tbl.getY()); glVertex2i(bl.getX(), bl.getY()); - glTexCoord2d(tbr.getX(), tbr.getY()); + glVertexAttrib2d(texCoordIndex, tbr.getX(), tbr.getY()); glVertex2i(br.getX(), bl.getY()); } } diff --git a/com/danitheskunk/skunkworks/backends/gl/Shader.java b/com/danitheskunk/skunkworks/backends/gl/Shader.java new file mode 100644 index 0000000..77d44d5 --- /dev/null +++ b/com/danitheskunk/skunkworks/backends/gl/Shader.java @@ -0,0 +1,28 @@ +package com.danitheskunk.skunkworks.backends.gl; + +import static org.lwjgl.opengl.GL46.*; + +public class Shader { + private int shader; + private int type; + + public Shader(String source, int type) { + this.type = type; + + shader = glCreateShader(type); + glShaderSource(shader, source); + glCompileShader(shader); + + int[] ret = {0}; + glGetShaderiv(shader, GL_COMPILE_STATUS, ret); + if(ret[0] == GL_FALSE) { + var errmsg = glGetShaderInfoLog(shader); + glDeleteShader(shader); + throw new RuntimeException("Shader error:\n" + errmsg); + } + } + + public int getShader() { + return shader; + } +} diff --git a/com/danitheskunk/skunkworks/GLTexture.java b/com/danitheskunk/skunkworks/backends/gl/Texture.java similarity index 54% rename from com/danitheskunk/skunkworks/GLTexture.java rename to com/danitheskunk/skunkworks/backends/gl/Texture.java index 602c17e..0df7935 100644 --- a/com/danitheskunk/skunkworks/GLTexture.java +++ b/com/danitheskunk/skunkworks/backends/gl/Texture.java @@ -1,12 +1,17 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.backends.gl; -class GLTexture implements ITexture { +import com.danitheskunk.skunkworks.gfx.ITexture; +import com.danitheskunk.skunkworks.gfx.Image; +import com.danitheskunk.skunkworks.Recti; +import com.danitheskunk.skunkworks.Vec2i; + +class Texture implements ITexture { private Recti texArea; private final Image img; //for re-blitting onto texture atlas - GLTexture(Recti texArea, Image img) { + Texture(Recti texArea, Image img) { this.texArea = texArea; this.img = img; } diff --git a/com/danitheskunk/skunkworks/GLTextureAtlas.java b/com/danitheskunk/skunkworks/backends/gl/TextureAtlas.java similarity index 81% rename from com/danitheskunk/skunkworks/GLTextureAtlas.java rename to com/danitheskunk/skunkworks/backends/gl/TextureAtlas.java index 3b91edf..1314b41 100644 --- a/com/danitheskunk/skunkworks/GLTextureAtlas.java +++ b/com/danitheskunk/skunkworks/backends/gl/TextureAtlas.java @@ -1,5 +1,9 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.backends.gl; +import com.danitheskunk.skunkworks.gfx.ITexture; +import com.danitheskunk.skunkworks.gfx.Image; +import com.danitheskunk.skunkworks.Recti; +import com.danitheskunk.skunkworks.Vec2i; import org.lwjgl.BufferUtils; import java.util.ArrayList; @@ -8,13 +12,13 @@ import java.util.List; import static org.lwjgl.opengl.GL11.*; -class GLTextureAtlas { - private GLTexture atlasTexture; //for debugging +class TextureAtlas { + private Texture atlasTexture; //for debugging private Image img; private boolean shouldUpdate; - private final List textures; + private final List textures; - GLTextureAtlas() { + TextureAtlas() { img = new Image(new Vec2i(32, 32)); int textureID = glGenTextures(); textures = new ArrayList<>(); @@ -31,7 +35,7 @@ class GLTextureAtlas { ITexture addTexture(Image img) { //todo: do the actual texture stuff //this.img = img; - var texture = new GLTexture(new Recti(new Vec2i(0, 0), img.getSize()), img); + var texture = new Texture(new Recti(new Vec2i(0, 0), img.getSize()), img); textures.add(texture); shouldUpdate = true; return texture; @@ -40,7 +44,7 @@ class GLTextureAtlas { void doubleAtlasSize() { img = new Image(Vec2i.mul(img.getSize(), 2)); System.out.printf("Resized atlas to %dx%d\n", img.getSize().getX(), img.getSize().getY()); - atlasTexture = new GLTexture(new Recti(Vec2i.ZERO, img.getSize()), img); + atlasTexture = new Texture(new Recti(Vec2i.ZERO, img.getSize()), img); } public void update() { @@ -114,7 +118,7 @@ class GLTextureAtlas { ); } - public GLTexture getAtlasTexture() { + public Texture getAtlasTexture() { return atlasTexture; } @@ -122,9 +126,9 @@ class GLTextureAtlas { return img.getSize(); } - private static class TextureHeightComparator implements Comparator { + private static class TextureHeightComparator implements Comparator { @Override - public int compare(GLTexture o1, GLTexture o2) { + public int compare(Texture o1, Texture o2) { return o1.getImg().getHeight() - o2.getImg().getHeight(); } } diff --git a/com/danitheskunk/skunkworks/GLWindow.java b/com/danitheskunk/skunkworks/backends/gl/Window.java similarity index 66% rename from com/danitheskunk/skunkworks/GLWindow.java rename to com/danitheskunk/skunkworks/backends/gl/Window.java index 762e62f..8701850 100644 --- a/com/danitheskunk/skunkworks/GLWindow.java +++ b/com/danitheskunk/skunkworks/backends/gl/Window.java @@ -1,5 +1,9 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.backends.gl; +import com.danitheskunk.skunkworks.*; +import com.danitheskunk.skunkworks.gfx.IRenderContext; +import com.danitheskunk.skunkworks.gfx.ITexture; +import com.danitheskunk.skunkworks.gfx.Image; import org.lwjgl.glfw.GLFWErrorCallback; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL11; @@ -8,18 +12,19 @@ import java.util.ArrayList; import java.util.List; import static org.lwjgl.glfw.GLFW.*; -import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL46.*; import static org.lwjgl.system.MemoryUtil.NULL; -class GLWindow extends BaseWindow { +public class Window extends BaseWindow { private boolean debug; - private final GLRenderContext renderContext; + private final Program program; + private final RenderContext renderContext; private boolean shouldClose; private final Vec2i size; - private final GLTextureAtlas textureAtlas; + private final TextureAtlas textureAtlas; private final long window; - public GLWindow(Vec2i size, String title, Engine engine) { + public Window(Vec2i size, String title, Engine engine) { super(engine); GLFWErrorCallback.createPrint(System.err).set(); if(!glfwInit()) throw new IllegalStateException("Unable to initialize GLFW"); @@ -44,8 +49,11 @@ class GLWindow extends BaseWindow { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - textureAtlas = new GLTextureAtlas(); - renderContext = new GLRenderContext(textureAtlas); + textureAtlas = new TextureAtlas(); + program = new Program(vertexSource, fragmentSource); + program.use(); + renderContext = new RenderContext(textureAtlas, program.getAttribLocation("texCoord")); + glProgramUniform2f(program.program, program.getUniformLocation("windowSize"), size.getX(), size.getY()); shouldClose = false; @@ -102,6 +110,7 @@ class GLWindow extends BaseWindow { glClearColor(0.1f, 0.2f, 0.3f, 1.0f); glClearColor(0.5f, 0.5f, 0.5f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + program.use(); glBegin(GL_TRIANGLES); return renderContext; } @@ -126,4 +135,27 @@ class GLWindow extends BaseWindow { glfwPollEvents(); } + + private static String vertexSource = """ + #version 450 + layout(location = 0) in vec2 pos; + layout(location = 1) in vec2 texCoord; + layout(location = 2) uniform vec2 windowSize; + layout(location = 1) out vec2 out_texCoord; + void main() { + gl_Position = vec4(pos / windowSize * vec2(2.0f, -2.0f) + vec2(-1.0f, 1.0f), 0.0f, 1.0f); + out_texCoord = texCoord; + } + """; + + private static String fragmentSource = """ + #version 450 + layout(location = 1) in vec2 texCoord; + layout(binding = 0) uniform sampler2D tex; + out vec4 color; + void main() { + //color = vec4(texCoord.x, texCoord.y, 0.7f, 1.0f); + color = texture(tex, texCoord); + } + """; } diff --git a/com/danitheskunk/skunkworks/BaseRenderContext.java b/com/danitheskunk/skunkworks/gfx/BaseRenderContext.java similarity index 72% rename from com/danitheskunk/skunkworks/BaseRenderContext.java rename to com/danitheskunk/skunkworks/gfx/BaseRenderContext.java index 4645961..6a31c73 100644 --- a/com/danitheskunk/skunkworks/BaseRenderContext.java +++ b/com/danitheskunk/skunkworks/gfx/BaseRenderContext.java @@ -1,10 +1,14 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx; + +import com.danitheskunk.skunkworks.gfx.font.IFont; +import com.danitheskunk.skunkworks.Recti; +import com.danitheskunk.skunkworks.Vec2i; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.IntBuffer; -abstract class BaseRenderContext implements IRenderContext { +abstract public class BaseRenderContext implements IRenderContext { public void drawString(Vec2i pos, String string, IFont font) { int x = pos.getX(); int y = pos.getY(); diff --git a/com/danitheskunk/skunkworks/Color.java b/com/danitheskunk/skunkworks/gfx/Color.java similarity index 93% rename from com/danitheskunk/skunkworks/Color.java rename to com/danitheskunk/skunkworks/gfx/Color.java index 7b33b46..d262d1c 100644 --- a/com/danitheskunk/skunkworks/Color.java +++ b/com/danitheskunk/skunkworks/gfx/Color.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx; public final class Color { private final int r, g, b, a; diff --git a/com/danitheskunk/skunkworks/GraphicsBackend.java b/com/danitheskunk/skunkworks/gfx/GraphicsBackend.java similarity index 50% rename from com/danitheskunk/skunkworks/GraphicsBackend.java rename to com/danitheskunk/skunkworks/gfx/GraphicsBackend.java index d55d4be..1c1f835 100644 --- a/com/danitheskunk/skunkworks/GraphicsBackend.java +++ b/com/danitheskunk/skunkworks/gfx/GraphicsBackend.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx; public enum GraphicsBackend { OPENGL diff --git a/com/danitheskunk/skunkworks/IRenderContext.java b/com/danitheskunk/skunkworks/gfx/IRenderContext.java similarity index 78% rename from com/danitheskunk/skunkworks/IRenderContext.java rename to com/danitheskunk/skunkworks/gfx/IRenderContext.java index ce255ad..91acc12 100644 --- a/com/danitheskunk/skunkworks/IRenderContext.java +++ b/com/danitheskunk/skunkworks/gfx/IRenderContext.java @@ -1,4 +1,7 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx; + +import com.danitheskunk.skunkworks.*; +import com.danitheskunk.skunkworks.gfx.font.IFont; public interface IRenderContext { void drawNineSlice(NineSlice slice, Recti rect); //todo: add rounding mode diff --git a/com/danitheskunk/skunkworks/gfx/ITexture.java b/com/danitheskunk/skunkworks/gfx/ITexture.java new file mode 100644 index 0000000..48d081d --- /dev/null +++ b/com/danitheskunk/skunkworks/gfx/ITexture.java @@ -0,0 +1,7 @@ +package com.danitheskunk.skunkworks.gfx; + +import com.danitheskunk.skunkworks.Vec2i; + +public interface ITexture { + Vec2i getSize(); +} diff --git a/com/danitheskunk/skunkworks/Image.java b/com/danitheskunk/skunkworks/gfx/Image.java similarity index 88% rename from com/danitheskunk/skunkworks/Image.java rename to com/danitheskunk/skunkworks/gfx/Image.java index 5afd7b9..6cd65b8 100644 --- a/com/danitheskunk/skunkworks/Image.java +++ b/com/danitheskunk/skunkworks/gfx/Image.java @@ -1,5 +1,7 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx; +import com.danitheskunk.skunkworks.Recti; +import com.danitheskunk.skunkworks.Vec2i; import org.lwjgl.stb.STBImage; import java.nio.ByteBuffer; @@ -9,7 +11,7 @@ public class Image { private final Vec2i size; //constructors - Image(ByteBuffer buffer) { //png or similar + public Image(ByteBuffer buffer) { //png or similar //todo: resource system int[] x = {0}, y = {0}, n = {0}; var img = STBImage.stbi_load_from_memory(buffer, x, y, n, 4); @@ -19,12 +21,12 @@ public class Image { img.get(data); } - Image(Vec2i size) { + public Image(Vec2i size) { this.size = size; data = new byte[size.getX() * size.getY() * 4]; } - Image(ByteBuffer buffer, Vec2i size) { + public Image(ByteBuffer buffer, Vec2i size) { data = new byte[buffer.remaining()]; buffer.get(data); this.size = size; diff --git a/com/danitheskunk/skunkworks/NineSlice.java b/com/danitheskunk/skunkworks/gfx/NineSlice.java similarity index 55% rename from com/danitheskunk/skunkworks/NineSlice.java rename to com/danitheskunk/skunkworks/gfx/NineSlice.java index 17791e0..803066a 100644 --- a/com/danitheskunk/skunkworks/NineSlice.java +++ b/com/danitheskunk/skunkworks/gfx/NineSlice.java @@ -1,4 +1,6 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx; + +import com.danitheskunk.skunkworks.gfx.ITexture; public class NineSlice { private ITexture topLeft; @@ -10,7 +12,7 @@ public class NineSlice { private ITexture bottom; private ITexture left; private ITexture center; - NineSlice(ITexture topLeft, ITexture topRight, ITexture bottomLeft, ITexture bottomRight, ITexture top, ITexture right, ITexture bottom, ITexture left, ITexture center) { + public NineSlice(ITexture topLeft, ITexture topRight, ITexture bottomLeft, ITexture bottomRight, ITexture top, ITexture right, ITexture bottom, ITexture left, ITexture center) { this.topLeft = topLeft; this.topRight = topRight; this.bottomLeft = bottomLeft; @@ -22,39 +24,39 @@ public class NineSlice { this.center = center; } - ITexture getTopLeft() { + public ITexture getTopLeft() { return topLeft; } - ITexture getTopRight() { + public ITexture getTopRight() { return topRight; } - ITexture getBottomLeft() { + public ITexture getBottomLeft() { return bottomLeft; } - ITexture getBottomRight() { + public ITexture getBottomRight() { return bottomRight; } - ITexture getTop() { + public ITexture getTop() { return top; } - ITexture getRight() { + public ITexture getRight() { return right; } - ITexture getBottom() { + public ITexture getBottom() { return bottom; } - ITexture getLeft() { + public ITexture getLeft() { return left; } - ITexture getCenter() { + public ITexture getCenter() { return center; } } diff --git a/com/danitheskunk/skunkworks/FontTTF.java b/com/danitheskunk/skunkworks/gfx/font/FontTTF.java similarity index 89% rename from com/danitheskunk/skunkworks/FontTTF.java rename to com/danitheskunk/skunkworks/gfx/font/FontTTF.java index 1d3c3d7..42e7a84 100644 --- a/com/danitheskunk/skunkworks/FontTTF.java +++ b/com/danitheskunk/skunkworks/gfx/font/FontTTF.java @@ -1,10 +1,11 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx.font; -import org.lwjgl.BufferUtils; +import com.danitheskunk.skunkworks.IWindow; +import com.danitheskunk.skunkworks.Vec2i; +import com.danitheskunk.skunkworks.gfx.ITexture; +import com.danitheskunk.skunkworks.gfx.Image; import org.lwjgl.stb.STBTTFontinfo; -import java.io.FileInputStream; -import java.io.IOException; import java.nio.ByteBuffer; import java.util.HashMap; @@ -19,7 +20,7 @@ public class FontTTF implements IFont { STBTTFontinfo info; IWindow window; - FontTTF(ByteBuffer buffer, float size, IWindow window) { + public FontTTF(ByteBuffer buffer, float size, IWindow window) { int[] ascent = {0}; int[] descent = {0}; int[] lineGap = {0}; diff --git a/com/danitheskunk/skunkworks/FontTileset.java b/com/danitheskunk/skunkworks/gfx/font/FontTileset.java similarity index 68% rename from com/danitheskunk/skunkworks/FontTileset.java rename to com/danitheskunk/skunkworks/gfx/font/FontTileset.java index d1b06df..2fc567b 100644 --- a/com/danitheskunk/skunkworks/FontTileset.java +++ b/com/danitheskunk/skunkworks/gfx/font/FontTileset.java @@ -1,12 +1,15 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx.font; + +import com.danitheskunk.skunkworks.Vec2i; +import com.danitheskunk.skunkworks.gfx.ITexture; import java.util.List; -class FontTileset implements IFont { +public class FontTileset implements IFont { private List textures; private Vec2i charSize; - FontTileset(List textures) { + public FontTileset(List textures) { this.textures = textures; this.charSize = textures.get(0).getSize(); } diff --git a/com/danitheskunk/skunkworks/IFont.java b/com/danitheskunk/skunkworks/gfx/font/IFont.java similarity index 50% rename from com/danitheskunk/skunkworks/IFont.java rename to com/danitheskunk/skunkworks/gfx/font/IFont.java index b440b04..7f9f03e 100644 --- a/com/danitheskunk/skunkworks/IFont.java +++ b/com/danitheskunk/skunkworks/gfx/font/IFont.java @@ -1,4 +1,7 @@ -package com.danitheskunk.skunkworks; +package com.danitheskunk.skunkworks.gfx.font; + +import com.danitheskunk.skunkworks.Vec2i; +import com.danitheskunk.skunkworks.gfx.ITexture; public interface IFont { int getLineHeight(int ch); diff --git a/com/danitheskunk/skunkworks/windows/Dwm.java b/com/danitheskunk/skunkworks/os/windows/Dwm.java similarity index 97% rename from com/danitheskunk/skunkworks/windows/Dwm.java rename to com/danitheskunk/skunkworks/os/windows/Dwm.java index fbf5c3b..066168a 100644 --- a/com/danitheskunk/skunkworks/windows/Dwm.java +++ b/com/danitheskunk/skunkworks/os/windows/Dwm.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks.windows; +package com.danitheskunk.skunkworks.os.windows; import com.sun.jna.Library; import com.sun.jna.Native; diff --git a/com/danitheskunk/skunkworks/windows/MARGINS.java b/com/danitheskunk/skunkworks/os/windows/MARGINS.java similarity index 89% rename from com/danitheskunk/skunkworks/windows/MARGINS.java rename to com/danitheskunk/skunkworks/os/windows/MARGINS.java index 0fadca3..b648594 100644 --- a/com/danitheskunk/skunkworks/windows/MARGINS.java +++ b/com/danitheskunk/skunkworks/os/windows/MARGINS.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks.windows; +package com.danitheskunk.skunkworks.os.windows; import com.sun.jna.Structure; diff --git a/com/danitheskunk/skunkworks/windows/TITLEBARINFO.java b/com/danitheskunk/skunkworks/os/windows/TITLEBARINFO.java similarity index 93% rename from com/danitheskunk/skunkworks/windows/TITLEBARINFO.java rename to com/danitheskunk/skunkworks/os/windows/TITLEBARINFO.java index 4c443a2..d0f0650 100644 --- a/com/danitheskunk/skunkworks/windows/TITLEBARINFO.java +++ b/com/danitheskunk/skunkworks/os/windows/TITLEBARINFO.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks.windows; +package com.danitheskunk.skunkworks.os.windows; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinDef; diff --git a/com/danitheskunk/skunkworks/windows/User32Extra.java b/com/danitheskunk/skunkworks/os/windows/User32Extra.java similarity index 98% rename from com/danitheskunk/skunkworks/windows/User32Extra.java rename to com/danitheskunk/skunkworks/os/windows/User32Extra.java index a717ba1..ce8a8c0 100644 --- a/com/danitheskunk/skunkworks/windows/User32Extra.java +++ b/com/danitheskunk/skunkworks/os/windows/User32Extra.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks.windows; +package com.danitheskunk.skunkworks.os.windows; import com.sun.jna.Native; import com.sun.jna.platform.win32.User32; diff --git a/com/danitheskunk/skunkworks/windows/WinUserExtra.java b/com/danitheskunk/skunkworks/os/windows/WinUserExtra.java similarity index 89% rename from com/danitheskunk/skunkworks/windows/WinUserExtra.java rename to com/danitheskunk/skunkworks/os/windows/WinUserExtra.java index 8dba2a0..edf6372 100644 --- a/com/danitheskunk/skunkworks/windows/WinUserExtra.java +++ b/com/danitheskunk/skunkworks/os/windows/WinUserExtra.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks.windows; +package com.danitheskunk.skunkworks.os.windows; import com.sun.jna.Native; import com.sun.jna.platform.win32.WinUser; diff --git a/com/danitheskunk/skunkworks/windows/Window.java b/com/danitheskunk/skunkworks/os/windows/Window.java similarity index 99% rename from com/danitheskunk/skunkworks/windows/Window.java rename to com/danitheskunk/skunkworks/os/windows/Window.java index abc955c..5302a42 100644 --- a/com/danitheskunk/skunkworks/windows/Window.java +++ b/com/danitheskunk/skunkworks/os/windows/Window.java @@ -1,4 +1,4 @@ -package com.danitheskunk.skunkworks.windows; +package com.danitheskunk.skunkworks.os.windows; import com.danitheskunk.skunkworks.Recti;