aaaaaa
# Conflicts: # app/src/main/java/sudoku/Main.java # app/src/main/java/sudoku/solver/Solver.java
This commit is contained in:
BIN
app/background.png
Normal file
BIN
app/background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
@@ -14,6 +14,9 @@ plugins {
|
|||||||
repositories {
|
repositories {
|
||||||
// Use Maven Central for resolving dependencies.
|
// Use Maven Central for resolving dependencies.
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
flatDir {
|
||||||
|
dirs("$rootProject.projectDir/libs")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -31,6 +34,10 @@ dependencies {
|
|||||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
|
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
|
||||||
|
|
||||||
implementation "io.github.spair:imgui-java-app:1.88.0"
|
implementation "io.github.spair:imgui-java-app:1.88.0"
|
||||||
|
|
||||||
|
implementation ":PNG-library"
|
||||||
|
|
||||||
|
runtimeOnly "org.lwjgl:lwjgl-stb::natives-windows"
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
|
|||||||
66
app/src/main/java/gui/Images.java
Normal file
66
app/src/main/java/gui/Images.java
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
import java.nio.LongBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import io.nayuki.png.ImageDecoder;
|
||||||
|
import io.nayuki.png.PngImage;
|
||||||
|
import io.nayuki.png.image.BufferedRgbaImage;
|
||||||
|
|
||||||
|
public class Images {
|
||||||
|
|
||||||
|
public static int BACKGROUND;
|
||||||
|
|
||||||
|
private static int loadTexture(String fileName) {
|
||||||
|
// Decoding
|
||||||
|
PngImage png = null;
|
||||||
|
try {
|
||||||
|
png = PngImage.read(new File(fileName));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
BufferedRgbaImage img = (BufferedRgbaImage) ImageDecoder.toImage(png);
|
||||||
|
ByteBuffer pixels = ByteBuffer.allocateDirect(img.getWidth() * img.getHeight() * Long.BYTES);
|
||||||
|
for (int y = 0; y < img.getHeight(); y++) {
|
||||||
|
for (int x = 0; x < img.getWidth(); x++) {
|
||||||
|
long value = img.getPixel(x, y);
|
||||||
|
int red = (int) ((value >> 48) & 0xFF);
|
||||||
|
int blue = (int) ((value >> 32) & 0xFF);
|
||||||
|
int green = (int) ((value >> 16) & 0xFF);
|
||||||
|
int alpha = 255;
|
||||||
|
pixels.putInt(red << 24 | green << 16 | blue << 8 | alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pixels.flip();
|
||||||
|
|
||||||
|
var caca = img.getBitDepths();
|
||||||
|
System.out.println(caca);
|
||||||
|
|
||||||
|
int textureID = GL11.glGenTextures();
|
||||||
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
|
||||||
|
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
||||||
|
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
|
||||||
|
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); // Not on WebGL/ES
|
||||||
|
GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0); // Not on WebGL/ES
|
||||||
|
GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0); // Not on WebGL/ES
|
||||||
|
GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0); // Not on WebGL/ES
|
||||||
|
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, img.getWidth(), img.getHeight(), 0,
|
||||||
|
GL11.GL_RGBA,
|
||||||
|
GL11.GL_UNSIGNED_BYTE, pixels);
|
||||||
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
return textureID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadImages() {
|
||||||
|
BACKGROUND = loadTexture("background.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -27,6 +27,12 @@ public class Main extends Application {
|
|||||||
stateMachine.pushState(new MainMenu(stateMachine));
|
stateMachine.pushState(new MainMenu(stateMachine));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preRun() {
|
||||||
|
super.preRun();
|
||||||
|
Images.loadImages();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() {
|
public void process() {
|
||||||
stateMachine.render();
|
stateMachine.render();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package gui.menu;
|
|||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
|
import gui.Images;
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
import imgui.ImVec2;
|
import imgui.ImVec2;
|
||||||
import imgui.flag.ImGuiKey;
|
import imgui.flag.ImGuiKey;
|
||||||
@@ -41,6 +42,12 @@ public class StateMachine {
|
|||||||
var displaySize = ImGui.getIO().getDisplaySize();
|
var displaySize = ImGui.getIO().getDisplaySize();
|
||||||
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
||||||
ImGui.setNextWindowSize(displaySize);
|
ImGui.setNextWindowSize(displaySize);
|
||||||
|
ImGui.begin("Background", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
|
||||||
|
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoInputs);
|
||||||
|
ImGui.image(Images.BACKGROUND, displaySize, new ImVec2(displaySize.x / 100, displaySize.y / 100));
|
||||||
|
ImGui.end();
|
||||||
|
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
||||||
|
ImGui.setNextWindowSize(displaySize);
|
||||||
ImGui.begin("##Main Window", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
|
ImGui.begin("##Main Window", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
|
||||||
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground);
|
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground);
|
||||||
menus.get(menus.size() - 1).render();
|
menus.get(menus.size() - 1).render();
|
||||||
|
|||||||
BIN
libs/PNG-library.jar
Normal file
BIN
libs/PNG-library.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user