Sunday, October 12, 2014

Having Fun with OpenGL, Android and Hardware Decoding

OpenGL is a good technology, and playing around with it on Android can be real fun! :-) By streaming a video to texture it is possible to create interesting effects, like it is possible to do with Qt. With a simple shader, for instance, lightning effects can be added:

#extension GL_OES_EGL_image_external : require

precision mediump float;
uniform samplerExternalOES u_Texture;
uniform vec3 u_LightPos;      // The position of the light in eye space.
varying vec2 v_TexCoordinate; // Interpolated texture coordinate per fragment.
varying vec3 v_Position;      // Interpolated position for this fragment.
varying vec4 v_Color; 
varying vec3 v_Normal;        // Interpolated normal.
void main()
   float distance = length(u_LightPos - v_Position);
   vec3 lightVector = normalize(u_LightPos - v_Position);
   float diffuse = max(dot(v_Normal, lightVector), 0.0);
   diffuse = diffuse*(1.0/(1.0 + (0.10*distance)));
   diffuse = diffuse + 0.3;
   gl_FragColor = v_Color*diffuse*texture2D(u_Texture, v_TexCoordinate);


This is the result on a couple of different devices (Nexus 7 with Qualcomm Snapdragon and an Allwinner A31s chip):

Saturday, October 11, 2014

Qt on Linux i.MX 6

i.MX 6 is a good device. Qt runs pretty well on it. Also a plugin for hardware accelerated and zero-copy rendering seems to work pretty well. Simply building Qt for i.MX 6 makes it possible to use the Qt Multimedia plugin. This is the result (on Linux):
I also tested a provided Android port but the result was not as good.