WE HAVE A POINTER

Turns out there IS pointer handling in the library, only the wrapper generator isn't prepared for pointers
In the end, all I did was editing the generated source file from byte[] to long[]
This commit is contained in:
Norbi Peti 2018-09-21 00:43:50 +02:00
parent 5dd5546dc1
commit 2ccf1d976e
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 24 additions and 22 deletions

Binary file not shown.

View file

@ -97,22 +97,27 @@ public class MCFrameBuffer implements IFramebuffer {
* return; // Don't even try to render too large resolutions } * return; // Don't even try to render too large resolutions }
*/ */
tt = Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, () -> { tt = Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, () -> {
display.querySourceBitmap(0L, holder); try {
byte[] arr = PluginMain.allpixels.array(); display.querySourceBitmap(0L, holder);
long[] w = new long[1], h = new long[1], bpp = new long[1], bpl = new long[1], pf = new long[1]; //byte[] arr = PluginMain.allpixels.array();
holder.value.getTypedWrapped().queryBitmapInfo(arr, w, h, bpp, bpl, pf); long[] arr = new long[1];
System.out.println("Arr0:" + arr[0]); long[] w = new long[1], h = new long[1], bpp = new long[1], bpl = new long[1], pf = new long[1];
System.out.println("whbppbplpf: " + w[0] + " " + h[0] + " " + bpp[0] + " " + bpl[0] + " " + pf[0]); holder.value.getTypedWrapped().queryBitmapInfo(arr, w, h, bpp, bpl, pf);
if (width * height > 640 * 480) System.out.println("Arr0:" + arr[0]);
PluginMain.allpixels.limit(640 * 480 * 4); System.out.println("whbppbplpf: " + w[0] + " " + h[0] + " " + bpp[0] + " " + bpl[0] + " " + pf[0]);
else if (width * height > 640 * 480)
PluginMain.allpixels.limit((int) (width * height * 4)); PluginMain.allpixels.limit(640 * 480 * 4);
for (IRenderer r : PluginMain.renderers) else
if (r instanceof BukkitRenderer) PluginMain.allpixels.limit((int) (width * height * 4));
((BukkitRenderer) r).setAllPixels(PluginMain.allpixels); for (IRenderer r : PluginMain.renderers)
else if (r instanceof DirectRenderer) if (r instanceof BukkitRenderer)
((DirectRenderer) r).render(PluginMain.allpixels, xOrigin, yOrigin, width, height); ((BukkitRenderer) r).setAllPixels(PluginMain.allpixels);
System.out.println("Change!"); else if (r instanceof DirectRenderer)
((DirectRenderer) r).render(PluginMain.allpixels, xOrigin, yOrigin, width, height);
System.out.println("Change!");
} catch (Throwable t) {
t.printStackTrace();
}
}, 5); // Wait 1/4th of a second }, 5); // Wait 1/4th of a second
} }
@ -126,7 +131,6 @@ public class MCFrameBuffer implements IFramebuffer {
((DirectRenderer) r).render(PluginMain.allpixels, x, y, width, height); ((DirectRenderer) r).render(PluginMain.allpixels, x, y, width, height);
System.out.println("Update!"); System.out.println("Update!");
}, 5);*/ }, 5);*/
throw new UnsupportedOperationException("Use UpdateImage");
} }
@Override @Override
@ -135,11 +139,11 @@ public class MCFrameBuffer implements IFramebuffer {
} }
@Override @Override
public void processVHWACommand(byte arg0) { public void setVisibleRegion(byte arg0, long arg1) {
} }
@Override @Override
public void setVisibleRegion(byte arg0, long arg1) { public void processVHWACommand(byte b, int i, boolean b1) {
} }
@Override @Override

View file

@ -1,7 +1,6 @@
package sznp.virtualcomputer; package sznp.virtualcomputer;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sun.jna.Memory;
import com.sun.jna.Pointer; import com.sun.jna.Pointer;
import jnr.ffi.LibraryLoader; import jnr.ffi.LibraryLoader;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -10,7 +9,6 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.virtualbox_5_2.*; import org.virtualbox_5_2.*;
import sun.misc.Unsafe;
import java.io.File; import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -115,7 +113,7 @@ public class PluginMain extends JavaPlugin {
screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(PluginMain.this, () -> { screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(PluginMain.this, () -> {
if (session.getState().equals(SessionState.Locked) // Don't run until the machine is running if (session.getState().equals(SessionState.Locked) // Don't run until the machine is running
&& console.getState().equals(MachineState.Running)) && console.getState().equals(MachineState.Running))
console.getDi splay().invalidateAndUpdateScreen(0L); console.getDisplay().invalidateAndUpdateScreen(0L);
if (session.getState().equals(SessionState.Unlocked) // Stop if the machine stopped fully if (session.getState().equals(SessionState.Unlocked) // Stop if the machine stopped fully
|| console.getState().equals(MachineState.PoweredOff) || console.getState().equals(MachineState.PoweredOff)
|| console.getState().equals(MachineState.Saved)) { || console.getState().equals(MachineState.Saved)) {