Android EGL eglCreateWindowSurface 调用问题
eglCreateWindowSurface 函数的第三个参数怎么填呢?查了好几天,都没怎么说这个参数的问题。
Android系统:4.1.1,硬件:小米2(MIUI版本:2.12.21)
以下是我的测试代码(jni代码):
EGLDisplay myDisplay = NULL;
EGLint majorVer = 0, minorVer = 0;
EGLBoolean ret = EGL_TRUE;
EGLConfig eglConfig;
EGLint num_config;
EGLSurface windowSurface;
NativeWindowType win = NULL; //就是这个变量,不知道怎么写~~
EGLContext myContext;
int ViewCreate(){
myDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if(EGL_NO_DISPLAY == myDisplay)
LOGI("eglGetDisplay no display");
ret = eglInitialize(myDisplay, &majorVer, &minorVer);
LOGI("ret: %d major: %d minor: %d", ret, majorVer, minorVer);
EGLint attribs[] = {
EGL_RED_SIZE, 4,
EGL_GREEN_SIZE, 4,
EGL_BLUE_SIZE, 4,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE
};
ret = eglChooseConfig(myDisplay, attribs, &eglConfig, 1, &num_config);
LOGI("ret: %d num: %d", ret, num_config);
EGLint surfAttribs[] = {
EGL_COLORSPACE, EGL_COLORSPACE_sRGB,
EGL_NONE
};
windowSurface = eglCreateWindowSurface(myDisplay, eglConfig, win, surfAttribs);
if(EGL_NO_SURFACE == windowSurface){
LOGI("create surface error");
return 0;
}
myContext = eglCreateContext(myDisplay, eglConfig, NULL, NULL);
if(EGL_NO_CONTEXT == myContext){
LOGI("EGL_NO_CONTEXT");
return 0;
}
eglMakeCurrent(myDisplay, windowSurface, windowSurface, myContext);
eglBindAPI(EGL_OPENGL_ES_API);
}
,返回的版本号是:1.4,
但在eglCreateWindowSurface的时候程序直接崩溃,
Fatal signal 11 (SIGSEGV) at 0x00000058 (code=1), thread 8356,看有好多人遇到这个问题,但不知道大家解决怎么样了?
java代码:
package com.android.Test;
public class TestView {
public TestView (){
TestLib.ViewCreate();
}
protected void finalize(){
TestLib.ViewDelete();
}
}
package com.android.Test;
public class TestLib {
static {
System.loadLibrary("Test");
}
public static native void ViewCreate();
}