summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/TextureSurface.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/TextureSurface.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/TextureSurface.java')
-rw-r--r--NET/worlds/scape/TextureSurface.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/NET/worlds/scape/TextureSurface.java b/NET/worlds/scape/TextureSurface.java
new file mode 100644
index 0000000..abdd240
--- /dev/null
+++ b/NET/worlds/scape/TextureSurface.java
@@ -0,0 +1,85 @@
+package NET.worlds.scape;
+
+public class TextureSurface {
+ private Texture[] _textures;
+ private int _hwnd;
+ private int _oldObject;
+ private int _offscreen;
+ private int _texWidth;
+ private int _texHeight;
+ private int _width;
+ private int _height;
+ private int _rows;
+ private int _cols;
+
+ public TextureSurface(Texture[] texList, int rows, int w, int h) {
+ this._width = w;
+ this._height = h;
+ this._oldObject = 0;
+ this._hwnd = this.nativeInit(w, h);
+ this._offscreen = this.nativeMakeDC(this._hwnd, w, h);
+ if (texList != null) {
+ this.setTextures(texList, rows);
+ }
+ }
+
+ @Override
+ public void finalize() {
+ this.nativeDestroyDC(this._offscreen);
+ this._oldObject = 0;
+ }
+
+ public void setTextures(Texture[] texList, int rows) {
+ this._textures = texList;
+ this._rows = rows;
+ this._cols = texList.length / rows;
+ this._texWidth = this._width / this._cols;
+ this._texHeight = this._height / this._rows;
+ }
+
+ public synchronized boolean draw(TextureSurfaceRenderer renderer) {
+ renderer.renderTo(this._offscreen);
+ int idx = 0;
+
+ for (int row = this._rows - 1; row >= 0; row--) {
+ for (int col = 0; col < this._cols; col++) {
+ if (this._textures[idx] != null) {
+ this._textures[idx]
+ .copyFrom(this._offscreen, col * this._texWidth, (col + 1) * this._texWidth, row * this._texHeight, (row + 1) * this._texHeight);
+ }
+
+ idx++;
+ }
+ }
+
+ return false;
+ }
+
+ public void sendLeftClick(int x, int y) {
+ this.nativeLeftClick(this._hwnd, x, y);
+ }
+
+ public int getHwnd() {
+ return this._hwnd;
+ }
+
+ public int getWidth() {
+ return this._width;
+ }
+
+ public int getHeight() {
+ return this._height;
+ }
+
+ private native int nativeInit(int var1, int var2);
+
+ private native int nativeMakeDC(int var1, int var2, int var3);
+
+ private native int nativeGetDC(int var1);
+
+ private native void nativeReleaseDC(int var1, int var2);
+
+ private native void nativeDestroyDC(int var1);
+
+ private native void nativeLeftClick(int var1, int var2, int var3);
+}