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

Function shaders

test/browser/gl_ps_packed.c:43–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41#include <assert.h>
42
43void shaders() {
44#if USE_GLEW
45 glewInit();
46#endif
47
48 GLint ok;
49
50 const char *vertexShader = "void main(void) \n"
51 "{ \n"
52 " gl_Position = ftransform(); \n"
53 " gl_TexCoord[0] = gl_MultiTexCoord0; \n"
54 " gl_FrontColor = gl_Color; \n"
55 "} \n";
56 const char *fragmentShader = "uniform sampler2D tex0; \n"
57 "void main(void) \n"
58 "{ \n"
59 " gl_FragColor = gl_Color * texture2D(tex0, gl_TexCoord[0].xy); \n"
60 "} \n";
61
62 GLuint vs = glCreateShader(GL_VERTEX_SHADER);
63 glShaderSource(vs, 1, &vertexShader, NULL);
64 glCompileShader(vs);
65 glGetShaderiv(vs, GL_COMPILE_STATUS, &ok);
66 assert(ok);
67
68 GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
69 glShaderSource(fs, 1, &fragmentShader, NULL);
70 glCompileShader(fs);
71 glGetShaderiv(fs, GL_COMPILE_STATUS, &ok);
72 assert(ok);
73
74 GLuint program = glCreateProgram();
75
76 glAttachShader(program, vs);
77 glAttachShader(program, fs);
78 glLinkProgram(program);
79 glGetProgramiv(program, GL_LINK_STATUS, &ok);
80 assert(ok);
81
82 glUseProgram(program);
83}
84
85int main(int argc, char *argv[])
86{

Callers 1

mainFunction · 0.70

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected