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); }