Skip to content

Commit 1e08d0e

Browse files
author
Constantin Geier
committed
make intermediate render texture for distortion optional (will be migrated soon)
1 parent 3c947a8 commit 1e08d0e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

app/src/main/cpp/GLRenderer/GLRStereoNormal.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ void GLRStereoNormal::onSurfaceCreated(JNIEnv * env,jobject androidContext,jobje
6464
Extensions2::init();
6565
KHR_debug::enable();
6666
//
67+
#ifdef USE_INTERMEDIATE_DISTORTION
6768
GLHelper::checkGlError("onSurfaceCreated1");
6869
mTextureRenderer=std::make_unique<GLProgramTexture>(false,&distortionManager);
6970
// Create render texture.
@@ -86,6 +87,7 @@ void GLRStereoNormal::onSurfaceCreated(JNIEnv * env,jobject androidContext,jobje
8687
MLOGE<<"Framebuffer not complete "<<status;
8788
}
8889
glBindFramebuffer(GL_FRAMEBUFFER,0);
90+
#endif
8991
GLHelper::checkGlError("onSurfaceCreated2");
9092
}
9193

@@ -146,16 +148,19 @@ void GLRStereoNormal::onDrawFrame(JNIEnv* env) {
146148
#ifdef CHANGE_SWAP_COLOR
147149
GLHelper::updateSetClearColor(swapColor);
148150
#endif
151+
#ifdef USE_INTERMEDIATE_DISTORTION
149152
glBindFramebuffer(GL_FRAMEBUFFER,framebuffer_);
150153
glClearColor(1,0,0,0.5f);
151154
glScissor(0,0,RENDER_TEX_W,RENDER_TEX_H);
152155
glViewport(0,0,RENDER_TEX_W,RENDER_TEX_H);
153156
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
157+
distortionManager.updateDistortionWithIdentity();
154158
mOSDRenderer->updateAndDrawElementsGL(glm::mat4(1.0f), glm::perspective(80.0f,(GLfloat)RENDER_TEX_W/(GLfloat)RENDER_TEX_H,0.01f,1000.0f));
159+
vrHeadsetParams.updateDistortionManager(distortionManager);
155160
glFlush();
156161
glBindFramebuffer(GL_FRAMEBUFFER,0);
157162
glClearColor(0,0,0,0);
158-
163+
#endif
159164
if(checkAndResetVideoFormatChanged()){
160165
placeGLElements();
161166
}
@@ -232,13 +237,15 @@ void GLRStereoNormal::drawEye(JNIEnv* env,gvr::Eye eye,bool updateOSDBetweenEyes
232237
//glBlendEquation(GL_FUNC_ADD);
233238
mVideoRenderer->drawVideoCanvas(viewVideo, projection, eye == GVR_LEFT_EYE);
234239
// new HA
240+
#ifdef USE_INTERMEDIATE_DISTORTION
235241
mTextureRenderer->drawX(texture_,viewVideo,projection,mVideoRenderer->mVideoCanvasB);
236-
237-
/*if (eye == GVR_LEFT_EYE || updateOSDBetweenEyes) {
242+
#else
243+
if (eye == GVR_LEFT_EYE || updateOSDBetweenEyes) {
238244
mOSDRenderer->updateAndDrawElementsGL(viewOSD, projection);
239245
} else {
240246
mOSDRenderer->drawElementsGL(viewOSD, projection);
241-
}*/
247+
}
248+
#endif
242249
//glBlendFunc(GL_DST_ALPHA, GL_SRC_ALPHA);
243250
//glBlendEquation(GL_FUNC_SUBTRACT);
244251
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

app/src/main/cpp/GLRenderer/GLRStereoNormal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <Extensions.hpp>
2626
#include <queue>
2727

28+
// #define USE_INTERMEDIATE_DISTORTION
29+
2830
class GLRStereoNormal : public IVideoFormatChanged {
2931
public:
3032
/**
@@ -78,11 +80,11 @@ class GLRStereoNormal : public IVideoFormatChanged {
7880
// Doing so I can update the video texture between frames, reducing latency
7981
enum RENDERING_MODE{SUBMIT_FRAMES,SUBMIT_HALF_FRAMES};
8082
const RENDERING_MODE mRenderingMode=SUBMIT_FRAMES;
81-
83+
#ifdef USE_INTERMEDIATE_DISTORTION
8284
GLuint framebuffer_; // framebuffer object
8385
GLuint texture_; // distortion texture
84-
8586
const int RENDER_TEX_W=1280,RENDER_TEX_H=1440;
87+
#endif
8688
};
8789

8890

0 commit comments

Comments
 (0)