| 46 | } |
| 47 | |
| 48 | int main() |
| 49 | { |
| 50 | EmscriptenWebGLContextAttributes attr; |
| 51 | emscripten_webgl_init_context_attributes(&attr); |
| 52 | #ifdef EXPLICIT_SWAP |
| 53 | attr.explicitSwapControl = 1; |
| 54 | #endif |
| 55 | |
| 56 | EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr); |
| 57 | emscripten_webgl_make_context_current(ctx); |
| 58 | |
| 59 | GLboolean extAvailable = emscripten_webgl_enable_WEBGL_multi_draw(ctx); |
| 60 | |
| 61 | if (!extAvailable) { |
| 62 | EM_ASM({ |
| 63 | skipTest('WEBGL_multi_draw is not supported'); |
| 64 | }); |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | static const char vertex_shader[] = |
| 69 | "attribute vec4 apos;" |
| 70 | "attribute vec4 acolor;" |
| 71 | "varying vec4 color;" |
| 72 | "void main() {" |
| 73 | "color = acolor;" |
| 74 | "gl_Position = apos;" |
| 75 | "}"; |
| 76 | GLuint vs = compile_shader(GL_VERTEX_SHADER, vertex_shader); |
| 77 | |
| 78 | static const char fragment_shader[] = |
| 79 | "precision lowp float;" |
| 80 | "varying vec4 color;" |
| 81 | "void main() {" |
| 82 | "gl_FragColor = color;" |
| 83 | "}"; |
| 84 | GLuint fs = compile_shader(GL_FRAGMENT_SHADER, fragment_shader); |
| 85 | |
| 86 | GLuint program = create_program(vs, fs); |
| 87 | glUseProgram(program); |
| 88 | |
| 89 | static const float pos_and_color[] = { |
| 90 | // x, y, r, g, b |
| 91 | -0.5f, -0.5f, 1, 0, 0, |
| 92 | 0.5f, -0.5f, 0, 1, 0, |
| 93 | -0.5f, 0.5f, 0, 0, 1, |
| 94 | 0.5f, 0.5f, 1, 1, 1, |
| 95 | -0.5f, 0.5f, 0, 0, 1, |
| 96 | 0.5f, -0.5f, 0, 1, 0, |
| 97 | }; |
| 98 | |
| 99 | // 2 -- 3 |
| 100 | // | \ | |
| 101 | // | \ | |
| 102 | // 0 -- 1 |
| 103 | static const GLushort indices[] = { |
| 104 | 0, 1, 2, |
| 105 | 3, 2, 1 |
nothing calls this directly
no test coverage detected