Portability of OpenGL ES on the Android platform

Source: Internet
Author: User

Android uses ndk instead of yuv420 overlay to ensure smooth video display. Instead, it uses a platform to port a safer rgb565 display. Tested on Android 2.3.

However, the MTK andriod platform (a301) encountered a glteximage2d gl_error 0x501 error (the source image is 176*144 ). After repeated tests, this MTK andriod version supports OpenGL ES, but it has a strange limit on the resolution of the source image. When the source dimension width and height must be a multiple of 64 and the width and height are usually two times the relationship. For example, 512*256,256*128 is acceptable. You can only scale the image to 256*128 first, and then use OpenGL ES to screen.

In addition, opensl es can still be used on MTK android.

~~~ Finally, paste the sample code of OpenGL ES for your reference.

Void opengl_resize (jint screen_width, jint screen_height)

{

Gldeletetextures (1, & s_texture );
Gluint * Start = s_disable_caps;
While (* start)
Gldisable (* Start ++ );
Glable (gl_texture_2d );

Glgentextures (1, & s_texture );

Glbindtexture (gl_texture_2d, s_texture );

Gltexparameterf (gl_texture_2d,
Gl_texture_min_filter, gl_linear );

Gltexparameterf (gl_texture_2d,
Gl_texture_mag_filter, gl_linear );

Glshademodel (gl_flat );
Check_gl_error ("glshademodel ");
Glcolor4x (0x10000, 0x10000, 0x10000, 0x10000 );
Check_gl_error ("glcolor4x ");
Int rect [4] = {0, texture_height, texture_width,-texture_height };
Gltexparameteriv (gl_texture_2d, gl_texture_crop_rect_oes, rect );
Check_gl_error ("gltexparameteriv ");
Videowidth = width;
Videoheight = height;

}

Static void render_video_opengl (unsigned char * rgb_buffer)
{
Glclear (gl_color_buffer_bit );
Glteximage2d (gl_texture_2d,/* Target */
0,/* level */
Gl_rgb,
/* Internal format */
Texture_width,/* width */
Texture_height,/* height */
0,/* border */
Gl_rgb,
/* Format */
Gl_unsigned_short_5_6_5,/* type */
Rgb_buffer );
/* Pixels */
Check_gl_error ("glteximage2d ");
Gldrawtexioes (0, 0, 0, videowidth, videoheight );
Check_gl_error ("gldrawtexioes ");
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.