Skip to content

Commit

Permalink
boop
Browse files Browse the repository at this point in the history
  • Loading branch information
jakedowns committed Jan 17, 2024
1 parent 3fb4d5c commit 1813076
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ import org.citra.citra_emu.utils.GameIconUtils
import org.citra.citra_emu.utils.EmulationLifecycleUtil
import org.citra.citra_emu.utils.Log
import org.citra.citra_emu.utils.ViewUtils
import org.citra.citra_emu.vendor.simongellis.leia.webxr.LeiaSurfaceView
import org.citra.citra_emu.viewmodel.EmulationViewModel

class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.FrameCallback {
Expand Down Expand Up @@ -866,7 +865,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram

override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
Log.debug("[EmulationFragment] Surface changed. Resolution: " + width + "x" + height)
emulationState.newSurface(binding.surfaceEmulation.holder.surface)
emulationState.newSurface(holder.surface)
}

override fun surfaceDestroyed(holder: SurfaceHolder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package org.citra.citra_emu.vendor.simongellis.leia.webxr
import android.content.Context
import android.graphics.SurfaceTexture
import android.util.AttributeSet
import android.util.Log
import com.leia.sdk.views.InputViewsAsset
import com.leia.sdk.views.InterlacedSurfaceView

open class LeiaSurfaceView(context: Context, attrs: AttributeSet) : InterlacedSurfaceView(context, attrs) {
class LeiaSurfaceView(context: Context, attrs: AttributeSet) : InterlacedSurfaceView(context, attrs) {
private val textureRenderer = LeiaTextureRenderer()
private val asset = InputViewsAsset(RendererImpl(textureRenderer))

init {
Log.i("LeiaSurfaceView", "init")
setViewAsset(asset)
}

Expand Down
6 changes: 3 additions & 3 deletions src/android/app/src/main/jni/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ bg_blue =
bg_green =
# Whether and how Stereoscopic 3D should be rendered
# 0 (default): Off, 1: Side by Side, 2: Anaglyph, 3: Interlaced, 4: Reverse Interlaced, 5: Cardboard VR
render_3d =
# 0 (default): Off, 1: Side by Side, 2: Anaglyph, 3: Interlaced, 4: Reverse Interlaced, 5: Cardboard VR, 6: Lumepad 1, 7: Lumepad 2
render_3d = 7
# Change 3D Intensity
# 0 - 100: Intensity. 0 (default)
factor_3d =
factor_3d = 50
# The name of the post processing shader to apply.
# Loaded from shaders if render_3d is off or side by side.
Expand Down
6 changes: 5 additions & 1 deletion src/android/app/src/main/jni/emu_window/emu_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ EmuWindow_Android::~EmuWindow_Android() {
}

void EmuWindow_Android::MakeCurrent() {
core_context->MakeCurrent();
try {
core_context->MakeCurrent();
} catch (const std::exception& e) {
LOG_DEBUG(Frontend, "Exception caught in MakeCurrent: {}", e.what());
}
}

void EmuWindow_Android::DoneCurrent() {
Expand Down
24 changes: 16 additions & 8 deletions src/android/app/src/main/jni/emu_window/emu_window_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class SharedContext_Android : public Frontend::GraphicsContext {
EmuWindow_Android_OpenGL::EmuWindow_Android_OpenGL(Core::System& system_, ANativeWindow* surface)
: EmuWindow_Android{surface}, system{system_} {
if (egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); egl_display == EGL_NO_DISPLAY) {
LOG_CRITICAL(Frontend, "eglGetDisplay() failed");
LOG_CRITICAL(Frontend, "eglGetDisplay() failed 1");
return;
}
if (eglInitialize(egl_display, 0, 0) != EGL_TRUE) {
LOG_CRITICAL(Frontend, "eglInitialize() failed");
LOG_CRITICAL(Frontend, "eglInitialize() failed 2");
return;
}
if (EGLint egl_num_configs{}; eglChooseConfig(egl_display, egl_attribs.data(), &egl_config, 1,
Expand All @@ -99,12 +99,12 @@ EmuWindow_Android_OpenGL::EmuWindow_Android_OpenGL(Core::System& system_, ANativ

if (egl_context = eglCreateContext(egl_display, egl_config, 0, egl_context_attribs.data());
egl_context == EGL_NO_CONTEXT) {
LOG_CRITICAL(Frontend, "eglCreateContext() failed");
LOG_CRITICAL(Frontend, "eglCreateContext() failed a");
return;
}
if (eglSurfaceAttrib(egl_display, egl_surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED) !=
EGL_TRUE) {
LOG_CRITICAL(Frontend, "eglSurfaceAttrib() failed");
LOG_CRITICAL(Frontend, "eglSurfaceAttrib() failed b");
return;
}
if (core_context = CreateSharedContext(); !core_context) {
Expand Down Expand Up @@ -136,12 +136,20 @@ bool EmuWindow_Android_OpenGL::CreateWindowSurface() {
eglGetConfigAttrib(egl_display, egl_config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(host_window, 0, 0, format);

if (egl_surface = eglCreateWindowSurface(egl_display, egl_config, host_window, 0);
egl_surface == EGL_NO_SURFACE) {
return {};
// Check if a surface already exists and destroy it
if (egl_surface != EGL_NO_SURFACE) {
eglDestroySurface(egl_display, egl_surface);
}

return egl_surface;
egl_surface = eglCreateWindowSurface(egl_display, egl_config, host_window, nullptr);

if (egl_surface == EGL_NO_SURFACE) {
EGLint error = eglGetError(); // Get the error code
LOG_CRITICAL(Frontend, "EmuWindow_Android_OpenGL eglCreateWindowSurface() returned error {}", error);
return true;
}

return true;
}

void EmuWindow_Android_OpenGL::DestroyWindowSurface() {
Expand Down
5 changes: 4 additions & 1 deletion src/android/app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
<item>@string/interlaced</item>
<item>@string/reverse_interlaced</item>
<item>@string/cardboard_vr</item>
<item>@string/lumepad_1</item>
<item>@string/lumepad_2</item>
</string-array>

<integer-array name="render3dValues">
Expand All @@ -150,6 +152,8 @@
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
</integer-array>

<string-array name="graphicsApiNames">
Expand Down Expand Up @@ -450,5 +454,4 @@
<item>11</item>
<item>12</item>
</integer-array>

</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@
<string name="factor3d">Depth</string>
<string name="factor3d_description">Specifies the value of the 3D slider. This should be set to higher than 0% when Stereoscopic 3D is enabled.</string>
<string name="cardboard_vr">Cardboard VR</string>
<string name="lumepad_2">Lumepad 2 / Nubia Pad 3D</string>
<string name="lumepad_1">Lumepad 1</string>
<string name="cardboard_screen_size">Cardboard Screen Size</string>
<string name="cardboard_screen_size_description">Scales the screen to a percentage of its original size.</string>
<string name="cardboard_x_shift">Horizontal Shift</string>
Expand Down

0 comments on commit 1813076

Please sign in to comment.