我正在开发一个Android Unity插件,允许用户记录他/她的游戏玩法
我的解决方案概述:
我的问题是表现虽然录音不好.三星Galaxy S4的FPS从60降至40.我试图记录渲染操作的执行时间,并认识到影响最大的性能操作是使视频表面当前操作和交换缓冲区从视频表面到默认窗口操作.以下是他们的代码
public void makeCurrent()
{
if (!EGL14.eglMakeCurrent(this.mEGLDisplay, this.mEGLSurface, this.mEGLSurface, this.mEGLContext))
throw new RuntimeException("eglMakeCurrent failed");
}
public boolean swapBuffers()
{
return EGL14.eglSwapBuffers(this.mEGLDisplay, this.mEGLSurface);
}
Run Code Online (Sandbox Code Playgroud)
执行当前操作的执行时间为1~18 ms
交换缓冲区操作的执行时间为4~14 ms
其他操作的执行时间通常为0~1 ms
如何提高这些操作的性能?
任何帮助将不胜感激!
android opengl-es unity-game-engine opengl-es-2.0 android-mediarecorder
我正在开发一个Unity-Android插件来记录游戏画面并创建一个mp4视频文件.我在这个网站上关注Android Breakout游戏记录器补丁示例:http://bigflake.com/mediacodec/ .
首先,我创建了我的CustomUnityPlayer类,它扩展了UnityPlayer类并覆盖onDrawFrame方法.这是我的CustomUnityPlayer类代码:
package com.example.screenrecorder;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.content.ContextWrapper;
import android.opengl.EGL14;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import android.util.Log;
import com.unity3d.player.*;
public class CustomUnityPlayer extends UnityPlayer implements GLSurfaceView.Renderer {
public static final String TAG = "ScreenRecord";
public static final boolean EXTRA_CHECK = true; // enable additional assertions
private GameRecorder recorder;
static final float mProjectionMatrix[] = new float[16];
private final float mSavedMatrix[] = new float[16];
private EGLDisplay mSavedEglDisplay;
private EGLSurface …Run Code Online (Sandbox Code Playgroud) android opengl-es unity-game-engine screen-recording mediacodec
我正在开发记录 Unity 游戏画面的 Android 插件。为此,我使用了 OpenGL FBO。伪代码非常简单,如下所示:
// Bind frame buffer as a render target
mFrameBuffer.bind();
// Render scene to frame buffer
renderScene();
// Restore rendering target, unbind FBO
mFrameBuffer.unbind();
// Draw texture into display
mTexture.draw(mFrameBuffer.getTexture());
// Make video surface a rendering target
videoCapture.captureFrame(mFrameBuffer.getTexture());
Run Code Online (Sandbox Code Playgroud)
输出视频没问题,但是在使用从 FBO 获得的屏幕外纹理渲染到窗口显示时遇到了问题。我检查了我的代码并认识到对 glDrawArray 的调用失败并显示 GL_INVALID_OPERATION 错误代码
。
我的渲染代码
public void draw(int textureId) {
this.shader.use();
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
Log.getPossibleGLError("active texture0");
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
Log.getPossibleGLError("bind texture when redraw");
int uOrientationM = this.shader.getAttributeLocation("uOrientationM");
Log.getPossibleGLError("get orientation matrix");
int uTransformM = this.shader.getAttributeLocation("uTransformM");
Log.getPossibleGLError("get …Run Code Online (Sandbox Code Playgroud)