MCPcopy Create free account
hub / github.com/android/ndk-samples / loadShader

Function loadShader

hello-gl2/app/src/main/cpp/gl_code.cpp:55–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 "}\n";
54
55GLuint loadShader(GLenum shaderType, const char* pSource) {
56 GLuint shader = glCreateShader(shaderType);
57 if (shader) {
58 glShaderSource(shader, 1, &pSource, NULL);
59 glCompileShader(shader);
60 GLint compiled = 0;
61 glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
62 if (!compiled) {
63 GLint infoLen = 0;
64 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
65 if (infoLen) {
66 char* buf = (char*)malloc(infoLen);
67 if (buf) {
68 glGetShaderInfoLog(shader, infoLen, NULL, buf);
69 LOGE("Could not compile shader %d:\n%s\n", shaderType, buf);
70 free(buf);
71 }
72 glDeleteShader(shader);
73 shader = 0;
74 }
75 }
76 }
77 return shader;
78}
79
80GLuint createProgram(const char* pVertexSource, const char* pFragmentSource) {
81 GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource);

Callers 2

createProgramFunction · 0.85
createProgramMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected