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

The following examples show how to use android.opengl.GLSurfaceView#setEGLContextClientVersion() . 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: MainActivity.java    From opengl with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mGLSurfaceView = new GLSurfaceView(this);

    if (detectOpenGLES30()) {
        // Tell the surface view we want to create an OpenGL ES 3.0-compatible
        // context, and set an OpenGL ES 3.0-compatible renderer.
        mGLSurfaceView.setEGLContextClientVersion(CONTEXT_CLIENT_VERSION);
        mGLSurfaceView.setRenderer(new HelloTriangleRenderer(this));
    } else {
        Log.e("HelloTriangle", "OpenGL ES 3.0 not supported on device.  Exiting...");
        finish();

    }

    setContentView(mGLSurfaceView);
}
 
Example 2
Source File: Game.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate( Bundle savedInstanceState ) {
	super.onCreate( savedInstanceState );
	
	BitmapCache.context = TextureCache.context = instance = this;
	
	DisplayMetrics m = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( m );
	density = m.density;
	
	try {
		version = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionName;
	} catch (NameNotFoundException e) {
		version = "???";
	}
	
	setVolumeControlStream( AudioManager.STREAM_MUSIC );
	
	view = new GLSurfaceView( this );
	view.setEGLContextClientVersion( 2 );
	view.setEGLConfigChooser( false );
	view.setRenderer( this );
	view.setOnTouchListener( this );
	setContentView( view );
}
 
Example 3
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 4
Source File: PlayRtspVideoView.java    From Viewer with Apache License 2.0 6 votes vote down vote up
private void initRtsp()
{
	wait_relayout.setVisibility(View.VISIBLE);
	glSurfaceView = new GLSurfaceView(this);
	glSurfaceView.setEGLContextClientVersion(2);
	if (isCloudVideo)
	{
		vodStreamId = media.openCloudRecordFileStream(Long.valueOf(cid), eid);
		Log.d("media", "vod stream:" + vodStreamId);
		myRenderer = new MyRenderer(this, vodStreamId, media, handler);
	} else
	{
		vodStreamId = media.openRemoteRecordFileStream(Long.valueOf(cid), videodata);
		Log.d("media", "vod stream:" + vodStreamId);
		myRenderer = new MyRenderer(this, vodStreamId, media, handler);
	}
	glSurfaceView.setRenderer(myRenderer);
	surfaceViewLayout.addView(glSurfaceView);
	surfaceViewLayout.setOnClickListener(this);
}
 
Example 5
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 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: 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 8
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);
}
 
Example 9
Source File: EffectsFilterActivity.java    From ImageEffects with Eclipse Public License 1.0 5 votes vote down vote up
@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.main);
		/**
		 * Initialise the renderer and tell it to only render when Explicit
		 * requested with the RENDERMODE_WHEN_DIRTY option
		 */
		mEffectView = (GLSurfaceView) findViewById(R.id.effectsview);
		mEffectView.setEGLContextClientVersion(2);
		mEffectView.setRenderer(this);
		mEffectView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
		mCurrentEffect = R.id.none;
	}
 
Example 10
Source File: PreviewTranscode.java    From media-for-mobile with Apache License 2.0 5 votes vote down vote up
public PreviewTranscode(GLSurfaceView glView,
                        IEglUtil eglUtil) {
    this.glView = glView;
    this.eglUtil = eglUtil;
    textureRender = new TextureRenderer(eglUtil);

    glView.setEGLContextClientVersion(2);
    glView.setEGLConfigChooser(true);
    glView.setRenderer(this);
    glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 11
Source File: RtmpPublisher.java    From RtmpPublisher with Apache License 2.0 5 votes vote down vote up
RtmpPublisher(AppCompatActivity activity,
              GLSurfaceView glView,
              String url,
              int width,
              int height,
              int audioBitrate,
              int videoBitrate,
              CameraMode mode,
              PublisherListener listener) {

    activity.getLifecycle().addObserver(this);

    this.glView = glView;
    this.url = url;
    this.width = width;
    this.height = height;
    this.audioBitrate = audioBitrate;
    this.videoBitrate = videoBitrate;

    this.camera = new CameraClient(activity, mode);
    this.streamer = new Streamer();
    this.streamer.setMuxerListener(listener);

    glView.setEGLContextClientVersion(2);
    renderer = new CameraSurfaceRenderer();
    renderer.addOnRendererStateChangedLister(streamer.getVideoHandlerListener());
    renderer.addOnRendererStateChangedLister(this);

    glView.setRenderer(renderer);
    glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

}
 
Example 12
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate( Bundle savedInstanceState ) {
	super.onCreate( savedInstanceState );
	
	BitmapCache.context = TextureCache.context = instance = this;
	
	DisplayMetrics m = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( m );
	density = m.density;
	
	try {
		version = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionName;
		versionNum = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionCode;
	} catch (NameNotFoundException e) {
		version = "???";
           versionNum = 0;
	}
	
	setVolumeControlStream( AudioManager.STREAM_MUSIC );
	
	view = new GLSurfaceView( this );
	view.setEGLContextClientVersion( 2 );
	view.setEGLConfigChooser( false );
	view.setRenderer( this );
	view.setOnTouchListener( this );
	setContentView( view );
}
 
Example 13
Source File: TiledImageView.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public TiledImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mRenderer = new ImageRendererWrapper();
    mRenderer.image = new TiledImageRenderer(this);
    mGLSurfaceView = new GLSurfaceView(context);
    mGLSurfaceView.setEGLContextClientVersion(2);
    mGLSurfaceView.setRenderer(new TileRenderer());
    mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    addView(mGLSurfaceView, new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    //setTileSource(new ColoredTiles());
}
 
Example 14
Source File: Game.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    iap = new Iap(this);

    try {
        version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
        versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        version = "???";
        versionCode = 0;
    }

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    view = new GLSurfaceView(this);
    view.setEGLContextClientVersion(2);

    // Hope this allow game work on broader devices list
    // view.setEGLConfigChooser( false );
    view.setRenderer(this);
    view.setOnTouchListener(this);

    layout = new LinearLayout(this);
    getLayout().setOrientation(LinearLayout.VERTICAL);
    getLayout().addView(view);

    setContentView(getLayout());
}
 
Example 15
Source File: InvertedColorsVideoRenderer.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
public InvertedColorsVideoRenderer(Context context) {
    this.mContext = context;

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

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

    mView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 16
Source File: GameActivity.java    From Tanks with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);

  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

  handler = new Handler();
  renderer = new Renderer();

  initializeContext();
  initializeFactory();

  // OpenGL init
  glView = new GLSurfaceView(this);
  glView.getHolder().setFormat(PixelFormat.RGBA_8888);
  glView.setEGLContextClientVersion(2);
  glView.setEGLConfigChooser(new ConfigChooser());
  glView.setRenderer(renderer);
  glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

  // Bind listener
  glView.setOnTouchListener(this);

  // Set view
  setContentView(glView);

  // Set menu and world
  initializeContent();
}
 
Example 17
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);
    }
}
 
Example 18
Source File: VideoRendererGui.java    From droidkit-webrtc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private VideoRendererGui(GLSurfaceView surface) {
  this.surface = surface;
  // Create an OpenGL ES 2.0 context.
  surface.setPreserveEGLContextOnPause(true);
  surface.setEGLContextClientVersion(2);
  surface.setRenderer(this);
  surface.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

  yuvImageRenderers = new ArrayList<YuvImageRenderer>();
}
 
Example 19
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 20
Source File: PointCloudActivity.java    From tango with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_jpoint_cloud);
    setTitle(R.string.app_name);

    mPoseTextView = (TextView) findViewById(R.id.pose);
    mQuatTextView = (TextView) findViewById(R.id.quat);
    mPoseCountTextView = (TextView) findViewById(R.id.posecount);
    mDeltaTextView = (TextView) findViewById(R.id.deltatime);
    mTangoEventTextView = (TextView) findViewById(R.id.tangoevent);
    mPoseStatusTextView = (TextView) findViewById(R.id.status);
    mPointCountTextView = (TextView) findViewById(R.id.pointCount);
    mTangoServiceVersionTextView = (TextView) findViewById(R.id.version);
    mApplicationVersionTextView = (TextView) findViewById(R.id.appversion);
    mAverageZTextView = (TextView) findViewById(R.id.averageZ);
    mFrequencyTextView = (TextView) findViewById(R.id.frameDelta);

    mSaveButton = (Button) findViewById(R.id.saveButton);
    mSaveButton.setOnClickListener(this);
    mFirstPersonButton = (Button) findViewById(R.id.first_person_button);
    mFirstPersonButton.setOnClickListener(this);
    mThirdPersonButton = (Button) findViewById(R.id.third_person_button);
    mThirdPersonButton.setOnClickListener(this);
    mTopDownButton = (Button) findViewById(R.id.top_down_button);
    mTopDownButton.setOnClickListener(this);

    mGLView = (GLSurfaceView) findViewById(R.id.gl_surface_view);
    mGLView.setEGLContextClientVersion(2);

    mTango = new Tango(this);
    mConfig = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT);
    // tangoCameraPreview = (TangoCameraPreview) findViewById(R.id.cameraView);

    int maxDepthPoints = mConfig.getInt("max_point_cloud_elements");
    mRenderer = new PCRenderer(maxDepthPoints);
    mGLView.setRenderer(mRenderer);

    mConfig.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);
    mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    PackageInfo packageInfo;
    try {
        packageInfo = this.getPackageManager().getPackageInfo(
                this.getPackageName(), 0);
        mApplicationVersionTextView.setText(packageInfo.versionName);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    // Display the version of Tango Service
    mServiceVersion = mConfig.getString("tango_service_library_version");
    mTangoServiceVersionTextView.setText(mServiceVersion);
    mIsTangoServiceConnected = false;

    // Set up OpenGL ES surface
    mCamView = new GLSurfaceView(this);
    mCamView.setEGLContextClientVersion(2);
    mCamView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR);
    mCamView.setRenderer(renderer_ = new FrameRenderer(this));
    mCamView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    mCamView.setOnClickListener(this);
    FrameLayout placeholder = (FrameLayout)findViewById(R.id.cameraFrame);
    placeholder.addView(mCamView);
    cameraTextures_ = new HashMap<>();
}