102e55062064d443d2300157515e9aaa8d0d5585
[mesa.git] / src / egl / main / eglglobals.c
1 #include <stdio.h>
2 #include "eglglobals.h"
3
4
5 struct _egl_global _eglGlobal = { EGL_FALSE };
6
7
8 /**
9 * Init the fields in the _eglGlobal struct
10 * May be safely called more than once.
11 */
12 void
13 _eglInitGlobals(void)
14 {
15 if (!_eglGlobal.Initialized) {
16 _eglGlobal.Displays = _eglNewHashTable();
17 _eglGlobal.Contexts = _eglNewHashTable();
18 _eglGlobal.Surfaces = _eglNewHashTable();
19 _eglGlobal.CurrentContext = EGL_NO_CONTEXT;
20 _eglGlobal.LastError = EGL_SUCCESS;
21 _eglGlobal.Initialized = EGL_TRUE;
22 }
23 }
24
25
26 /**
27 * Should call this via an atexit handler.
28 */
29 void
30 _eglDestroyGlobals(void)
31 {
32 /* XXX TODO walk over table entries, deleting each */
33 _eglDeleteHashTable(_eglGlobal.Displays);
34 _eglDeleteHashTable(_eglGlobal.Contexts);
35 _eglDeleteHashTable(_eglGlobal.Surfaces);
36 }
37
38
39
40 /**
41 * Record EGL error code.
42 */
43 void
44 _eglError(EGLint errCode, const char *msg)
45 {
46 if (_eglGlobal.LastError == EGL_SUCCESS) {
47 _eglGlobal.LastError = errCode;
48 /* XXX temporary */
49 fprintf(stderr, "EGL Error 0x%x in %s\n", errCode, msg);
50 }
51 }