File: webgl_unmasked_vendor_webgl.c

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 121,872 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,365; asm: 2,415; lisp: 1,869
file content (38 lines) | stat: -rw-r--r-- 1,122 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <string.h>
#include <emscripten/html5.h>
#include <GLES2/gl2.h>
#include <webgl/webgl1_ext.h>
#include <assert.h>

int main()
{
  EmscriptenWebGLContextAttributes attr;
  emscripten_webgl_init_context_attributes(&attr);
  attr.enableExtensionsByDefault = 0;
  EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr);
  emscripten_webgl_make_context_current(ctx);

  assert(!glGetError());

  // This should gracefully return null and record a GL error.
  const char *str = (const char *)glGetString(GL_UNMASKED_VENDOR_WEBGL);
  printf("%s\n", str);
  assert(glGetError());
  assert(!glGetError()); // One error is enough

  bool success = emscripten_webgl_enable_extension(ctx, "WEBGL_debug_renderer_info");
  if (!success)
  {
    // Browser does not have WEBGL_debug_renderer_info, skip remainder and return success.
    return 0;
  }

  assert(!glGetError());

  str = (const char *)glGetString(GL_UNMASKED_VENDOR_WEBGL);
  printf("%s\n", str);
  assert(strlen(str) > 3); // Should get something (dependent on hardware)
  assert(!glGetError());
  return 0;
}