我正試圖獲得一個簡單的測試應用程序,以使用San Angeles演示作爲參考進行構建。目前(在我的native/cpp代碼中)我只在調整glize時調用glViewport,在渲染幀時調用glClearColor和glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)。動態加載opengl庫時會發生問題(通過dlopen(「libGLESv1_CM.so」,RTLD_NOW)); dl打開成功,我找到了符號,但屏幕仍然保持黑色,即使我已將清晰的顏色設置爲綠色。另一方面,如果我不導入符號,事情似乎很好。Android:使用NDK進行OpenGL渲染
我已經經歷了幾次現在的San Angeles演示,看不到我可能錯過了什麼。任何想法/建議非常感謝。我的進口代碼如下:
uint32 ImportOpenGL()
{
uint32 uResult = 0;
glesLib = dlopen("libGLESv1_CM.so", RTLD_NOW);
if (!glesLib)
return 1;
#define GL_IMPORT_FUNC(funcName) \
{ \
*((void **)&(funcPtr_##funcName)) = (void *)dlsym(glesLib, #funcName); \
if(!funcPtr_##funcName) \
{ \
LOGW("Could not load OpenGL symbol: %s", #funcName); \
uResult = (!uResult ? 2 : uResult); \
} \
}
GL_IMPORT_FUNC(glBlendFunc);
GL_IMPORT_FUNC(glClear);
GL_IMPORT_FUNC(glClearColorx);
GL_IMPORT_FUNC(glClearColor);
GL_IMPORT_FUNC(glColor4x);
GL_IMPORT_FUNC(glColorPointer);
GL_IMPORT_FUNC(glDisable);
GL_IMPORT_FUNC(glDisableClientState);
GL_IMPORT_FUNC(glDrawArrays);
GL_IMPORT_FUNC(glEnable);
GL_IMPORT_FUNC(glEnableClientState);
GL_IMPORT_FUNC(glFrustumx);
GL_IMPORT_FUNC(glGetError);
GL_IMPORT_FUNC(glLightxv);
GL_IMPORT_FUNC(glLoadIdentity);
GL_IMPORT_FUNC(glMaterialx);
GL_IMPORT_FUNC(glMaterialxv);
GL_IMPORT_FUNC(glMatrixMode);
GL_IMPORT_FUNC(glMultMatrixx);
GL_IMPORT_FUNC(glNormalPointer);
GL_IMPORT_FUNC(glPopMatrix);
GL_IMPORT_FUNC(glPushMatrix);
GL_IMPORT_FUNC(glRotatex);
GL_IMPORT_FUNC(glScalex);
GL_IMPORT_FUNC(glShadeModel);
GL_IMPORT_FUNC(glTranslatex);
GL_IMPORT_FUNC(glVertexPointer);
GL_IMPORT_FUNC(glViewport);
#undef GL_IMPORT_FUNC
if(!uResult)
{
LOGI("Successfully imported OpenGL symbols");
}
return uResult;
}