MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / compile_shader

Function compile_shader

test/browser/webgl_draw_triangle.c:15–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include <GLES2/gl2.h>
14
15GLuint compile_shader(GLenum shaderType, const char *src) {
16 GLuint shader = glCreateShader(shaderType);
17 glShaderSource(shader, 1, &src, NULL);
18 glCompileShader(shader);
19
20 GLint isCompiled = 0;
21 glGetShaderiv(shader, GL_COMPILE_STATUS, &isCompiled);
22 if (!isCompiled)
23 {
24 GLint maxLength = 0;
25 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
26 char *buf = (char*)malloc(maxLength);
27 glGetShaderInfoLog(shader, maxLength, NULL, buf);
28 printf("%s\n", buf);
29 free(buf);
30 return 0;
31 }
32
33 return shader;
34}
35
36GLuint create_program(GLuint vertexShader, GLuint fragmentShader)
37{

Callers 1

mainFunction · 0.70

Calls 3

printfFunction · 0.85
mallocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected