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

Function gears_init

test/full_es2_sdlproc.c:653–714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651"}";
652
653static void
654gears_init(void)
655{
656 GLuint v, f, program;
657 const char *p;
658 char msg[512];
659
660 glEnable(GL_CULL_FACE);
661 glEnable(GL_DEPTH_TEST);
662
663 /* Compile the vertex shader */
664 p = vertex_shader;
665 v = glCreateShader(GL_VERTEX_SHADER);
666 glShaderSource(v, 1, &p, NULL);
667 glCompileShader(v);
668 glGetShaderInfoLog(v, sizeof msg, NULL, msg);
669 printf("vertex shader info: %s\n", msg);
670
671 /* Compile the fragment shader */
672 p = fragment_shader;
673 f = glCreateShader(GL_FRAGMENT_SHADER);
674 glShaderSource(f, 1, &p, NULL);
675 glCompileShader(f);
676 glGetShaderInfoLog(f, sizeof msg, NULL, msg);
677 printf("fragment shader info: %s\n", msg);
678
679 /* Create and link the shader program */
680 program = glCreateProgram();
681 glAttachShader(program, v);
682 glAttachShader(program, f);
683 glBindAttribLocation(program, 0, "position");
684 glBindAttribLocation(program, 1, "normal");
685
686 glLinkProgram(program);
687 glGetProgramInfoLog(program, sizeof msg, NULL, msg);
688 printf("info: %s\n", msg);
689
690 /* Enable the shaders */
691 glUseProgram(program);
692
693 /* Get the locations of the uniforms so we can access them */
694 ModelViewProjectionMatrix_location = glGetUniformLocation(program, "ModelViewProjectionMatrix");
695 NormalMatrix_location = glGetUniformLocation(program, "NormalMatrix");
696 LightSourcePosition_location = glGetUniformLocation(program, "LightSourcePosition");
697 MaterialColor_location = glGetUniformLocation(program, "MaterialColor");
698
699 /* Set the LightSourcePosition uniform which is constant throught the program */
700 glUniform4fv(LightSourcePosition_location, 1, LightSourcePosition);
701
702 {
703 GLfloat LightSourcePosition_copy[4];
704 glGetUniformfv(program, LightSourcePosition_location, LightSourcePosition_copy);
705 for (uint32_t i = 0; i < 4; ++i) {
706 assert(LightSourcePosition[i] == LightSourcePosition_copy[i]);
707 }
708 }
709
710 /* make the gears */

Callers 1

mainFunction · 0.70

Calls 4

printfFunction · 0.85
glUniform4fvFunction · 0.85
create_gearFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected