Posts

Showing posts from August, 2013

Play video inside OpenGL ES by using MediaCodec

In Android 4.1 (API 16) and above, MediaCodec is introduced by Android. By using MediaCodec, we can easily decode video without using Android NDK, like creating video playback application, etc. In game development, video is also needed to make the game environment more realistics, like when you are playing a racing game with video banner around the track. In here, I'll introduce of how to decode the video and render it into OpenGL ES. Firstly, we prepare some stuffs to decode the video, like MediaExtractor and MediaCodec. private boolean initExtractor() { extractor = new MediaExtractor(); try { extractor.setDataSource(mFilePath); } catch (IOException e) { return false; } // get video track for (int i = 0; i < extractor.getTrackCount(); i++) { MediaFormat format = extractor.getTrackFormat(i); String mime = format.getString(MediaFormat.KEY_MIME); if (mime.startsWith("video/")) { ...

Check OpenGL ES capability on Android

There are lots of Android devices around the world. And when you want to create one application that need OpenGL ES, you would think (what I thought) if the user's device can run smoothly by checking the OpenGL ES version because this is important. So how to check the OpenGL ES version? By using SystemService. This is the simplest one. You don't need to create any OpenGL ES component. final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x30000; By using glGetService . By doing this, you can get more information, like the vendor, chip, shading version, etc. But, you need to have GL context first. String glVersion = GLES20.glGetString(GLES20.GL_VERSION); String glRenderer = GLES20.glGetString(GLES20.GL_RENDERER); String glVendor = GLES20.glGetString(GLES20.GL_VENDOR); String g...