fixed some warnings
This commit is contained in:
parent
a62577234e
commit
77197b6004
|
@ -2,8 +2,41 @@
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,org.lwjgl.assimp.Assimp,aiImportFile" />
|
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,org.lwjgl.assimp.Assimp,aiImportFile,org.lwjgl.glfw.GLFW,glfwSetWindowSizeCallback|glfwSetMouseButtonCallback" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="ClassCanBeRecord" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
<inspection_tool class="ClassCanBeRecord" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="EmptyMethod" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||||
|
<option name="processCode" value="true" />
|
||||||
|
<option name="processLiterals" value="true" />
|
||||||
|
<option name="processComments" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="UnnecessarilyQualifiedStaticUsage" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="m_ignoreStaticFieldAccesses" value="false" />
|
||||||
|
<option name="m_ignoreStaticMethodCalls" value="false" />
|
||||||
|
<option name="m_ignoreStaticAccessFromStaticContext" value="false" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="UnnecessaryQualifierForThis" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="UnnecessarySuperConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="UnnecessarySuperQualifier" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="UnnecessaryThis" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="UnqualifiedInnerClassAccess" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoreReferencesToLocalInnerClasses" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="UnusedReturnValue" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="highestModifier" value="protected" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="unused" enabled="true" level="WARNING" enabled_by_default="true" klass="packageLocal" field="packageLocal" parameter="packageLocal" checkParameterExcludingHierarchy="true">
|
||||||
|
<option name="LOCAL_VARIABLE" value="true" />
|
||||||
|
<option name="FIELD" value="true" />
|
||||||
|
<option name="METHOD" value="false" />
|
||||||
|
<option name="CLASS" value="true" />
|
||||||
|
<option name="PARAMETER" value="true" />
|
||||||
|
<option name="REPORT_PARAMETER_FOR_PUBLIC_METHODS" value="false" />
|
||||||
|
<option name="ADD_MAINS_TO_ENTRIES" value="true" />
|
||||||
|
<option name="ADD_APPLET_TO_ENTRIES" value="true" />
|
||||||
|
<option name="ADD_SERVLET_TO_ENTRIES" value="true" />
|
||||||
|
<option name="ADD_NONJAVA_TO_ENTRIES" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
|
@ -12,27 +12,28 @@ import com.danitheskunk.skunkworks.gfx.font.IFont;
|
||||||
import com.danitheskunk.skunkworks.nodes.NodeRoot;
|
import com.danitheskunk.skunkworks.nodes.NodeRoot;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
public abstract class BaseGame {
|
public abstract class BaseGame {
|
||||||
protected AudioEngine audioEngine;
|
protected final AudioEngine audioEngine;
|
||||||
protected IFont debugFont;
|
protected final IFont debugFont;
|
||||||
protected Engine engine;
|
protected final Engine engine;
|
||||||
protected Mixer mixer;
|
protected final Mixer mixer;
|
||||||
protected NodeRoot rootNode;
|
protected final NodeRoot rootNode;
|
||||||
protected SamplePlayer samplePlayer;
|
protected final SamplePlayer samplePlayer;
|
||||||
protected IWindow window;
|
protected final IWindow window;
|
||||||
|
|
||||||
public BaseGame(Vec2i windowSize, String windowTitle) {
|
public BaseGame(Vec2i windowSize, String windowTitle) {
|
||||||
this.audioEngine = new AudioEngine(44100, 256, 8);
|
audioEngine = new AudioEngine(44100, 256, 8);
|
||||||
this.mixer = new Mixer(this.audioEngine, 2);
|
mixer = new Mixer(audioEngine, 2);
|
||||||
this.samplePlayer = new SamplePlayer(this.audioEngine);
|
samplePlayer = new SamplePlayer(audioEngine);
|
||||||
Node.connect(samplePlayer, 0, mixer, 0);
|
Node.connect(samplePlayer, 0, mixer, 0);
|
||||||
this.audioEngine.setNode(this.mixer);
|
audioEngine.setNode(mixer);
|
||||||
|
|
||||||
this.engine = new Engine();
|
engine = new Engine();
|
||||||
this.window = engine.openWindow(windowSize, windowTitle);
|
window = engine.openWindow(windowSize, windowTitle);
|
||||||
//todo: load from .jar
|
//todo: load from .jar
|
||||||
this.debugFont = window.loadFontTileset("fonts/ega-8x14.png");
|
debugFont = window.loadFontTileset("fonts/ega-8x14.png");
|
||||||
this.rootNode = new NodeRoot();
|
rootNode = new NodeRoot();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,10 +64,11 @@ public abstract class BaseGame {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void render3D(IRenderContext3D rc3d) {
|
protected void render3D(IRenderContext3D rc3d) {
|
||||||
|
//to be overriden by child class
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderPre(IRenderContext rc) {
|
protected void renderPre(IRenderContext rc) {
|
||||||
|
//to be overriden by child class
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -12,7 +12,7 @@ abstract public class BaseWindow implements IWindow {
|
||||||
|
|
||||||
public BaseWindow(Engine engine) {
|
public BaseWindow(Engine engine) {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.stretchMode = WindowStretchMode.ASPECT;
|
stretchMode = WindowStretchMode.ASPECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,7 +100,7 @@ abstract public class BaseWindow implements IWindow {
|
||||||
image.getWidth() - x2,
|
image.getWidth() - x2,
|
||||||
image.getHeight() - y2
|
image.getHeight() - y2
|
||||||
));
|
));
|
||||||
var slice = new NineSlice(loadTexture(tl),
|
return new NineSlice(loadTexture(tl),
|
||||||
loadTexture(tr),
|
loadTexture(tr),
|
||||||
loadTexture(bl),
|
loadTexture(bl),
|
||||||
loadTexture(br),
|
loadTexture(br),
|
||||||
|
@ -110,7 +110,6 @@ abstract public class BaseWindow implements IWindow {
|
||||||
loadTexture(left),
|
loadTexture(left),
|
||||||
loadTexture(center)
|
loadTexture(center)
|
||||||
);
|
);
|
||||||
return slice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,7 +119,7 @@ abstract public class BaseWindow implements IWindow {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStretchMode(WindowStretchMode mode) {
|
public void setStretchMode(WindowStretchMode mode) {
|
||||||
this.stretchMode = mode;
|
stretchMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class Data {
|
||||||
|
|
||||||
public Data(ByteBuffer data) {
|
public Data(ByteBuffer data) {
|
||||||
this.data = new LinkedHashMap<>();
|
this.data = new LinkedHashMap<>();
|
||||||
this.currentCategory = "";
|
currentCategory = "";
|
||||||
this.data.put("", new LinkedHashMap<>());
|
this.data.put("", new LinkedHashMap<>());
|
||||||
StandardCharsets.UTF_8.decode(data).toString().lines().forEach(this::processLine);
|
StandardCharsets.UTF_8.decode(data).toString().lines().forEach(this::processLine);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,8 @@ public class Engine {
|
||||||
WatchKey key;
|
WatchKey key;
|
||||||
while((key = watchService.poll()) != null) {
|
while((key = watchService.poll()) != null) {
|
||||||
for(var event : key.pollEvents()) {
|
for(var event : key.pollEvents()) {
|
||||||
var path = ((WatchEvent<Path>) event).context();
|
@SuppressWarnings("unchecked") var path =
|
||||||
|
((WatchEvent<Path>) event).context();
|
||||||
if(path.equals(watchPaths.get(key))) {
|
if(path.equals(watchPaths.get(key))) {
|
||||||
try {
|
try {
|
||||||
if(watchCallbacks.get(key).call()) {
|
if(watchCallbacks.get(key).call()) {
|
||||||
|
|
|
@ -14,35 +14,15 @@ public final class Mat4f {
|
||||||
public static Mat4f perspective(
|
public static Mat4f perspective(
|
||||||
double fovy, double aspect, double zNear, double zFar
|
double fovy, double aspect, double zNear, double zFar
|
||||||
) {
|
) {
|
||||||
/*
|
|
||||||
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
|
||||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
|
||||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
|
||||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Result[2][2] = zFar / (zFar - zNear);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
|
||||||
*/
|
|
||||||
var mat = new Mat4f();
|
var mat = new Mat4f();
|
||||||
double tanHalfFovy = Math.tan(fovy / 2.0);
|
double tanHalfFovy = Math.tan(fovy / 2.0);
|
||||||
mat.set(0, 0, 1.0 / (aspect * tanHalfFovy));
|
mat.set(0, 0, 1.0 / (aspect * tanHalfFovy));
|
||||||
mat.set(1, 1, 1.0 / tanHalfFovy);
|
mat.set(1, 1, 1.0 / tanHalfFovy);
|
||||||
/*
|
|
||||||
mat.set(2, 2, - (zFar + zNear) / (zFar - zNear));
|
|
||||||
mat.set(2, 3, -1.0);
|
|
||||||
mat.set(3, 2, -(2.0 * zFar * zNear) / (zFar - zNear));
|
|
||||||
*/
|
|
||||||
mat.set(2, 2, zFar / (zFar - zNear));
|
mat.set(2, 2, zFar / (zFar - zNear));
|
||||||
mat.set(2, 3, 1.0);
|
mat.set(2, 3, 1.0);
|
||||||
mat.set(3, 2, -(zFar * zNear) / (zFar - zNear));
|
mat.set(3, 2, -(zFar * zNear) / (zFar - zNear));
|
||||||
//mat.set(3, 3, 0);
|
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ import org.lwjgl.assimp.*;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
@SuppressWarnings("ALL")
|
||||||
public class Test3D extends BaseGame {
|
public class Test3D extends BaseGame {
|
||||||
private Mesh[] meshes;
|
private final Mesh[] meshes;
|
||||||
private ITexture dtex;
|
|
||||||
|
|
||||||
public Test3D() {
|
public Test3D() {
|
||||||
super(new Vec2i(1920, 1080), "Skunkworks 3d test");
|
super(new Vec2i(1920, 1080), "Skunkworks 3d test");
|
||||||
|
@ -25,11 +25,7 @@ public class Test3D extends BaseGame {
|
||||||
//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);
|
||||||
var flags = Assimp.aiProcess_Triangulate;
|
var flags = Assimp.aiProcess_Triangulate;
|
||||||
//flags |= Assimp.aiProcess_FixInfacingNormals;
|
|
||||||
//flags |= Assimp.aiProcess_OptimizeGraph;
|
|
||||||
flags |= Assimp.aiProcess_PreTransformVertices;
|
flags |= Assimp.aiProcess_PreTransformVertices;
|
||||||
//flags |= Assimp.aiProcess_OptimizeMeshes;
|
|
||||||
//flags |= Assimp.aiProcess_Debone;
|
|
||||||
var ai = Assimp.aiImportFile(path, flags);
|
var ai = Assimp.aiImportFile(path, flags);
|
||||||
if(ai == null) {
|
if(ai == null) {
|
||||||
throw new RuntimeException("couldn't load model because: " +
|
throw new RuntimeException("couldn't load model because: " +
|
||||||
|
@ -94,9 +90,6 @@ public class Test3D extends BaseGame {
|
||||||
faces += aiMesh.mNumFaces();
|
faces += aiMesh.mNumFaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
dtex = meshes[14].getTexture();
|
|
||||||
|
|
||||||
|
|
||||||
//window.setDebug(true);
|
//window.setDebug(true);
|
||||||
|
|
||||||
System.out.printf("numMeshes: %d, faces: %d, textures: %d\n",
|
System.out.printf("numMeshes: %d, faces: %d, textures: %d\n",
|
||||||
|
@ -121,12 +114,5 @@ public class Test3D extends BaseGame {
|
||||||
rc.renderMesh(meshes[i]);
|
rc.renderMesh(meshes[i]);
|
||||||
}
|
}
|
||||||
//rc.renderMesh(meshes[14]);
|
//rc.renderMesh(meshes[14]);
|
||||||
/*
|
|
||||||
rc.renderTriangle(new Vec3f(-10, -10, 1),
|
|
||||||
new Vec3f(10, -10, 1),
|
|
||||||
new Vec3f(10, 10, 1)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import com.danitheskunk.skunkworks.audio.ISample;
|
||||||
import com.danitheskunk.skunkworks.nodes.NodeSprite;
|
import com.danitheskunk.skunkworks.nodes.NodeSprite;
|
||||||
|
|
||||||
public class TestNode extends BaseGame {
|
public class TestNode extends BaseGame {
|
||||||
ISample kick;
|
private final ISample kick;
|
||||||
NodeSprite sprite;
|
private final NodeSprite sprite;
|
||||||
|
|
||||||
public TestNode() {
|
public TestNode() {
|
||||||
super(new Vec2i(1280, 720), "Skunkworks");
|
super(new Vec2i(1280, 720), "Skunkworks");
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.danitheskunk.skunkworks.audio.nodes.Node;
|
||||||
import com.danitheskunk.skunkworks.audio.nodes.SamplePlayer;
|
import com.danitheskunk.skunkworks.audio.nodes.SamplePlayer;
|
||||||
import com.danitheskunk.skunkworks.audio.nodes.Sine;
|
import com.danitheskunk.skunkworks.audio.nodes.Sine;
|
||||||
|
|
||||||
|
@SuppressWarnings("ALL")
|
||||||
public class TestSound {
|
public class TestSound {
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
var engine = new AudioEngine(44100, 256, 16);
|
var engine = new AudioEngine(44100, 256, 16);
|
||||||
|
@ -35,17 +36,5 @@ public class TestSound {
|
||||||
Thread.sleep(20);
|
Thread.sleep(20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
for(int i = 0; i < 60; ++i) {
|
|
||||||
engine.refill();
|
|
||||||
Thread.sleep(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < 60; ++i) {
|
|
||||||
engine.refill();
|
|
||||||
Thread.sleep(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import static org.lwjgl.openal.AL10.*;
|
||||||
import static org.lwjgl.openal.ALC10.*;
|
import static org.lwjgl.openal.ALC10.*;
|
||||||
|
|
||||||
public class AudioEngine {
|
public class AudioEngine {
|
||||||
private final int bufferCount;
|
|
||||||
private final int bufferSize;
|
private final int bufferSize;
|
||||||
private final long context;
|
private final long context;
|
||||||
private final long device;
|
private final long device;
|
||||||
|
@ -29,7 +28,6 @@ public class AudioEngine {
|
||||||
public AudioEngine(int sampleRate, int bufferSize, int bufferCount) {
|
public AudioEngine(int sampleRate, int bufferSize, int bufferCount) {
|
||||||
this.sampleRate = sampleRate;
|
this.sampleRate = sampleRate;
|
||||||
this.bufferSize = bufferSize;
|
this.bufferSize = bufferSize;
|
||||||
this.bufferCount = bufferCount;
|
|
||||||
|
|
||||||
device = alcOpenDevice((ByteBuffer) null);
|
device = alcOpenDevice((ByteBuffer) null);
|
||||||
if(device == 0) {
|
if(device == 0) {
|
||||||
|
@ -43,7 +41,7 @@ public class AudioEngine {
|
||||||
alcMakeContextCurrent(context);
|
alcMakeContextCurrent(context);
|
||||||
AL.createCapabilities(deviceCaps);
|
AL.createCapabilities(deviceCaps);
|
||||||
|
|
||||||
this.source = alGenSources();
|
source = alGenSources();
|
||||||
|
|
||||||
for(int i = 0; i < bufferCount; ++i) {
|
for(int i = 0; i < bufferCount; ++i) {
|
||||||
addEmptyBuffer();
|
addEmptyBuffer();
|
||||||
|
@ -89,7 +87,7 @@ public class AudioEngine {
|
||||||
|
|
||||||
public ISample loadSample(String path) {
|
public ISample loadSample(String path) {
|
||||||
//todo: clean up this code
|
//todo: clean up this code
|
||||||
FileInputStream file = null;
|
FileInputStream file;
|
||||||
try {
|
try {
|
||||||
file = new FileInputStream(path);
|
file = new FileInputStream(path);
|
||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
|
|
|
@ -14,9 +14,9 @@ public abstract class Node {
|
||||||
public Node(AudioEngine engine, int inCount, int outCount) {
|
public Node(AudioEngine engine, int inCount, int outCount) {
|
||||||
this.inCount = inCount;
|
this.inCount = inCount;
|
||||||
this.outCount = outCount;
|
this.outCount = outCount;
|
||||||
this.isOutConnected = new boolean[outCount];
|
isOutConnected = new boolean[outCount];
|
||||||
this.inConnections = new Node[inCount];
|
inConnections = new Node[inCount];
|
||||||
this.inConnectionSlots = new int[inCount];
|
inConnectionSlots = new int[inCount];
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
if(outCount > 1) {
|
if(outCount > 1) {
|
||||||
throw new RuntimeException("more than one out connection not yet" +
|
throw new RuntimeException("more than one out connection not yet" +
|
||||||
|
|
|
@ -3,10 +3,9 @@ package com.danitheskunk.skunkworks.backends.gl;
|
||||||
import static org.lwjgl.opengl.GL46.*;
|
import static org.lwjgl.opengl.GL46.*;
|
||||||
|
|
||||||
public class Program {
|
public class Program {
|
||||||
Shader fragment;
|
private final Shader fragment;
|
||||||
int program;
|
private final int program;
|
||||||
Shader vertex;
|
private final Shader vertex;
|
||||||
|
|
||||||
public Program(String vertexSource, String fragmentSource) {
|
public Program(String vertexSource, String fragmentSource) {
|
||||||
vertex = new Shader(vertexSource, GL_VERTEX_SHADER);
|
vertex = new Shader(vertexSource, GL_VERTEX_SHADER);
|
||||||
fragment = new Shader(fragmentSource, GL_FRAGMENT_SHADER);
|
fragment = new Shader(fragmentSource, GL_FRAGMENT_SHADER);
|
||||||
|
@ -25,6 +24,10 @@ public class Program {
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProgram() {
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
public int getUniformLocation(String attrib) {
|
public int getUniformLocation(String attrib) {
|
||||||
return glGetUniformLocation(program, attrib);
|
return glGetUniformLocation(program, attrib);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,16 @@ import com.danitheskunk.skunkworks.gfx.*;
|
||||||
import static org.lwjgl.opengl.GL46.*;
|
import static org.lwjgl.opengl.GL46.*;
|
||||||
|
|
||||||
class RenderContext extends BaseRenderContext implements IRenderContext {
|
class RenderContext extends BaseRenderContext implements IRenderContext {
|
||||||
private final TextureAtlas atlas;
|
|
||||||
private final int texCoordIndex;
|
private final int texCoordIndex;
|
||||||
private final int texOffsetIndex;
|
private final int texOffsetIndex;
|
||||||
private final int texSizeIndex;
|
private final int texSizeIndex;
|
||||||
private final int tintIndex;
|
private final int tintIndex;
|
||||||
|
|
||||||
public RenderContext(
|
public RenderContext(
|
||||||
Vec2i size, TextureAtlas atlas, int texCoordIndex, int texOffsetIndex,
|
Vec2i size, int texCoordIndex, int texOffsetIndex,
|
||||||
int texSizeIndex, int tintIndex
|
int texSizeIndex, int tintIndex
|
||||||
) {
|
) {
|
||||||
super(size);
|
super(size);
|
||||||
this.atlas = atlas;
|
|
||||||
this.texCoordIndex = texCoordIndex;
|
this.texCoordIndex = texCoordIndex;
|
||||||
this.texOffsetIndex = texOffsetIndex;
|
this.texOffsetIndex = texOffsetIndex;
|
||||||
this.texSizeIndex = texSizeIndex;
|
this.texSizeIndex = texSizeIndex;
|
||||||
|
@ -38,7 +36,6 @@ class RenderContext extends BaseRenderContext implements IRenderContext {
|
||||||
slice.getBottom().getSize().getY()
|
slice.getBottom().getSize().getY()
|
||||||
);
|
);
|
||||||
var pos = rect.getPos();
|
var pos = rect.getPos();
|
||||||
var size = rect.getSize();
|
|
||||||
|
|
||||||
drawTexture(pos, slice.getTopLeft());
|
drawTexture(pos, slice.getTopLeft());
|
||||||
drawTexture(new Vec2i(pos.getX() +
|
drawTexture(new Vec2i(pos.getX() +
|
||||||
|
@ -148,25 +145,9 @@ class RenderContext extends BaseRenderContext implements IRenderContext {
|
||||||
var bl = rect.getBottomLeft();
|
var bl = rect.getBottomLeft();
|
||||||
var br = rect.getBottomRight();
|
var br = rect.getBottomRight();
|
||||||
|
|
||||||
/*
|
|
||||||
var ttl = Vec2i.divf(tex.getTexArea().getTopLeft(), atlas.getSize
|
|
||||||
());
|
|
||||||
var ttr = Vec2i.divf(tex.getTexArea().getTopRight(), atlas.getSize
|
|
||||||
());
|
|
||||||
var tbl = Vec2i.divf(tex.getTexArea().getBottomLeft(), atlas.getSize
|
|
||||||
());
|
|
||||||
var tbr = Vec2i.divf(tex.getTexArea().getBottomRight(), atlas.getSize
|
|
||||||
());
|
|
||||||
*/
|
|
||||||
|
|
||||||
var topleft = tex.getTexArea().getTopLeft();
|
var topleft = tex.getTexArea().getTopLeft();
|
||||||
//var size = repeat ? tex.getSize() : rect.getSize();
|
|
||||||
var size = repeat ? tex.getSize() : new Vec2i(100000, 100000);
|
var size = repeat ? tex.getSize() : new Vec2i(100000, 100000);
|
||||||
/*var ttl = Vec2i.ZERO;
|
|
||||||
var ttr = Vec2i.sub(tex.getTexArea().getTopRight(), topleft);
|
|
||||||
var tbl = Vec2i.sub(tex.getTexArea().getBottomLeft(), topleft);
|
|
||||||
var tbr = Vec2i.sub(tex.getTexArea().getBottomRight(), topleft);
|
|
||||||
*/
|
|
||||||
var ttl = Vec2i.ZERO;
|
var ttl = Vec2i.ZERO;
|
||||||
var ttr = new Vec2i(rect.getWidth(), 0);
|
var ttr = new Vec2i(rect.getWidth(), 0);
|
||||||
var tbl = new Vec2i(0, rect.getHeight());
|
var tbl = new Vec2i(0, rect.getHeight());
|
||||||
|
@ -184,11 +165,11 @@ class RenderContext extends BaseRenderContext implements IRenderContext {
|
||||||
color.getB() / 255.0f,
|
color.getB() / 255.0f,
|
||||||
color.getA() / 255.0f
|
color.getA() / 255.0f
|
||||||
);
|
);
|
||||||
//color.getA() / 255.0f);
|
|
||||||
|
|
||||||
glUniform2i(texOffsetIndex, topleft.getX(), topleft.getY());
|
glUniform2i(texOffsetIndex, topleft.getX(), topleft.getY());
|
||||||
glUniform2i(texSizeIndex, size.getX(), size.getY());
|
glUniform2i(texSizeIndex, size.getX(), size.getY());
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
//counterclockwise triangles
|
//counterclockwise triangles
|
||||||
glVertexAttribI2i(texCoordIndex, tbl.getX(), tbl.getY());
|
glVertexAttribI2i(texCoordIndex, tbl.getX(), tbl.getY());
|
||||||
glVertex2i(bl.getX(), bl.getY());
|
glVertex2i(bl.getX(), bl.getY());
|
||||||
|
|
|
@ -42,21 +42,6 @@ public class RenderContext3D extends BaseRenderContext3D {
|
||||||
assert (t3.getX() >= 0.0 && t3.getX() <= 1.0);
|
assert (t3.getX() >= 0.0 && t3.getX() <= 1.0);
|
||||||
assert (t3.getY() >= 0.0 && t3.getY() <= 1.0);
|
assert (t3.getY() >= 0.0 && t3.getY() <= 1.0);
|
||||||
|
|
||||||
/*
|
|
||||||
t1 = new Vec2f(t1.getX() * 0.8 + 0.1,
|
|
||||||
t1.getY() * 0.8 + 0.1
|
|
||||||
);
|
|
||||||
t2 = new Vec2f(t2.getX() * 0.8 + 0.1,
|
|
||||||
t2.getY() * 0.8 + 0.1
|
|
||||||
);
|
|
||||||
t3 = new Vec2f(t3.getX() * 0.8 + 0.1,
|
|
||||||
t3.getY() * 0.8 + 0.1
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
//t1 = new Vec2f(t1.getX(), 1.0 - t1.getY());
|
|
||||||
//t2 = new Vec2f(t2.getX(), 1.0 - t2.getY());
|
|
||||||
//t3 = new Vec2f(t3.getX(), 1.0 - t3.getY());
|
|
||||||
t1 = Vec2f.add(texOff, Vec2f.mul(texMult, t1));
|
t1 = Vec2f.add(texOff, Vec2f.mul(texMult, t1));
|
||||||
t2 = Vec2f.add(texOff, Vec2f.mul(texMult, t2));
|
t2 = Vec2f.add(texOff, Vec2f.mul(texMult, t2));
|
||||||
t3 = Vec2f.add(texOff, Vec2f.mul(texMult, t3));
|
t3 = Vec2f.add(texOff, Vec2f.mul(texMult, t3));
|
||||||
|
@ -82,12 +67,6 @@ public class RenderContext3D extends BaseRenderContext3D {
|
||||||
glVertex3d(p2.getX(), p2.getY(), p2.getZ());
|
glVertex3d(p2.getX(), p2.getY(), p2.getZ());
|
||||||
glVertex3d(p3.getX(), p3.getY(), p3.getZ());
|
glVertex3d(p3.getX(), p3.getY(), p3.getZ());
|
||||||
|
|
||||||
/*
|
|
||||||
glVertex3f((float) p1.getX(), (float) p1.getY(), (float) p1.getZ());
|
|
||||||
glVertex3f((float) p2.getX(), (float) p2.getY(), (float) p2.getZ());
|
|
||||||
glVertex3f((float) p3.getX(), (float) p3.getY(), (float) p3.getZ());
|
|
||||||
*/
|
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,8 @@ import static org.lwjgl.opengl.GL46.*;
|
||||||
|
|
||||||
public class Shader {
|
public class Shader {
|
||||||
private final int shader;
|
private final int shader;
|
||||||
private final int type;
|
|
||||||
|
|
||||||
public Shader(String source, int type) {
|
public Shader(String source, int type) {
|
||||||
this.type = type;
|
|
||||||
|
|
||||||
shader = glCreateShader(type);
|
shader = glCreateShader(type);
|
||||||
glShaderSource(shader, source);
|
glShaderSource(shader, source);
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Texture implements ITexture {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec2i getSize() {
|
public Vec2i getSize() {
|
||||||
return this.img.getSize();
|
return img.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
Recti getTexArea() {
|
Recti getTexArea() {
|
||||||
|
|
|
@ -2,9 +2,9 @@ package com.danitheskunk.skunkworks.backends.gl;
|
||||||
|
|
||||||
import com.danitheskunk.skunkworks.*;
|
import com.danitheskunk.skunkworks.*;
|
||||||
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||||
import com.danitheskunk.skunkworks.gfx.threedee.IRenderContext3D;
|
|
||||||
import com.danitheskunk.skunkworks.gfx.ITexture;
|
import com.danitheskunk.skunkworks.gfx.ITexture;
|
||||||
import com.danitheskunk.skunkworks.gfx.Image;
|
import com.danitheskunk.skunkworks.gfx.Image;
|
||||||
|
import com.danitheskunk.skunkworks.gfx.threedee.IRenderContext3D;
|
||||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
@ -99,20 +99,19 @@ public class Window extends BaseWindow {
|
||||||
""";
|
""";
|
||||||
private final int framebuffer;
|
private final int framebuffer;
|
||||||
private final int framebufferTex;
|
private final int framebufferTex;
|
||||||
private final int framebufferDepthTex;
|
|
||||||
private final Program program;
|
private final Program program;
|
||||||
private final Program program3D;
|
private final Program program3D;
|
||||||
private final Program programScaler;
|
private final Program programScaler;
|
||||||
|
private final Mat4f projection;
|
||||||
private final RenderContext renderContext;
|
private final RenderContext renderContext;
|
||||||
private final RenderContext3D renderContext3D;
|
private final RenderContext3D renderContext3D;
|
||||||
private final Vec2i size;
|
private final Vec2i size;
|
||||||
|
private final boolean[] stateMouseClicked;
|
||||||
|
private final boolean[] stateMouseDown;
|
||||||
private final TextureAtlas textureAtlas;
|
private final TextureAtlas textureAtlas;
|
||||||
private final long window;
|
private final long window;
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
private final Mat4f projection;
|
|
||||||
private boolean shouldClose;
|
private boolean shouldClose;
|
||||||
private final boolean[] stateMouseClicked;
|
|
||||||
private final boolean[] stateMouseDown;
|
|
||||||
private Vec2i windowSize;
|
private Vec2i windowSize;
|
||||||
|
|
||||||
public Window(Vec2i size, String title, Engine engine) {
|
public Window(Vec2i size, String title, Engine engine) {
|
||||||
|
@ -122,12 +121,12 @@ public class Window extends BaseWindow {
|
||||||
"Unable to initialize GLFW");
|
"Unable to initialize GLFW");
|
||||||
|
|
||||||
glfwDefaultWindowHints();
|
glfwDefaultWindowHints();
|
||||||
this.debug = false;
|
debug = false;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.windowSize = size;
|
windowSize = size;
|
||||||
|
|
||||||
this.stateMouseClicked = new boolean[8];
|
stateMouseClicked = new boolean[8];
|
||||||
this.stateMouseDown = new boolean[8];
|
stateMouseDown = new boolean[8];
|
||||||
|
|
||||||
window = glfwCreateWindow(size.getX(), size.getY(), title, NULL, NULL);
|
window = glfwCreateWindow(size.getX(), size.getY(), title, NULL, NULL);
|
||||||
if(window == NULL) throw new RuntimeException(
|
if(window == NULL) throw new RuntimeException(
|
||||||
|
@ -174,7 +173,7 @@ public class Window extends BaseWindow {
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
framebufferDepthTex = glGenTextures();
|
int framebufferDepthTex = glGenTextures();
|
||||||
glBindTexture(GL_TEXTURE_2D, framebufferDepthTex);
|
glBindTexture(GL_TEXTURE_2D, framebufferDepthTex);
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
|
@ -204,17 +203,18 @@ public class Window extends BaseWindow {
|
||||||
projection = Mat4f.perspective(Math.PI / 2, 16.0 / 9.0, 0.1, 100.0);
|
projection = Mat4f.perspective(Math.PI / 2, 16.0 / 9.0, 0.1, 100.0);
|
||||||
|
|
||||||
renderContext = new RenderContext(size,
|
renderContext = new RenderContext(size,
|
||||||
textureAtlas,
|
|
||||||
program.getAttribLocation("texCoord"),
|
program.getAttribLocation("texCoord"),
|
||||||
program.getUniformLocation("texOffset"),
|
program.getUniformLocation("texOffset"),
|
||||||
program.getUniformLocation("texSize"),
|
program.getUniformLocation("texSize"),
|
||||||
program.getUniformLocation("tint")
|
program.getUniformLocation("tint")
|
||||||
);
|
);
|
||||||
|
|
||||||
renderContext3D = new RenderContext3D(program.getAttribLocation("texCoord"));
|
renderContext3D = new RenderContext3D(program.getAttribLocation(
|
||||||
|
"texCoord"));
|
||||||
renderContext3D.setTextureAtlas(textureAtlas);
|
renderContext3D.setTextureAtlas(textureAtlas);
|
||||||
|
|
||||||
glProgramUniform2f(program.program,
|
glProgramUniform2f(
|
||||||
|
program.getProgram(),
|
||||||
program.getUniformLocation("windowSize"),
|
program.getUniformLocation("windowSize"),
|
||||||
size.getX(),
|
size.getX(),
|
||||||
size.getY()
|
size.getY()
|
||||||
|
@ -235,13 +235,13 @@ public class Window extends BaseWindow {
|
||||||
glfwGetCursorPos(window, x, y);
|
glfwGetCursorPos(window, x, y);
|
||||||
var mousePos = new Vec2i((int) x[0], (int) y[0]);
|
var mousePos = new Vec2i((int) x[0], (int) y[0]);
|
||||||
|
|
||||||
var scaledMousePos = switch(this.stretchMode) {
|
var scaledMousePos = switch(stretchMode) {
|
||||||
case STRETCH -> {
|
case STRETCH -> {
|
||||||
var stretch = Vec2f.div(this.size, this.windowSize);
|
var stretch = Vec2f.div(size, windowSize);
|
||||||
yield Vec2i.mul(stretch, mousePos);
|
yield Vec2i.mul(stretch, mousePos);
|
||||||
}
|
}
|
||||||
case ASPECT -> {
|
case ASPECT -> {
|
||||||
var scale = Vec2f.div(this.size, this.windowSize);
|
var scale = Vec2f.div(size, windowSize);
|
||||||
var scalef = Math.max(scale.getX(), scale.getY());
|
var scalef = Math.max(scale.getX(), scale.getY());
|
||||||
|
|
||||||
var off = Vec2f.div(Vec2i.sub(windowSize,
|
var off = Vec2f.div(Vec2i.sub(windowSize,
|
||||||
|
@ -251,7 +251,7 @@ public class Window extends BaseWindow {
|
||||||
yield Vec2i.mul(Vec2i.sub(mousePos, off), 1.0 / scalef);
|
yield Vec2i.mul(Vec2i.sub(mousePos, off), 1.0 / scalef);
|
||||||
}
|
}
|
||||||
case INTEGER -> {
|
case INTEGER -> {
|
||||||
var scale = Vec2i.div(this.windowSize, this.size);
|
var scale = Vec2i.div(windowSize, size);
|
||||||
var scalei = Math.max(1, Math.min(scale.getX(), scale.getY()));
|
var scalei = Math.max(1, Math.min(scale.getX(), scale.getY()));
|
||||||
|
|
||||||
var off = Vec2i.div(Vec2i.sub(windowSize,
|
var off = Vec2i.div(Vec2i.sub(windowSize,
|
||||||
|
@ -268,12 +268,12 @@ public class Window extends BaseWindow {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMouseClicked(int button) {
|
public boolean isMouseClicked(int button) {
|
||||||
return this.stateMouseClicked[button];
|
return stateMouseClicked[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMouseDown(int button) {
|
public boolean isMouseDown(int button) {
|
||||||
return this.stateMouseDown[button];
|
return stateMouseDown[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -311,17 +311,18 @@ public class Window extends BaseWindow {
|
||||||
return loadTextureArray(img, tileSize);
|
return loadTextureArray(img, tileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void mouseButtonCallback(
|
private void mouseButtonCallback(
|
||||||
long window, int button, int action, int mods
|
@SuppressWarnings("unused") long window, int button, int action,
|
||||||
|
@SuppressWarnings(
|
||||||
|
"unused") int mods
|
||||||
) {
|
) {
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case GLFW_PRESS -> {
|
case GLFW_PRESS -> {
|
||||||
this.stateMouseClicked[button] = true;
|
stateMouseClicked[button] = true;
|
||||||
this.stateMouseDown[button] = true;
|
stateMouseDown[button] = true;
|
||||||
}
|
|
||||||
case GLFW_RELEASE -> {
|
|
||||||
this.stateMouseDown[button] = false;
|
|
||||||
}
|
}
|
||||||
|
case GLFW_RELEASE -> stateMouseDown[button] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +384,8 @@ public class Window extends BaseWindow {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, framebufferTex);
|
glBindTexture(GL_TEXTURE_2D, framebufferTex);
|
||||||
glProgramUniform2f(programScaler.program,
|
glProgramUniform2f(
|
||||||
|
programScaler.getProgram(),
|
||||||
programScaler.getUniformLocation("windowSize"),
|
programScaler.getUniformLocation("windowSize"),
|
||||||
windowSize.getX(),
|
windowSize.getX(),
|
||||||
windowSize.getY()
|
windowSize.getY()
|
||||||
|
@ -394,15 +396,12 @@ public class Window extends BaseWindow {
|
||||||
int tlx2 = 0;
|
int tlx2 = 0;
|
||||||
int tly2 = 0;
|
int tly2 = 0;
|
||||||
|
|
||||||
switch(this.stretchMode) {
|
switch(stretchMode) {
|
||||||
case STRETCH: {
|
case STRETCH -> {
|
||||||
tlx1 = 0;
|
|
||||||
tly1 = 0;
|
|
||||||
tlx2 = windowSize.getX();
|
tlx2 = windowSize.getX();
|
||||||
tly2 = windowSize.getY();
|
tly2 = windowSize.getY();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ASPECT: {
|
case ASPECT -> {
|
||||||
float scalex = (float) windowSize.getX() / (float) size.getX();
|
float scalex = (float) windowSize.getX() / (float) size.getX();
|
||||||
float scaley = (float) windowSize.getY() / (float) size.getY();
|
float scaley = (float) windowSize.getY() / (float) size.getY();
|
||||||
float scale = Math.min(scalex, scaley);
|
float scale = Math.min(scalex, scaley);
|
||||||
|
@ -418,9 +417,8 @@ public class Window extends BaseWindow {
|
||||||
tly1 = yoff;
|
tly1 = yoff;
|
||||||
tlx2 = (int) (xoff + size.getX() * scale);
|
tlx2 = (int) (xoff + size.getX() * scale);
|
||||||
tly2 = (int) (yoff + size.getY() * scale);
|
tly2 = (int) (yoff + size.getY() * scale);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case INTEGER: {
|
case INTEGER -> {
|
||||||
int scalex = windowSize.getX() / size.getX();
|
int scalex = windowSize.getX() / size.getX();
|
||||||
int scaley = windowSize.getY() / size.getY();
|
int scaley = windowSize.getY() / size.getY();
|
||||||
int scale = Math.max(1, Math.min(scalex, scaley));
|
int scale = Math.max(1, Math.min(scalex, scaley));
|
||||||
|
@ -432,7 +430,6 @@ public class Window extends BaseWindow {
|
||||||
tly1 = yoff;
|
tly1 = yoff;
|
||||||
tlx2 = xoff + size.getX() * scale;
|
tlx2 = xoff + size.getX() * scale;
|
||||||
tly2 = yoff + size.getY() * scale;
|
tly2 = yoff + size.getY() * scale;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,13 +454,12 @@ public class Window extends BaseWindow {
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDebug(boolean on) {
|
public void setDebug(boolean on) {
|
||||||
this.debug = on;
|
debug = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -483,11 +479,11 @@ public class Window extends BaseWindow {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void windowSizeCallback(long window, int width, int height) {
|
private void windowSizeCallback(
|
||||||
|
@SuppressWarnings("unused") long window, int width, int height
|
||||||
|
) {
|
||||||
System.out.printf("new window size %d x %d\n", width, height);
|
System.out.printf("new window size %d x %d\n", width, height);
|
||||||
windowSize = new Vec2i(width, height);
|
windowSize = new Vec2i(width, height);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
//glLoadIdentity();
|
|
||||||
//glOrtho(0.0f, width, height, 0.0f, 0.0f, 1.0f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.nio.ByteBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
abstract public class BaseRenderContext implements IRenderContext {
|
abstract public class BaseRenderContext implements IRenderContext {
|
||||||
protected Vec2i size;
|
protected final Vec2i size;
|
||||||
|
|
||||||
protected BaseRenderContext(Vec2i size) {
|
protected BaseRenderContext(Vec2i size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public final class Color {
|
||||||
this.r = r;
|
this.r = r;
|
||||||
this.g = g;
|
this.g = g;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
this.a = 0xff;
|
a = 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color(int r, int g, int b, int a) {
|
public Color(int r, int g, int b, int a) {
|
||||||
|
|
|
@ -12,12 +12,11 @@ import java.util.HashMap;
|
||||||
import static org.lwjgl.stb.STBTruetype.*;
|
import static org.lwjgl.stb.STBTruetype.*;
|
||||||
|
|
||||||
public class FontTTF implements IFont {
|
public class FontTTF implements IFont {
|
||||||
HashMap<Integer, Char> chars;
|
private final HashMap<Integer, Char> chars;
|
||||||
STBTTFontinfo info;
|
private final STBTTFontinfo info;
|
||||||
int lineHeight;
|
private final int lineHeight;
|
||||||
float size;
|
private final float size;
|
||||||
float unscaled_size;
|
private final IWindow window;
|
||||||
IWindow window;
|
|
||||||
|
|
||||||
public FontTTF(ByteBuffer buffer, float size, IWindow window) {
|
public FontTTF(ByteBuffer buffer, float size, IWindow window) {
|
||||||
int[] ascent = {0};
|
int[] ascent = {0};
|
||||||
|
@ -25,8 +24,8 @@ public class FontTTF implements IFont {
|
||||||
int[] lineGap = {0};
|
int[] lineGap = {0};
|
||||||
|
|
||||||
this.window = window;
|
this.window = window;
|
||||||
this.chars = new HashMap<>();
|
chars = new HashMap<>();
|
||||||
this.info = STBTTFontinfo.create();
|
info = STBTTFontinfo.create();
|
||||||
|
|
||||||
if(!stbtt_InitFont(info, buffer)) {
|
if(!stbtt_InitFont(info, buffer)) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
@ -35,7 +34,6 @@ public class FontTTF implements IFont {
|
||||||
//todo: save these
|
//todo: save these
|
||||||
stbtt_GetFontVMetrics(info, ascent, descent, lineGap);
|
stbtt_GetFontVMetrics(info, ascent, descent, lineGap);
|
||||||
lineHeight = lineGap[0];
|
lineHeight = lineGap[0];
|
||||||
this.unscaled_size = size;
|
|
||||||
this.size = stbtt_ScaleForPixelHeight(info, size);
|
this.size = stbtt_ScaleForPixelHeight(info, size);
|
||||||
|
|
||||||
//precache ascii characters
|
//precache ascii characters
|
||||||
|
@ -127,10 +125,10 @@ public class FontTTF implements IFont {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Char {
|
private static class Char {
|
||||||
int advance;
|
final int advance;
|
||||||
Vec2i off;
|
final Vec2i off;
|
||||||
ITexture tex;
|
final ITexture tex;
|
||||||
|
|
||||||
Char(ITexture tex, int advance, Vec2i off) {
|
Char(ITexture tex, int advance, Vec2i off) {
|
||||||
this.tex = tex;
|
this.tex = tex;
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class FontTileset implements IFont {
|
||||||
|
|
||||||
public FontTileset(List<ITexture> textures) {
|
public FontTileset(List<ITexture> textures) {
|
||||||
this.textures = textures;
|
this.textures = textures;
|
||||||
this.charSize = textures.get(0).getSize();
|
charSize = textures.get(0).getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,5 +16,6 @@ public interface IFont {
|
||||||
|
|
||||||
boolean isCP437();
|
boolean isCP437();
|
||||||
|
|
||||||
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
boolean isMonospace();
|
boolean isMonospace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class Mesh {
|
public class Mesh {
|
||||||
private ITexture texture;
|
private ITexture texture;
|
||||||
private List<Vec3i> triangles;
|
private final List<Vec3i> triangles;
|
||||||
private List<Vec2f> uv;
|
private final List<Vec2f> uv;
|
||||||
private List<Vec3f> vertices;
|
private final List<Vec3f> vertices;
|
||||||
|
|
||||||
public Mesh() {
|
public Mesh() {
|
||||||
vertices = new ArrayList<>();
|
vertices = new ArrayList<>();
|
||||||
|
@ -24,9 +24,6 @@ public class Mesh {
|
||||||
public static Mesh fromAIMesh(AIMesh aiMesh) {
|
public static Mesh fromAIMesh(AIMesh aiMesh) {
|
||||||
var mesh = new Mesh();
|
var mesh = new Mesh();
|
||||||
|
|
||||||
var numVertices = aiMesh.mNumVertices();
|
|
||||||
var numFaces = aiMesh.mNumFaces();
|
|
||||||
|
|
||||||
var vertexBuffer = aiMesh.mVertices();
|
var vertexBuffer = aiMesh.mVertices();
|
||||||
var faceBuffer = aiMesh.mFaces();
|
var faceBuffer = aiMesh.mFaces();
|
||||||
var texCoordsBuffer = aiMesh.mTextureCoords(0);
|
var texCoordsBuffer = aiMesh.mTextureCoords(0);
|
||||||
|
@ -46,6 +43,7 @@ public class Mesh {
|
||||||
mesh.addTriangle(indices.get(0), indices.get(1), indices.get(2));
|
mesh.addTriangle(indices.get(0), indices.get(1), indices.get(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(texCoordsBuffer != null);
|
||||||
while(texCoordsBuffer.remaining() > 0) {
|
while(texCoordsBuffer.remaining() > 0) {
|
||||||
var uv = texCoordsBuffer.get();
|
var uv = texCoordsBuffer.get();
|
||||||
var x = Math.max(0.0001, Math.min(uv.x(), 0.9999));
|
var x = Math.max(0.0001, Math.min(uv.x(), 0.9999));
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class Terminal {
|
||||||
private final Vec2i size;
|
private final Vec2i size;
|
||||||
|
|
||||||
public Terminal(Vec2i size, IFont fullFont, IFont halfFont) {
|
public Terminal(Vec2i size, IFont fullFont, IFont halfFont) {
|
||||||
this.cells = new ArrayList<>();
|
cells = new ArrayList<>();
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.fullFont = fullFont;
|
this.fullFont = fullFont;
|
||||||
this.halfFont = halfFont;
|
this.halfFont = halfFont;
|
||||||
|
@ -30,8 +30,8 @@ public class Terminal {
|
||||||
throw new RuntimeException("Fonts need to be monospace");
|
throw new RuntimeException("Fonts need to be monospace");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fullCharSize = fullFont.getMonospaceSize();
|
fullCharSize = fullFont.getMonospaceSize();
|
||||||
this.halfCharSize = halfFont.getMonospaceSize();
|
halfCharSize = halfFont.getMonospaceSize();
|
||||||
|
|
||||||
if(fullCharSize.getY() != halfCharSize.getY() ||
|
if(fullCharSize.getY() != halfCharSize.getY() ||
|
||||||
fullCharSize.getX() != halfCharSize.getX() * 2) {
|
fullCharSize.getX() != halfCharSize.getX() * 2) {
|
||||||
|
@ -51,16 +51,16 @@ public class Terminal {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Terminal(Vec2i size, IFont fullFont) {
|
public Terminal(Vec2i size, IFont fullFont) {
|
||||||
this.cells = new ArrayList<>();
|
cells = new ArrayList<>();
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.fullFont = fullFont;
|
this.fullFont = fullFont;
|
||||||
this.halfFont = null;
|
halfFont = null;
|
||||||
|
|
||||||
if(!fullFont.isMonospace()) {
|
if(!fullFont.isMonospace()) {
|
||||||
throw new RuntimeException("Fonts need to be monospace");
|
throw new RuntimeException("Fonts need to be monospace");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fullCharSize = fullFont.getMonospaceSize();
|
fullCharSize = fullFont.getMonospaceSize();
|
||||||
|
|
||||||
for(int i = 0; i < size.getY() * size.getX(); ++i) {
|
for(int i = 0; i < size.getY() * size.getX(); ++i) {
|
||||||
var cell = new Cell();
|
var cell = new Cell();
|
||||||
|
@ -681,7 +681,7 @@ public class Terminal {
|
||||||
return pos.getX() + pos.getY() * size.getX();
|
return pos.getX() + pos.getY() * size.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Cell {
|
private static class Cell {
|
||||||
Color bgColor;
|
Color bgColor;
|
||||||
Color fgColor;
|
Color fgColor;
|
||||||
int fullChar;
|
int fullChar;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||||
//todo: figure out the whole translation position thingie
|
//todo: figure out the whole translation position thingie
|
||||||
|
|
||||||
public class Node implements Iterable<Node> {
|
public class Node implements Iterable<Node> {
|
||||||
protected List<Node> children;
|
protected final List<Node> children;
|
||||||
protected Node parent;
|
protected Node parent;
|
||||||
protected Vec2f pos;
|
protected Vec2f pos;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package com.danitheskunk.skunkworks.nodes;
|
package com.danitheskunk.skunkworks.nodes;
|
||||||
|
|
||||||
import com.danitheskunk.skunkworks.Timestep;
|
|
||||||
|
|
||||||
public class NodeRoot extends Node {
|
public class NodeRoot extends Node {
|
||||||
private final Tweener tweener;
|
private final Tweener tweener;
|
||||||
|
|
||||||
public NodeRoot() {
|
public NodeRoot() {
|
||||||
tweener = new Tweener(Timestep.FIXED);
|
tweener = new Tweener();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
package com.danitheskunk.skunkworks.nodes;
|
package com.danitheskunk.skunkworks.nodes;
|
||||||
|
|
||||||
import com.danitheskunk.skunkworks.Timestep;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Tweener {
|
public class Tweener {
|
||||||
private int currentFrame;
|
private int currentFrame;
|
||||||
private final Timestep timestepMode;
|
|
||||||
private final List<BaseTween> tweens;
|
private final List<BaseTween> tweens;
|
||||||
|
|
||||||
public Tweener(Timestep timestepMode) {
|
public Tweener() {
|
||||||
this.timestepMode = timestepMode;
|
tweens = new ArrayList<>();
|
||||||
this.tweens = new ArrayList<>();
|
currentFrame = 0;
|
||||||
this.currentFrame = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(BaseTween tween) {
|
public void add(BaseTween tween) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.sun.jna.platform.win32.WinDef;
|
||||||
import com.sun.jna.platform.win32.WinNT;
|
import com.sun.jna.platform.win32.WinNT;
|
||||||
import com.sun.jna.win32.W32APIOptions;
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public interface Dwm extends Library {
|
public interface Dwm extends Library {
|
||||||
WinDef.DWORD DWMWA_ALLOW_NCPAINT = new WinDef.DWORD(4);
|
WinDef.DWORD DWMWA_ALLOW_NCPAINT = new WinDef.DWORD(4);
|
||||||
WinDef.DWORD DWMWA_CAPTION_BUTTON_BOUNDS = new WinDef.DWORD(5);
|
WinDef.DWORD DWMWA_CAPTION_BUTTON_BOUNDS = new WinDef.DWORD(5);
|
||||||
|
|
|
@ -14,9 +14,9 @@ public class TITLEBARINFO extends Structure {
|
||||||
public static final int RESERVED = 1;
|
public static final int RESERVED = 1;
|
||||||
// Index constants
|
// Index constants
|
||||||
public static final int TITLE_BAR = 0;
|
public static final int TITLE_BAR = 0;
|
||||||
public int cbSize;
|
public final int cbSize;
|
||||||
public WinDef.RECT rcTitleBar;
|
public WinDef.RECT rcTitleBar;
|
||||||
public int[] rgstate;
|
public final int[] rgstate;
|
||||||
|
|
||||||
public TITLEBARINFO() {
|
public TITLEBARINFO() {
|
||||||
rgstate = new int[CCHILDREN_TITLEBAR + 1];
|
rgstate = new int[CCHILDREN_TITLEBAR + 1];
|
||||||
|
|
|
@ -53,9 +53,13 @@ public interface User32Extra extends User32 {
|
||||||
int WS_EX_TOPMOST = 0x00000008;
|
int WS_EX_TOPMOST = 0x00000008;
|
||||||
int WS_EX_TRANSPARENT = 0x00000020;
|
int WS_EX_TRANSPARENT = 0x00000020;
|
||||||
int WS_EX_WINDOWEDGE = 0x00000100;
|
int WS_EX_WINDOWEDGE = 0x00000100;
|
||||||
long WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
|
long WS_EX_OVERLAPPEDWINDOW = (
|
||||||
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE
|
||||||
|
);
|
||||||
long WS_EX_PALETTEWINDOW = (
|
long WS_EX_PALETTEWINDOW = (
|
||||||
WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST
|
WS_EX_WINDOWEDGE |
|
||||||
|
WS_EX_TOOLWINDOW |
|
||||||
|
WS_EX_TOPMOST
|
||||||
);
|
);
|
||||||
|
|
||||||
HCURSOR GetCursor();
|
HCURSOR GetCursor();
|
||||||
|
@ -64,6 +68,7 @@ public interface User32Extra extends User32 {
|
||||||
WinDef.HWND GetLastActivePopup(WinDef.HWND hwnd);
|
WinDef.HWND GetLastActivePopup(WinDef.HWND hwnd);
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-gettitlebarinfo
|
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-gettitlebarinfo
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
boolean GetTitleBarInfo(WinDef.HWND hwnd, TITLEBARINFO titlebarinfo);
|
boolean GetTitleBarInfo(WinDef.HWND hwnd, TITLEBARINFO titlebarinfo);
|
||||||
|
|
||||||
WinDef.HWND GetTopWindow(HWND hWnd);
|
WinDef.HWND GetTopWindow(HWND hWnd);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.sun.jna.Native;
|
||||||
import com.sun.jna.platform.win32.WinUser;
|
import com.sun.jna.platform.win32.WinUser;
|
||||||
import com.sun.jna.win32.W32APIOptions;
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public interface WinUserExtra extends WinUser,
|
public interface WinUserExtra extends WinUser,
|
||||||
com.sun.jna.win32.StdCallLibrary {
|
com.sun.jna.win32.StdCallLibrary {
|
||||||
WinUserExtra INSTANCE = Native.load("user32",
|
WinUserExtra INSTANCE = Native.load("user32",
|
||||||
|
|
|
@ -4,7 +4,7 @@ package com.danitheskunk.skunkworks.os.windows;
|
||||||
import com.danitheskunk.skunkworks.Recti;
|
import com.danitheskunk.skunkworks.Recti;
|
||||||
import com.danitheskunk.skunkworks.Util;
|
import com.danitheskunk.skunkworks.Util;
|
||||||
import com.sun.jna.Native;
|
import com.sun.jna.Native;
|
||||||
import com.sun.jna.Pointer;
|
import com.sun.jna.Structure;
|
||||||
import com.sun.jna.platform.win32.*;
|
import com.sun.jna.platform.win32.*;
|
||||||
import com.sun.jna.ptr.IntByReference;
|
import com.sun.jna.ptr.IntByReference;
|
||||||
|
|
||||||
|
@ -23,13 +23,10 @@ public class Window {
|
||||||
var user32 = User32Extra.INSTANCE;
|
var user32 = User32Extra.INSTANCE;
|
||||||
var windows = new ArrayList<Window>();
|
var windows = new ArrayList<Window>();
|
||||||
|
|
||||||
user32.EnumWindows(new WinUser.WNDENUMPROC() {
|
user32.EnumWindows((hwnd, pointer) -> {
|
||||||
@Override
|
var window = new Window(hwnd);
|
||||||
public boolean callback(WinDef.HWND hwnd, Pointer pointer) {
|
if(window.isInAltTabList()) windows.add(window);
|
||||||
var window = new Window(hwnd);
|
return true;
|
||||||
if(window.isInAltTabList()) windows.add(window);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}, null);
|
}, null);
|
||||||
|
|
||||||
return windows;
|
return windows;
|
||||||
|
@ -61,31 +58,26 @@ public class Window {
|
||||||
|
|
||||||
public static void onKey() {
|
public static void onKey() {
|
||||||
var user32 = User32Extra.INSTANCE;
|
var user32 = User32Extra.INSTANCE;
|
||||||
var kernel32 = Kernel32.INSTANCE;
|
|
||||||
var res = user32.SetWindowsHookEx(User32Extra.WH_KEYBOARD_LL,
|
var res = user32.SetWindowsHookEx(User32Extra.WH_KEYBOARD_LL,
|
||||||
new WinUser.HOOKPROC() {
|
new WinUser.HOOKPROC() {
|
||||||
public WinDef.LRESULT callback(
|
public WinDef.LRESULT callback(
|
||||||
int nCode, WinDef.WPARAM wparam, WinDef.LPARAM lparam
|
int nCode, WinDef.WPARAM wparam, WinDef.LPARAM lparam
|
||||||
) {
|
) {
|
||||||
|
new WinUser.KBDLLHOOKSTRUCT();
|
||||||
var kb =
|
var kb =
|
||||||
new WinUser.KBDLLHOOKSTRUCT().newInstance(WinUser.KBDLLHOOKSTRUCT.class,
|
Structure.newInstance(WinUser.KBDLLHOOKSTRUCT.class,
|
||||||
lparam.toPointer()
|
lparam.toPointer()
|
||||||
);
|
);
|
||||||
System.out.println(kb.vkCode);
|
System.out.println(kb.vkCode);
|
||||||
switch(wparam.intValue()) {
|
switch(wparam.intValue()) {
|
||||||
case User32Extra.WM_KEYDOWN:
|
case User32Extra.WM_KEYDOWN -> System.out.println(
|
||||||
|
"WM_KEYDOWN");
|
||||||
System.out.println("WM_KEYDOWN");
|
case User32Extra.WM_KEYUP -> System.out.println(
|
||||||
break;
|
"WM_KEYUP");
|
||||||
case User32Extra.WM_KEYUP:
|
case User32Extra.WM_SYSKEYDOWN -> System.out.println(
|
||||||
System.out.println("WM_KEYUP");
|
"WM_SYSKEYDOWN");
|
||||||
break;
|
case User32Extra.WM_SYSKEYUP -> System.out.println(
|
||||||
case User32Extra.WM_SYSKEYDOWN:
|
"WM_SYSKEYUP");
|
||||||
System.out.println("WM_SYSKEYDOWN");
|
|
||||||
break;
|
|
||||||
case User32Extra.WM_SYSKEYUP:
|
|
||||||
System.out.println("WM_SYSKEYUP");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
System.out.println("got some message a");
|
System.out.println("got some message a");
|
||||||
return user32.CallNextHookEx(null, nCode, wparam, lparam);
|
return user32.CallNextHookEx(null, nCode, wparam, lparam);
|
||||||
|
@ -108,7 +100,8 @@ public class Window {
|
||||||
var res = user32.SetWindowsHookEx(User32Extra.WH_SHELL,
|
var res = user32.SetWindowsHookEx(User32Extra.WH_SHELL,
|
||||||
new WinUser.HOOKPROC() {
|
new WinUser.HOOKPROC() {
|
||||||
public WinDef.LRESULT callback(
|
public WinDef.LRESULT callback(
|
||||||
int nCode, WinDef.WPARAM wparam, WinDef.LPARAM lparam
|
int nCode, WinDef.WPARAM ignoredWparam,
|
||||||
|
WinDef.LPARAM ignoredLparam
|
||||||
) {
|
) {
|
||||||
System.out.println("got some message b");
|
System.out.println("got some message b");
|
||||||
if(nCode == User32Extra.HSHELL_WINDOWCREATED) {
|
if(nCode == User32Extra.HSHELL_WINDOWCREATED) {
|
||||||
|
@ -226,7 +219,7 @@ public class Window {
|
||||||
if(!(o instanceof Window)) {
|
if(!(o instanceof Window)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ((Window) o).hwnd.equals(this.hwnd);
|
return ((Window) o).hwnd.equals(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
|
@ -238,7 +231,6 @@ public class Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExecutableName() {
|
public String getExecutableName() {
|
||||||
var user32 = User32Extra.INSTANCE;
|
|
||||||
var kernel32 = Kernel32.INSTANCE;
|
var kernel32 = Kernel32.INSTANCE;
|
||||||
var handle =
|
var handle =
|
||||||
kernel32.OpenProcess(WinNT.PROCESS_QUERY_LIMITED_INFORMATION,
|
kernel32.OpenProcess(WinNT.PROCESS_QUERY_LIMITED_INFORMATION,
|
||||||
|
@ -294,7 +286,6 @@ public class Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDwmCloaked() {
|
public boolean isDwmCloaked() {
|
||||||
var user32 = User32Extra.INSTANCE;
|
|
||||||
var dwm = Dwm.INSTANCE;
|
var dwm = Dwm.INSTANCE;
|
||||||
var out = new IntByReference();
|
var out = new IntByReference();
|
||||||
dwm.DwmGetWindowAttribute(hwnd,
|
dwm.DwmGetWindowAttribute(hwnd,
|
||||||
|
@ -313,7 +304,6 @@ public class Window {
|
||||||
public boolean isInAltTabList() {
|
public boolean isInAltTabList() {
|
||||||
var user32 = User32Extra.INSTANCE;
|
var user32 = User32Extra.INSTANCE;
|
||||||
var walk = user32.GetAncestor(hwnd, WinUser.GA_ROOTOWNER);
|
var walk = user32.GetAncestor(hwnd, WinUser.GA_ROOTOWNER);
|
||||||
WinDef.HWND test;
|
|
||||||
|
|
||||||
var window = new Window(hwnd);
|
var window = new Window(hwnd);
|
||||||
if(walk == null) return false;
|
if(walk == null) return false;
|
||||||
|
@ -362,17 +352,7 @@ public class Window {
|
||||||
rect.top = pos.getY() - top_shadow;
|
rect.top = pos.getY() - top_shadow;
|
||||||
rect.right = pos.getX() + size.getX() + right_shadow;
|
rect.right = pos.getX() + size.getX() + right_shadow;
|
||||||
rect.bottom = pos.getY() + size.getY() + bottom_shaddow;
|
rect.bottom = pos.getY() + size.getY() + bottom_shaddow;
|
||||||
//user32.AdjustWindowRect(rect, new WinDef.DWORD(WinUser
|
|
||||||
// .WS_OVERLAPPEDWINDOW), new WinDef.BOOL(false));
|
|
||||||
//var style = getStyle();
|
|
||||||
//var styleex = getStyleEx();
|
|
||||||
//style &= ~(User32Extra.WS_CAPTION | User32Extra.WS_MINIMIZEBOX |
|
|
||||||
// User32Extra.WS_SYSMENU);
|
|
||||||
//styleex &= ~(User32Extra.WS_EX_DLGMODALFRAME | User32Extra
|
|
||||||
// .WS_EX_CLIENTEDGE | User32Extra.WS_EX_STATICEDGE);
|
|
||||||
//style |= User32Extra.WS_POPUP;
|
|
||||||
//user32.AdjustWindowRectEx(rect, new WinDef.DWORD(style), new WinDef
|
|
||||||
// .BOOL(false), new WinDef.DWORD(styleex));
|
|
||||||
user32.MoveWindow(hwnd,
|
user32.MoveWindow(hwnd,
|
||||||
rect.left,
|
rect.left,
|
||||||
rect.top,
|
rect.top,
|
||||||
|
@ -380,8 +360,6 @@ public class Window {
|
||||||
rect.bottom - rect.top,
|
rect.bottom - rect.top,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
//user32.MoveWindow(hwnd, pos.getX(), pos.getY(), size.getX(), size
|
|
||||||
// .getY(), true);
|
|
||||||
|
|
||||||
user32.SetWindowPos(hwnd,
|
user32.SetWindowPos(hwnd,
|
||||||
null,
|
null,
|
||||||
|
@ -404,12 +382,10 @@ public class Window {
|
||||||
User32Extra.WS_THICKFRAME |
|
User32Extra.WS_THICKFRAME |
|
||||||
User32Extra.WS_MINIMIZEBOX |
|
User32Extra.WS_MINIMIZEBOX |
|
||||||
User32Extra.WS_SYSMENU;
|
User32Extra.WS_SYSMENU;
|
||||||
//var STYLES = User32Extra.WS_THICKFRAME | User32Extra.WS_MINIMIZEBOX
|
|
||||||
// | User32Extra.WS_SYSMENU;
|
|
||||||
var STYLESEX = User32Extra.WS_EX_DLGMODALFRAME |
|
var STYLESEX = User32Extra.WS_EX_DLGMODALFRAME |
|
||||||
User32Extra.WS_EX_CLIENTEDGE |
|
User32Extra.WS_EX_CLIENTEDGE |
|
||||||
User32Extra.WS_EX_STATICEDGE;
|
User32Extra.WS_EX_STATICEDGE;
|
||||||
//var STYLES = User32Extra.WS_POPUP;
|
|
||||||
|
|
||||||
var style = getStyle();
|
var style = getStyle();
|
||||||
var styleex = getStyleEx();
|
var styleex = getStyleEx();
|
||||||
|
|
Loading…
Reference in New Issue