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

Function CompileShader

test/browser/webgl_sampler_layout_binding.c:14–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include <stdlib.h>
13
14GLuint CompileShader(GLenum type, const char *src)
15{
16 GLuint shader = glCreateShader(type);
17 glShaderSource(shader, 1, &src, NULL);
18 glCompileShader(shader);
19 assert(glGetError() == GL_NO_ERROR && "Shader compilation failed!");
20
21 GLint isCompiled = 0;
22 glGetShaderiv(shader, GL_COMPILE_STATUS, &isCompiled);
23 if (!isCompiled)
24 {
25 GLint maxLength = 0;
26 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
27 char *buf = (char*)malloc(maxLength+1);
28 glGetShaderInfoLog(shader, maxLength, &maxLength, buf);
29 printf("%s\n", buf);
30 free(buf);
31 return 0;
32 }
33
34 return shader;
35}
36
37GLuint CreateProgram(GLuint vertexShader, GLuint fragmentShader)
38{

Callers 1

mainFunction · 0.70

Calls 4

printfFunction · 0.85
assertFunction · 0.50
mallocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected