| 78 | } |
| 79 | |
| 80 | GLuint createProgram(const char* pVertexSource, const char* pFragmentSource) { |
| 81 | GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource); |
| 82 | if (!vertexShader) { |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | GLuint pixelShader = loadShader(GL_FRAGMENT_SHADER, pFragmentSource); |
| 87 | if (!pixelShader) { |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | GLuint program = glCreateProgram(); |
| 92 | if (program) { |
| 93 | glAttachShader(program, vertexShader); |
| 94 | checkGlError("glAttachShader"); |
| 95 | glAttachShader(program, pixelShader); |
| 96 | checkGlError("glAttachShader"); |
| 97 | glLinkProgram(program); |
| 98 | GLint linkStatus = GL_FALSE; |
| 99 | glGetProgramiv(program, GL_LINK_STATUS, &linkStatus); |
| 100 | if (linkStatus != GL_TRUE) { |
| 101 | GLint bufLength = 0; |
| 102 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &bufLength); |
| 103 | if (bufLength) { |
| 104 | char* buf = (char*)malloc(bufLength); |
| 105 | if (buf) { |
| 106 | glGetProgramInfoLog(program, bufLength, NULL, buf); |
| 107 | LOGE("Could not link program:\n%s\n", buf); |
| 108 | free(buf); |
| 109 | } |
| 110 | } |
| 111 | glDeleteProgram(program); |
| 112 | program = 0; |
| 113 | } |
| 114 | } |
| 115 | return program; |
| 116 | } |
| 117 | |
| 118 | GLuint gProgram; |
| 119 | GLuint gvPositionHandle; |
no test coverage detected