Some small traps on Android Simulators

Source: Internet
Author: User
Reprinted please indicate the source for the klayge game engine, the permanent link of this article is http://www.klayge.org /? P = 2229

Since Android SDK R17, the simulator supports OpenGL ES 2. If klayge can run on the simulator, it is much easier to develop and test it. So I installed the latest R21 and Android 2.1 arm v7a images. After several hours of efforts, I finally successfully executed some simple examples that could have been run on Android x86 2.3. Some small traps were found on the way. Here we will summarize them.

Screen width and height

In the past, I used anativewindow_lock to obtain the buffer, and then the width and height of the buffer. In ICS, this will cause eglcreatewindowsurface to fail. The reason seems to be that the window is connected to the 2D API after anativewindow_lock, so when you call eglcreatewindowsurface, it will be said that the window has been connected by other APIs. Even anativewindow_unlockandpost is useless. The solution is to use anativewindow_getwidth and anativewindow_getheight. In the past, the two functions always return 0. Now it seems better, but it is more convenient to use.

Gldeleteshader

Previously, I used to call gldeleteshader immediately after glattachshader, because the gles document contains a sentence:

If a shader object to be deleted is attached to a program object, it will be flagged for deletion, but it will not be deleted until it is no longer attached to any program object...

But the implementation of the simulator does not seem to comply with this. If the delete operation is completed, glgetattriblocation returns-1, and all attrib does not exist. Therefore, you must remove gldeleteshader.

Lack of complete wchar_t support

This is a persistent problem. Bonic 2.3 does not fully support the wchar_t series functions. The most disgusting is mbstowcs and wcstombs. It's only memcpy internally and there is no transcoding at all... I used crystax's ndk all the time. Without this problem, I went back to the official ndk and then suffered a direct tragedy.

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.