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:
parent
5dd5546dc1
commit
2ccf1d976e
3 changed files with 24 additions and 22 deletions
BIN
VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.jar
Executable file → Normal file
BIN
VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.jar
Executable file → Normal file
Binary file not shown.
|
@ -97,22 +97,27 @@ public class MCFrameBuffer implements IFramebuffer {
|
|||
* return; // Don't even try to render too large resolutions }
|
||||
*/
|
||||
tt = Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, () -> {
|
||||
display.querySourceBitmap(0L, holder);
|
||||
byte[] arr = PluginMain.allpixels.array();
|
||||
long[] w = new long[1], h = new long[1], bpp = new long[1], bpl = new long[1], pf = new long[1];
|
||||
holder.value.getTypedWrapped().queryBitmapInfo(arr, w, h, bpp, bpl, pf);
|
||||
System.out.println("Arr0:" + arr[0]);
|
||||
System.out.println("whbppbplpf: " + w[0] + " " + h[0] + " " + bpp[0] + " " + bpl[0] + " " + pf[0]);
|
||||
if (width * height > 640 * 480)
|
||||
PluginMain.allpixels.limit(640 * 480 * 4);
|
||||
else
|
||||
PluginMain.allpixels.limit((int) (width * height * 4));
|
||||
for (IRenderer r : PluginMain.renderers)
|
||||
if (r instanceof BukkitRenderer)
|
||||
((BukkitRenderer) r).setAllPixels(PluginMain.allpixels);
|
||||
else if (r instanceof DirectRenderer)
|
||||
((DirectRenderer) r).render(PluginMain.allpixels, xOrigin, yOrigin, width, height);
|
||||
System.out.println("Change!");
|
||||
try {
|
||||
display.querySourceBitmap(0L, holder);
|
||||
//byte[] arr = PluginMain.allpixels.array();
|
||||
long[] arr = new long[1];
|
||||
long[] w = new long[1], h = new long[1], bpp = new long[1], bpl = new long[1], pf = new long[1];
|
||||
holder.value.getTypedWrapped().queryBitmapInfo(arr, w, h, bpp, bpl, pf);
|
||||
System.out.println("Arr0:" + arr[0]);
|
||||
System.out.println("whbppbplpf: " + w[0] + " " + h[0] + " " + bpp[0] + " " + bpl[0] + " " + pf[0]);
|
||||
if (width * height > 640 * 480)
|
||||
PluginMain.allpixels.limit(640 * 480 * 4);
|
||||
else
|
||||
PluginMain.allpixels.limit((int) (width * height * 4));
|
||||
for (IRenderer r : PluginMain.renderers)
|
||||
if (r instanceof BukkitRenderer)
|
||||
((BukkitRenderer) r).setAllPixels(PluginMain.allpixels);
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -126,7 +131,6 @@ public class MCFrameBuffer implements IFramebuffer {
|
|||
((DirectRenderer) r).render(PluginMain.allpixels, x, y, width, height);
|
||||
System.out.println("Update!");
|
||||
}, 5);*/
|
||||
throw new UnsupportedOperationException("Use UpdateImage");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,11 +139,11 @@ public class MCFrameBuffer implements IFramebuffer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void processVHWACommand(byte arg0) {
|
||||
public void setVisibleRegion(byte arg0, long arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleRegion(byte arg0, long arg1) {
|
||||
public void processVHWACommand(byte b, int i, boolean b1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Pointer;
|
||||
import jnr.ffi.LibraryLoader;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -10,7 +9,6 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.virtualbox_5_2.*;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -115,7 +113,7 @@ public class PluginMain extends JavaPlugin {
|
|||
screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(PluginMain.this, () -> {
|
||||
if (session.getState().equals(SessionState.Locked) // Don't run until the machine is 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
|
||||
|| console.getState().equals(MachineState.PoweredOff)
|
||||
|| console.getState().equals(MachineState.Saved)) {
|
||||
|
|
Loading…
Reference in a new issue