Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/browser/glut_glutget.c
7085 views
1
// Copyright 2018 The Emscripten Authors. All rights reserved.
2
// Emscripten is available under two separate licenses, the MIT license and the
3
// University of Illinois/NCSA Open Source License. Both these licenses can be
4
// found in the LICENSE file.
5
6
#include <assert.h>
7
#include <stdio.h>
8
#include <stdbool.h>
9
#include <GL/gl.h>
10
#include <GL/glut.h>
11
12
int main(int argc, char* argv[]) {
13
bool stencilActivated = false;
14
bool depthActivated = false;
15
bool alphaActivated = false;
16
bool antiAliasingActivated = false;
17
18
unsigned int mode = GLUT_RGBA | GLUT_DOUBLE;
19
20
#ifdef STENCIL_ACTIVATED
21
stencilActivated = true;
22
mode |= GLUT_STENCIL;
23
#endif
24
#ifdef DEPTH_ACTIVATED
25
depthActivated = true;
26
mode |= GLUT_DEPTH;
27
#endif
28
#ifdef ALPHA_ACTIVATED
29
alphaActivated = true;
30
mode |= GLUT_ALPHA;
31
#endif
32
#ifdef AA_ACTIVATED
33
antiAliasingActivated = true;
34
mode |= GLUT_MULTISAMPLE;
35
#endif
36
37
glutInit(&argc, argv);
38
glutInitWindowSize(640, 480);
39
glutInitDisplayMode(mode);
40
glutCreateWindow(__FILE__);
41
42
printf("stencil: %d\n", glutGet(GLUT_WINDOW_STENCIL_SIZE));
43
printf("depth: %d\n", glutGet(GLUT_WINDOW_DEPTH_SIZE));
44
printf("alpha: %d\n", glutGet(GLUT_WINDOW_ALPHA_SIZE));
45
printf("antialias: %d\n", glutGet(GLUT_WINDOW_NUM_SAMPLES));
46
assert(!stencilActivated || glutGet(GLUT_WINDOW_STENCIL_SIZE) > 0);
47
assert(!depthActivated || glutGet(GLUT_WINDOW_DEPTH_SIZE) > 0);
48
assert(!alphaActivated || glutGet(GLUT_WINDOW_ALPHA_SIZE) > 0);
49
assert(!antiAliasingActivated || glutGet(GLUT_WINDOW_NUM_SAMPLES) > 0);
50
51
// fix-up "ReferenceError: GL is not defined,createContext" due to
52
// overzealous JS stripping
53
glClear(0);
54
55
return 0;
56
}
57
58