mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-06-17 21:48:32 -04:00
fix(SDLSurface): Return native window from MinecraftGLSurface
We can't have SDLSurface using its own native surface if a mod wants to use SDL for outputting the rendered window (LWJGL3ify)
This commit is contained in:
@@ -84,6 +84,7 @@ public class MinecraftGLSurface extends View implements GrabListener, DirectGame
|
||||
final Object mSurfaceReadyListenerLock = new Object();
|
||||
/* View holding the surface, either a SurfaceView or a TextureView */
|
||||
View mSurface;
|
||||
Surface mNativeSurface;
|
||||
String TAG = "MinecraftGLSurface";
|
||||
|
||||
private final InGameEventProcessor mIngameProcessor = new InGameEventProcessor(mSensitivityFactor);
|
||||
@@ -127,18 +128,19 @@ public class MinecraftGLSurface extends View implements GrabListener, DirectGame
|
||||
if(useSurfaceView){
|
||||
SurfaceView surfaceView = new SurfaceView(getContext());
|
||||
mSurface = surfaceView;
|
||||
mNativeSurface = surfaceView.getHolder().getSurface();
|
||||
|
||||
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
|
||||
private boolean isCalled = isAlreadyRunning;
|
||||
@Override
|
||||
public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
||||
if(isCalled) {
|
||||
JREUtils.setupBridgeWindow(surfaceView.getHolder().getSurface());
|
||||
JREUtils.setupBridgeWindow(mNativeSurface);
|
||||
return;
|
||||
}
|
||||
isCalled = true;
|
||||
|
||||
realStart(surfaceView.getHolder().getSurface());
|
||||
realStart(mNativeSurface);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,14 +171,14 @@ public class MinecraftGLSurface extends View implements GrabListener, DirectGame
|
||||
private boolean isCalled = isAlreadyRunning;
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surface, int width, int height) {
|
||||
Surface tSurface = new Surface(surface);
|
||||
mNativeSurface = new Surface(surface);
|
||||
if(isCalled) {
|
||||
JREUtils.setupBridgeWindow(tSurface);
|
||||
JREUtils.setupBridgeWindow(mNativeSurface);
|
||||
return;
|
||||
}
|
||||
isCalled = true;
|
||||
|
||||
realStart(tSurface);
|
||||
realStart(mNativeSurface);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,6 +52,7 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
|
||||
// Pinch events
|
||||
private final ScaleGestureDetector scaleGestureDetector;
|
||||
static Surface mNativeSurface;
|
||||
|
||||
// Startup
|
||||
public SDLSurface(Context context) {
|
||||
@@ -93,8 +94,12 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
enableSensor(Sensor.TYPE_ACCELEROMETER, true);
|
||||
}
|
||||
|
||||
protected Surface getNativeSurface() {
|
||||
return getHolder().getSurface();
|
||||
public static Surface getNativeSurface() {
|
||||
return mNativeSurface;
|
||||
}
|
||||
|
||||
public static void setNativeSurface(Surface nativeSurface) {
|
||||
mNativeSurface = nativeSurface;
|
||||
}
|
||||
|
||||
// Called when we have a valid drawing surface
|
||||
|
||||
Reference in New Issue
Block a user