android.opengl.GLSurfaceView Java Examples

The following examples show how to use android.opengl.GLSurfaceView. 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: BlackAndWhiteEffect.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public String getShader(GLSurfaceView mGlSurfaceView) {

    String shader = "#extension GL_OES_EGL_image_external : require\n"
            + "precision mediump float;\n"
            + "varying vec2 vTextureCoord;\n"
            + "uniform samplerExternalOES sTexture;\n" + "void main() {\n"
            + "  vec4 color = texture2D(sTexture, vTextureCoord);\n"
            + "  float colorR = (color.r + color.g + color.b) / 3.0;\n"
            + "  float colorG = (color.r + color.g + color.b) / 3.0;\n"
            + "  float colorB = (color.r + color.g + color.b) / 3.0;\n"
            + "  gl_FragColor = vec4(colorR, colorG, colorB, color.a);\n"
            + "}\n";

    return shader;

}
 
Example #2
Source File: GLWrapper.java    From panoramagl with Apache License 2.0 6 votes vote down vote up
/**
 * init methods
 */

public GLWrapper(GL gl, GLSurfaceView glSurfaceView) {
    mGL = (GL10) gl;
    if (gl instanceof GL10Ext) {
        mGL10Ext = (GL10Ext) gl;
    }
    if (gl instanceof GL11) {
        mGL11 = (GL11) gl;
    }
    if (gl instanceof GL11Ext) {
        mGL11Ext = (GL11Ext) gl;
    }
    if (gl instanceof GL11ExtensionPack) {
        mGL11ExtPack = (GL11ExtensionPack) gl;
    }
    mGLSurfaceView = glSurfaceView;
}
 
Example #3
Source File: CurlView.java    From Android-Example with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize method.
 */
private void init(Context ctx) {
	mRenderer = new CurlRenderer(this);
	setRenderer(mRenderer);
	setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
	setOnTouchListener(this);

	// Even though left and right pages are static we have to allocate room
	// for curl on them too as we are switching meshes. Another way would be
	// to swap texture ids only.
	mPageLeft = new CurlMesh(10);
	mPageRight = new CurlMesh(10);
	mPageCurl = new CurlMesh(10);
	mPageLeft.setFlipTexture(true);
	mPageRight.setFlipTexture(false);
}
 
Example #4
Source File: CameraGLSurfaceView.java    From ml-authentication with Apache License 2.0 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example #5
Source File: SumerianConnector.java    From amazon-sumerian-arcore-starter-app with Apache License 2.0 6 votes vote down vote up
SumerianConnector(WebView webView, Session session, GLSurfaceView surfaceView) {
    mWebView = webView;
    mSession = session;
    mSurfaceView = surfaceView;

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setMediaPlaybackRequiresUserGesture(false);
    mWebView.addJavascriptInterface(new BridgeInterface(), "Android");

    this.mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            view.setBackgroundColor(0x00000000);
        }
    });
}
 
Example #6
Source File: PreviewActivity.java    From retroboy with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	// Force switch to landscape orientation
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

	// Check which camera to use
	for (int i = 0, cameras = Camera.getNumberOfCameras(); i < cameras; i++) {
		Camera.CameraInfo info = new Camera.CameraInfo();
		Camera.getCameraInfo(i, info);
		
		if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
			_cameraid = i;
			break;
		}
	}
	
	_surface = new GLSurfaceView(this);
	_surface.setEGLContextClientVersion(2);

	_renderer = new PreviewRenderer(this);
	_surface.setRenderer(_renderer);

	setContentView(_surface);
}
 
Example #7
Source File: PLTexture.java    From PanoramaGL with Apache License 2.0 6 votes vote down vote up
protected void recycleTexture(GL10 gl)
{
	if(gl != null && mTextureId != null && mTextureId[0] != 0)
	{
		if(PLUtils.getAndroidVersion() < 3f)
		{
			gl.glDeleteTextures(1, mTextureId, 0);
			mTextureId[0] = 0;
			mGLWrapper = null;
			mIsValid = false;
		}
		else if(mGLWrapper != null)
		{
			GLSurfaceView glSurfaceView = mGLWrapper.getGLSurfaceView();
			if(glSurfaceView != null)
				glSurfaceView.queueEvent(new PLRecycleTextureRunnable(this));
		}
	}
}
 
Example #8
Source File: TiledImageView.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
public TiledImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!IS_SUPPORTED) {
        return;
    }

    mRenderer = new ImageRendererWrapper();
    mRenderer.image = new TiledImageRenderer(this);
    View view;
    if (USE_TEXTURE_VIEW) {
        mTextureView = new BlockingGLTextureView(context);
        mTextureView.setRenderer(new TileRenderer());
        view = mTextureView;
    } else {
        mGLSurfaceView = new GLSurfaceView(context);
        mGLSurfaceView.setEGLContextClientVersion(2);
        mGLSurfaceView.setRenderer(new TileRenderer());
        mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        view = mGLSurfaceView;
    }
    addView(view, new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    //setTileSource(new ColoredTiles());
}
 
Example #9
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 6 votes vote down vote up
@Override
public void onConnected(Session session) {
    Log.d(TAG, "onConnected: Connected to session " + session.getSessionId());

    mPublisher = new Publisher.Builder(MainActivity.this)
            .name("publisher")
            .capturer(new CustomVideoCapturer(MainActivity.this, Publisher.CameraCaptureResolution.MEDIUM, Publisher.CameraCaptureFrameRate.FPS_30))
            .renderer(new InvertedColorsVideoRenderer(MainActivity.this)).build();
    mPublisher.setPublisherListener(this);

    mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
    mPublisherViewContainer.addView(mPublisher.getView());

    if (mPublisher.getView() instanceof GLSurfaceView) {
        ((GLSurfaceView) (mPublisher.getView())).setZOrderOnTop(true);
    }

    mSession.publish(mPublisher);
}
 
Example #10
Source File: GLRenderWrapper.java    From AndroidRipper with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Constructs this object.
 * 
 * @param view the current glSurfaceView
 * @param renderer the renderer to wrap
 * @param latch the count down latch
 */

public GLRenderWrapper(GLSurfaceView view,
		Renderer renderer, CountDownLatch latch) {
	this.view = view;
	this.renderer = renderer;
	this.latch = latch;
	
	this.width = view.getWidth();
	this.height = view.getHeight();
	
	Integer out = new Reflect(view).field("mEGLContextClientVersion")
			.out(Integer.class);
	if ( out != null ) {
		this.glVersion = out.intValue();
	} else {
		this.glVersion = -1;
		this.takeScreenshot = false;
	}
}
 
Example #11
Source File: JanusActivity.java    From janus-gateway-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
    java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_janus);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    vsv = (GLSurfaceView) findViewById(R.id.glview);
    vsv.setPreserveEGLContextOnPause(true);
    vsv.setKeepScreenOn(true);
    VideoRendererGui.setView(vsv, new MyInit());

    localRender = VideoRendererGui.create(72, 72, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false);
    remoteRender = VideoRendererGui.create(0, 0, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true);
}
 
Example #12
Source File: CameraGLSurfaceView.java    From LPR with Apache License 2.0 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example #13
Source File: CameraGLSurfaceView.java    From sudokufx with Apache License 2.0 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example #14
Source File: CameraGLSurfaceView.java    From SimpleDocumentScanner-Android with MIT License 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example #15
Source File: TiledImageView.java    From LB-Launcher with Apache License 2.0 6 votes vote down vote up
public TiledImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!IS_SUPPORTED) {
        return;
    }

    mRenderer = new ImageRendererWrapper();
    mRenderer.image = new TiledImageRenderer(this);
    View view;
    if (USE_TEXTURE_VIEW) {
        mTextureView = new BlockingGLTextureView(context);
        mTextureView.setRenderer(new TileRenderer());
        view = mTextureView;
    } else {
        mGLSurfaceView = new GLSurfaceView(context);
        mGLSurfaceView.setEGLContextClientVersion(2);
        mGLSurfaceView.setRenderer(new TileRenderer());
        mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        view = mGLSurfaceView;
    }
    addView(view, new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    //setTileSource(new ColoredTiles());
}
 
Example #16
Source File: CameraGLSurfaceView.java    From VIA-AI with MIT License 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example #17
Source File: CameraCaptureActivity.java    From AndroidPlayground with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera_capture);

    File outputFile = new File(Environment.getExternalStorageDirectory(), "camera-test.mp4");

    // Define a handler that receives camera-control messages from other threads.  All calls
    // to Camera must be made on the same thread.  Note we create this before the renderer
    // thread, so we know the fully-constructed object will be visible.
    mCameraHandler = new CameraHandler(this);

    // Configure the GLSurfaceView.  This will start the Renderer thread, with an
    // appropriate EGL context.
    mGLView = (GLSurfaceView) findViewById(R.id.cameraPreview_surfaceView);
    mGLView.setEGLContextClientVersion(2);     // select GLES 2.0
    mRenderer = new CameraSurfaceRenderer(mCameraHandler, outputFile);
    mGLView.setRenderer(mRenderer);
    mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    Log.d(TAG, "onCreate complete: " + this);
}
 
Example #18
Source File: CameraGLSurfaceView.java    From MOAAP with MIT License 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example #19
Source File: SepiaEffect.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public String getShader(GLSurfaceView mGlSurfaceView) {
    float weights[] = {805.0f / 2048.0f, 715.0f / 2048.0f,
            557.0f / 2048.0f, 1575.0f / 2048.0f, 1405.0f / 2048.0f,
            1097.0f / 2048.0f, 387.0f / 2048.0f, 344.0f / 2048.0f,
            268.0f / 2048.0f};
    String matrixString[] = new String[9];

    matrixString[0] = "  matrix[0][0]=" + weights[0] + ";\n";
    matrixString[1] = "  matrix[0][1]=" + weights[1] + ";\n";
    matrixString[2] = "  matrix[0][2]=" + weights[2] + ";\n";
    matrixString[3] = "  matrix[1][0]=" + weights[3] + ";\n";
    matrixString[4] = "  matrix[1][1]=" + weights[4] + ";\n";
    matrixString[5] = "  matrix[1][2]=" + weights[5] + ";\n";
    matrixString[6] = "  matrix[2][0]=" + weights[6] + ";\n";
    matrixString[7] = "  matrix[2][1]=" + weights[7] + ";\n";
    matrixString[8] = "  matrix[2][2]=" + weights[8] + ";\n";

    String shader = "#extension GL_OES_EGL_image_external : require\n"
            + "precision mediump float;\n"
            + "uniform samplerExternalOES sTexture;\n" + " mat3 matrix;\n"
            + "varying vec2 vTextureCoord;\n" + "void main() {\n"
            + matrixString[0] + matrixString[1] + matrixString[2]
            + matrixString[3] + matrixString[4] + matrixString[5]
            + matrixString[6] + matrixString[7] + matrixString[8]
            + "  vec4 color = texture2D(sTexture, vTextureCoord);\n"
            + "  vec3 new_color = min(matrix * color.rgb, 1.0);\n"
            + "  gl_FragColor = vec4(new_color.rgb, color.a);\n" + "}\n";

    return shader;

}
 
Example #20
Source File: MainActivity.java    From opengl with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// Turn off the window's title bar
	requestWindowFeature(Window.FEATURE_NO_TITLE);

	super.onCreate(savedInstanceState);
	mGLSurfaceView = new GLSurfaceView(this);
	// Check if the system supports OpenGL ES 2.0.
	final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
	final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
	final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
	if (supportsEs2)
	{
		// Request an OpenGL ES 2.0 compatible context.
		mGLSurfaceView.setEGLContextClientVersion(2);

		// Set the renderer to our demo renderer, defined below.
		mGLSurfaceView.setRenderer(new LessonOneRenderer());
	}
	else
	{
		// This is where you could create an OpenGL ES 1.x compatible
		// renderer if you wanted to support both ES 1 and ES 2.
		return;
	}
	setContentView(mGLSurfaceView);
}
 
Example #21
Source File: DemoActivity.java    From StarWars.Android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_demo);
    ButterKnife.bind(this);

    // Check if the system supports OpenGL ES 2.0.
    final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

    if (supportsEs2) {
        // Request an OpenGL ES 2.0 compatible context.
        mGlSurfaceView.setEGLContextClientVersion(2);

        // Set the renderer to our demo renderer, defined below.
        ParticleSystemRenderer mRenderer = new ParticleSystemRenderer(mGlSurfaceView);
        mGlSurfaceView.setRenderer(mRenderer);
        mGlSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    } else {
        throw new UnsupportedOperationException();
    }

    if (savedInstanceState == null) {
        showGreetings();
    }

}
 
Example #22
Source File: TextureFitView.java    From EZFilter with MIT License 5 votes vote down vote up
private void init() {
    setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR
            | GLSurfaceView.DEBUG_LOG_GL_CALLS);
    setEGLContextClientVersion(2);
    mHelper = new FitViewHelper();

    mPipeline = new RenderPipeline();
    setRenderer(mPipeline);
    setRenderMode(RENDERMODE_WHEN_DIRTY);
}
 
Example #23
Source File: OpenGlDemo1Activity.java    From opengl with Apache License 2.0 5 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    		WindowManager.LayoutParams.FLAG_FULLSCREEN);
    GLSurfaceView view = new GLSurfaceView(this);
    view.setRenderer(new SquareRenderer(true));
    setContentView(view);
}
 
Example #24
Source File: GLRenderer.java    From HoloKilo with GNU General Public License v3.0 5 votes vote down vote up
public GLRenderer(GLSurfaceView view, Tracker tracker)
{
    this.view = view;
    this.tracker = tracker;

    tracker.startTracking();

    Log.d(Config.TAG, "Created renderer");
}
 
Example #25
Source File: CameraCaptureActivity.java    From grafika with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera_capture);

    File outputFile = new File(getFilesDir(), "camera-test.mp4");
    TextView fileText = (TextView) findViewById(R.id.cameraOutputFile_text);
    fileText.setText(outputFile.toString());

    Spinner spinner = (Spinner) findViewById(R.id.cameraFilter_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.cameraFilterNames, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner.
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    // Define a handler that receives camera-control messages from other threads.  All calls
    // to Camera must be made on the same thread.  Note we create this before the renderer
    // thread, so we know the fully-constructed object will be visible.
    mCameraHandler = new CameraHandler(this);

    mRecordingEnabled = sVideoEncoder.isRecording();

    // Configure the GLSurfaceView.  This will start the Renderer thread, with an
    // appropriate EGL context.
    mGLView = (GLSurfaceView) findViewById(R.id.cameraPreview_surfaceView);
    mGLView.setEGLContextClientVersion(2);     // select GLES 2.0
    mRenderer = new CameraSurfaceRenderer(mCameraHandler, sVideoEncoder, outputFile);
    mGLView.setRenderer(mRenderer);
    mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    Log.d(TAG, "onCreate complete: " + this);
}
 
Example #26
Source File: GPUImage.java    From SimpleVideoEditor with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the GLSurfaceView which will display the preview.
 *
 * @param view the GLSurfaceView
 */
public void setGLSurfaceView(final GLSurfaceView view) {
    mGlSurfaceView = view;
    mGlSurfaceView.setEGLContextClientVersion(2);
    mGlSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    mGlSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
    mGlSurfaceView.setRenderer(mRenderer);
    mGlSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    mGlSurfaceView.requestRender();
}
 
Example #27
Source File: CompressedTextureActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mGLView = new GLSurfaceView(this);
    mGLView.setEGLConfigChooser(false);
    StaticTriangleRenderer.TextureLoader loader;
    if (TEST_CREATE_TEXTURE) {
        loader = new SyntheticCompressedTextureLoader();
    } else {
        loader = new CompressedTextureLoader();
    }
    mGLView.setRenderer(new StaticTriangleRenderer(this, loader));
    setContentView(mGLView);
}
 
Example #28
Source File: GreyScaleEffect.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public String getShader(GLSurfaceView mGlSurfaceView) {

    String shader = "#extension GL_OES_EGL_image_external : require\n"
            + "precision mediump float;\n"
            + "uniform samplerExternalOES sTexture;\n"
            + "varying vec2 vTextureCoord;\n" + "void main() {\n"
            + "  vec4 color = texture2D(sTexture, vTextureCoord);\n"
            + "  float y = dot(color, vec4(0.299, 0.587, 0.114, 0));\n"
            + "  gl_FragColor = vec4(y, y, y, color.a);\n" + "}\n";
    ;

    return shader;

}
 
Example #29
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 #30
Source File: BasicCustomVideoRenderer.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
public BasicCustomVideoRenderer(Context context) {
    this.mContext = context;

    mView = new GLSurfaceView(context);
    mView.setEGLContextClientVersion(2);

    mRenderer = new MyRenderer(this);
    mView.setRenderer(mRenderer);

    mView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}