Java Code Examples for android.opengl.GLSurfaceView#requestRender()

The following examples show how to use android.opengl.GLSurfaceView#requestRender() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OBMainViewController.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public void transition (OBSectionController l, OBSectionController r, boolean fromRight, double duration)
{
    OBRenderer renderer = MainActivity.mainActivity.renderer;
    renderer.transitionFrac = 0;
    renderer.transitionScreenL = l;
    renderer.transitionScreenR = r;
    renderer.transitionType = OBRenderer.TRANSITION_SLIDE;
    GLSurfaceView glv = glView();

    long startms = SystemClock.uptimeMillis();
    double frac = 0;
    while (frac <= 1.0)
    {
        long currtime = SystemClock.uptimeMillis();
        frac = (currtime - startms) / (duration * 1000);
        float f = (float) OB_Maths.clamp01(frac);
        if (fromRight)
            f = 1 - f;
        renderer.transitionFrac = f;
        glv.requestRender();
        if (l == null)
            try
            {
                Thread.sleep(10);
            }
            catch (InterruptedException e)
            {
            }
        else
            l.waitForSecsNoThrow(0.01);
    }
    renderer.transitionScreenR.setViewPort(0,0,renderer.w,renderer.h);
    renderer.transitionScreenL.setViewPort(0,0,renderer.w,renderer.h);
    glv.requestRender();
    renderer.transitionScreenR = renderer.transitionScreenL = null;
    renderer.resetViewport();
}
 
Example 2
Source File: OBMainViewController.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public void transitionZoom (OBSectionController l, OBSectionController r, boolean fromRight, RectF zoomRect, double duration)
{
    OBRenderer renderer = MainActivity.mainActivity.renderer;
    renderer.transitionFrac = 0;
    renderer.transitionScreenL = l;
    renderer.transitionScreenR = r;
    renderer.transitionType = OBRenderer.TRANSITION_ZOOM;
    renderer.zoomRect = zoomRect;
    GLSurfaceView glv = glView();

    long startms = SystemClock.uptimeMillis();
    double frac = 0;
    while (frac <= 1.0)
    {
        long currtime = SystemClock.uptimeMillis();
        frac = (currtime - startms) / (duration * 1000);
        float f = (float) OB_Maths.clamp01(frac);
        if (fromRight)
            f = 1 - f;
        renderer.transitionFrac = f;
        glv.requestRender();
        if (l == null)
            try
            {
                Thread.sleep(10);
            }
            catch (InterruptedException e)
            {
            }
        else
            l.waitForSecsNoThrow(0.01);
    }
    renderer.transitionScreenR.setViewPort(0,0,renderer.w,renderer.h);
    renderer.transitionScreenL.setViewPort(0,0,renderer.w,renderer.h);
    glv.requestRender();
    renderer.transitionScreenR = renderer.transitionScreenL = null;
    renderer.resetViewport();
}
 
Example 3
Source File: VRPlayerActivity.java    From IjkVRPlayer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Uri uri = getIntent().getData();
    if (uri == null) {
        Toast.makeText(this, "no media file to open!", Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    setContentView(R.layout.activity_vr_player);
    mGLView = (GLSurfaceView) findViewById(R.id.surface);
    mGLView.setEGLContextClientVersion(2); //GLES 2.0
    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 1) {
                prepareMediaPlayerIfReady();
                return;
            } else if (msg.what == 2) {
                mGLView.requestRender();
            }
            super.handleMessage(msg);
        }
    };
    // TODO: implements your TextureRender
    mRenderer = new IjkVRRender(mHandler);
    mGLView.setRenderer(mRenderer);
    mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
            && checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
    } else {
        initMediaPlayer(uri);
    }
}