From 1e08d0e77ebdc6a16c7f78bd91ff2ae32e589929 Mon Sep 17 00:00:00 2001 From: Constantin Geier Date: Fri, 12 Jun 2020 11:40:55 +0200 Subject: [PATCH] make intermediate render texture for distortion optional (will be migrated soon) --- app/src/main/cpp/GLRenderer/GLRStereoNormal.cpp | 15 +++++++++++---- app/src/main/cpp/GLRenderer/GLRStereoNormal.h | 6 ++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/cpp/GLRenderer/GLRStereoNormal.cpp b/app/src/main/cpp/GLRenderer/GLRStereoNormal.cpp index dd11e064..7e6b83b5 100644 --- a/app/src/main/cpp/GLRenderer/GLRStereoNormal.cpp +++ b/app/src/main/cpp/GLRenderer/GLRStereoNormal.cpp @@ -64,6 +64,7 @@ void GLRStereoNormal::onSurfaceCreated(JNIEnv * env,jobject androidContext,jobje Extensions2::init(); KHR_debug::enable(); // +#ifdef USE_INTERMEDIATE_DISTORTION GLHelper::checkGlError("onSurfaceCreated1"); mTextureRenderer=std::make_unique(false,&distortionManager); // Create render texture. @@ -86,6 +87,7 @@ void GLRStereoNormal::onSurfaceCreated(JNIEnv * env,jobject androidContext,jobje MLOGE<<"Framebuffer not complete "<updateAndDrawElementsGL(glm::mat4(1.0f), glm::perspective(80.0f,(GLfloat)RENDER_TEX_W/(GLfloat)RENDER_TEX_H,0.01f,1000.0f)); + vrHeadsetParams.updateDistortionManager(distortionManager); glFlush(); glBindFramebuffer(GL_FRAMEBUFFER,0); glClearColor(0,0,0,0); - +#endif if(checkAndResetVideoFormatChanged()){ placeGLElements(); } @@ -232,13 +237,15 @@ void GLRStereoNormal::drawEye(JNIEnv* env,gvr::Eye eye,bool updateOSDBetweenEyes //glBlendEquation(GL_FUNC_ADD); mVideoRenderer->drawVideoCanvas(viewVideo, projection, eye == GVR_LEFT_EYE); // new HA +#ifdef USE_INTERMEDIATE_DISTORTION mTextureRenderer->drawX(texture_,viewVideo,projection,mVideoRenderer->mVideoCanvasB); - - /*if (eye == GVR_LEFT_EYE || updateOSDBetweenEyes) { +#else + if (eye == GVR_LEFT_EYE || updateOSDBetweenEyes) { mOSDRenderer->updateAndDrawElementsGL(viewOSD, projection); } else { mOSDRenderer->drawElementsGL(viewOSD, projection); - }*/ + } +#endif //glBlendFunc(GL_DST_ALPHA, GL_SRC_ALPHA); //glBlendEquation(GL_FUNC_SUBTRACT); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/app/src/main/cpp/GLRenderer/GLRStereoNormal.h b/app/src/main/cpp/GLRenderer/GLRStereoNormal.h index f85a5498..fe04f450 100644 --- a/app/src/main/cpp/GLRenderer/GLRStereoNormal.h +++ b/app/src/main/cpp/GLRenderer/GLRStereoNormal.h @@ -25,6 +25,8 @@ #include #include +// #define USE_INTERMEDIATE_DISTORTION + class GLRStereoNormal : public IVideoFormatChanged { public: /** @@ -78,11 +80,11 @@ class GLRStereoNormal : public IVideoFormatChanged { // Doing so I can update the video texture between frames, reducing latency enum RENDERING_MODE{SUBMIT_FRAMES,SUBMIT_HALF_FRAMES}; const RENDERING_MODE mRenderingMode=SUBMIT_FRAMES; - +#ifdef USE_INTERMEDIATE_DISTORTION GLuint framebuffer_; // framebuffer object GLuint texture_; // distortion texture - const int RENDER_TEX_W=1280,RENDER_TEX_H=1440; +#endif };