2016-08-12 66 views
0

我遇到了一個對我來說沒有多大意義的問題。我正在測試Nexus 6設備上的一些簡單的GLES30代碼。我將代碼設置爲API 23和OS棒棒糖5.0。根據維基它採用了Adreno 420,支持全GLES 3.1輪廓無法在nexus 6(和類似設備)上編譯gles 30

https://en.wikipedia.org/wiki/Nexus_6

然而,一個簡單的着色器未能按下面的編譯:

shader代碼:

#version 300 es 

layout(location = 4) in vec4 a_position; 
layout(location = 5) in vec4 a_color; 

uniform mat4 u_mvpMatrix; 
out  vec4 v_color; 

void main() 
{ 
    v_color = a_color; 
    gl_Position = u_mvpMatrix * a_position; 
} 

日誌:

Vertex shader failed to compile with the following errors: 
ERROR: 0:2: error(#308) Profile " " is not available in shader version 1777753240 
ERROR: 0:1: error(#132) Syntax error: "es" parse error 
ERROR: error(#273) 2 compilation errors. No code generated 

我將我的上下文設置爲3.0 如下。

const EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 
          3, // Request opengl ES3.0 
          EGL_NONE}; 
context_ = eglCreateContext(display_, config_, NULL, context_attribs); 

仍然沒有編譯。

我錯過了什麼嗎?

thx!

回答

0

通常這意味着您的設備不支持您要求的GLSL版本。嘗試運行下面的代碼,以確認GLSL版本支持GLSL 3.

glGetString(GL_SHADING_LANGUAGE_VERSION); 

here你可以決定如何讀取這種格式。

GL_VERSION和GL_SHADING_LANGUAGE_VERSION字符串以版本號開頭。版本號使用以下形式之一: major_number.minor_number major_number.minor_number.release_number 供應商特定的信息可能會跟隨版本號。其格式取決於實現,但空間總是將版本號和供應商特定的信息分開。

這是我目前使用的配置。

#define EGL_OPENGL_ES3_BIT_KHR 0x0040 
const EGLint attribs[] = { 
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR, 
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 
    EGL_BLUE_SIZE, 8, 
    EGL_GREEN_SIZE, 8, 
    EGL_RED_SIZE, 8, 
    EGL_ALPHA_SIZE, 8, 
    EGL_DEPTH_SIZE, 8, 
    EGL_STENCIL_SIZE, 8, 
    EGL_NONE 
}; 
... 
eglChooseConfig(display, attribs, &config, 1, &numConfigs); 
... 
EGLint openGLVersionRequested = 3; 
EGLint contextAttribs[] = { 
    EGL_CONTEXT_CLIENT_VERSION, 
    openGLVersionRequested,  // selects OpenGL ES 3.0, set to 2 to select OpenGL ES 2.0 
    EGL_NONE 
}; 
context = eglCreateContext(display, config, NULL, contextAttribs); 
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { 
    LOGW("Unable to eglMakeCurrent"); 
    return -1; 
} 
+0

這是驅動程序更新問題。 – gmmo