mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-08-08 09:08:43 +00:00
fx
This commit is contained in:
parent
61935cdd6e
commit
113e825898
1 changed files with 37 additions and 34 deletions
|
@ -3,6 +3,7 @@ package com.panda3ds.pandroid.view;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
|
import android.view.SurfaceHolder;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.panda3ds.pandroid.math.Vector2;
|
import com.panda3ds.pandroid.math.Vector2;
|
||||||
|
@ -11,49 +12,51 @@ import com.panda3ds.pandroid.view.controller.nodes.TouchScreenNodeImpl;
|
||||||
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
||||||
|
|
||||||
public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNodeImpl {
|
public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNodeImpl {
|
||||||
final PandaGlRenderer renderer;
|
final PandaGlRenderer renderer;
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
public PandaGlSurfaceView(Context context, String romPath) {
|
public PandaGlSurfaceView(Context context, String romPath) {
|
||||||
super(context);
|
super(context);
|
||||||
setEGLContextClientVersion(3);
|
setEGLContextClientVersion(3);
|
||||||
if (Debug.isDebuggerConnected()) {
|
if (Debug.isDebuggerConnected()) {
|
||||||
setDebugFlags(DEBUG_LOG_GL_CALLS);
|
setDebugFlags(DEBUG_LOG_GL_CALLS);
|
||||||
}
|
}
|
||||||
renderer = new PandaGlRenderer(romPath, context.getResources()); // pass resources if needed
|
renderer = new PandaGlRenderer(romPath, context.getResources()); // pass resources if needed
|
||||||
setRenderer(renderer);
|
setRenderer(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConsoleRenderer getRenderer() { return renderer; }
|
public ConsoleRenderer getRenderer() {
|
||||||
|
return renderer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
width = getMeasuredWidth();
|
width = getMeasuredWidth();
|
||||||
height = getMeasuredHeight();
|
height = getMeasuredHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Vector2 getSize() {
|
public Vector2 getSize() {
|
||||||
return new Vector2(width, height);
|
return new Vector2(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTouch(TouchEvent event) {
|
public void onTouch(TouchEvent event) {
|
||||||
onTouchScreenPress(renderer, event);
|
onTouchScreenPress(renderer, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
super.onSurfaceChanged(holder, format, width, height);
|
super.onSurfaceChanged(holder, format, width, height);
|
||||||
// Update the dimensions in the renderer when the surface changes
|
// Update the dimensions in the renderer when the surface changes
|
||||||
renderer.onSurfaceChanged(newWidth, newHeight);
|
renderer.onSurfaceChanged(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSurfaceDestroyed(SurfaceHolder holder) {
|
public void onSurfaceDestroyed(SurfaceHolder holder) {
|
||||||
super.onSurfaceDestroyed(holder);
|
super.onSurfaceDestroyed(holder);
|
||||||
// Release resources from the renderer when the surface is destroyed
|
// Release resources from the renderer when the surface is destroyed
|
||||||
renderer.releaseResources();
|
renderer.releaseResources();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue