Skip to content

Commit

Permalink
make intermediate render texture for distortion optional (will be mig…
Browse files Browse the repository at this point in the history
…rated soon)
  • Loading branch information
Constantin Geier committed Jun 12, 2020
1 parent 3c947a8 commit 1e08d0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 11 additions & 4 deletions app/src/main/cpp/GLRenderer/GLRStereoNormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GLProgramTexture>(false,&distortionManager);
// Create render texture.
Expand All @@ -86,6 +87,7 @@ void GLRStereoNormal::onSurfaceCreated(JNIEnv * env,jobject androidContext,jobje
MLOGE<<"Framebuffer not complete "<<status;
}
glBindFramebuffer(GL_FRAMEBUFFER,0);
#endif
GLHelper::checkGlError("onSurfaceCreated2");
}

Expand Down Expand Up @@ -146,16 +148,19 @@ void GLRStereoNormal::onDrawFrame(JNIEnv* env) {
#ifdef CHANGE_SWAP_COLOR
GLHelper::updateSetClearColor(swapColor);
#endif
#ifdef USE_INTERMEDIATE_DISTORTION
glBindFramebuffer(GL_FRAMEBUFFER,framebuffer_);
glClearColor(1,0,0,0.5f);
glScissor(0,0,RENDER_TEX_W,RENDER_TEX_H);
glViewport(0,0,RENDER_TEX_W,RENDER_TEX_H);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
distortionManager.updateDistortionWithIdentity();
mOSDRenderer->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();
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/cpp/GLRenderer/GLRStereoNormal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <Extensions.hpp>
#include <queue>

// #define USE_INTERMEDIATE_DISTORTION

class GLRStereoNormal : public IVideoFormatChanged {
public:
/**
Expand Down Expand Up @@ -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
};


Expand Down

0 comments on commit 1e08d0e

Please sign in to comment.