Skip to content

Commit

Permalink
Fix AndroidGraphics2D dalvikvm
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduytran0 committed Aug 11, 2020
1 parent 1439477 commit 54433fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import android.view.Display;
import android.view.WindowManager;
import android.content.Context;
import org.lwjgl.opengl.*;

public class AndroidGraphics2D extends Graphics2D {

Expand Down Expand Up @@ -120,7 +121,7 @@ public static AndroidGraphics2D getInstance() {
}

public static AndroidGraphics2D getInstance(Context ctx, Canvas c, Paint p) {
if (c == null || ctx == null) {
if (c == null /* || ctx == null */) {
throw new RuntimeException(
"Illegal argument, Canvas cannot be null!");
}
Expand All @@ -143,7 +144,10 @@ private AndroidGraphics2D(Context ctx, Canvas c, Paint p) {
Display d = wm.getDefaultDisplay();
displayWidth = d.getWidth();
displayHeight = d.getHeight();
}
} else {
displayWidth = AndroidDisplay.windowWidth;
displayHeight = AndroidDisplay.windowHeight;
}
blitter = new AndroidJavaBlitter(c);
cm = new DirectColorModel(32, 0xff0000, 0xff00, 0xff, 0xff000000);
sm = new SinglePixelPackedSampleModel(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package com.kdt.minecraftegl;

import android.app.*;
import android.content.*;
import android.graphics.*;
import android.os.*;
import android.system.*;
import com.android.internal.awt.*;
import dalvik.system.*;
import java.lang.reflect.*;
import java.util.*;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.*;
import net.kdt.pojavlaunch.*;
import net.kdt.pojavlaunch.exit.*;
import org.lwjgl.opengl.*;

import static org.lwjgl.opengl.AndroidContextImplementation.*;
import android.content.pm.*;
import org.lwjgl.opengl.*;
import javax.microedition.khronos.opengles.*;
import android.util.*;

public class MinecraftEGLInitializer
{
Expand All @@ -42,6 +40,8 @@ private static void runOnThread(final String[] args) {
ExitManager.disableSystemExit();
Thread.sleep(200);
// System.out.println(Arrays.toString(args));

MainActivity.fixRSAPadding(null);

long lSurfaceTexture = Long.parseLong(args[0]);
long lProducer = Long.parseLong(args[1]);
Expand All @@ -50,6 +50,9 @@ private static void runOnThread(final String[] args) {
AndroidDisplay.windowWidth = Integer.parseInt(args[3]);
AndroidDisplay.windowHeight = Integer.parseInt(args[4]);

Bitmap awtGraphics = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
AndroidGraphics2D.getInstance(null, new Canvas(awtGraphics), null);

GLTextureView gtv = new GLTextureView(lSurfaceTexture, lProducer, lFrameAvailableListener);
gtv.setRenderer(new GLTextureView.Renderer() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ public class SurfaceTextureView
private SurfaceTextureListener mListener;
private boolean isTextureAvailable = false;
public SurfaceTextureView(long lSurfaceTexture, long lProducer, long lFrameAvailableListener) {
mSurfaceTexture = new SurfaceTexture(false);
/*
mSurfaceTexture = new SurfaceTexture(true);

try {
Tools.findField(mSurfaceTexture, "mSurfaceTexture").set(mSurfaceTexture, lSurfaceTexture);
Tools.findField(mSurfaceTexture, "mProducer").set(mSurfaceTexture, lProducer);
// Tools.findField(mSurfaceTexture, "mProducer").set(mSurfaceTexture, lProducer);
Tools.findField(mSurfaceTexture, "mFrameAvailableListener").set(mSurfaceTexture, lFrameAvailableListener);
} catch (Throwable th) {
throw new RuntimeException(th);
}
*/
}

public SurfaceTexture getSurfaceTexture() {
Expand Down

0 comments on commit 54433fa

Please sign in to comment.