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.