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