Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5371 | serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | |||
7 | |||
8 | #define GL_GLEXT_PROTOTYPES |
||
9 | |||
10 | |||
11 | #include "EGL/eglext.h" |
||
12 | #include "GL/gl.h" |
||
13 | #include "gbm.h" |
||
14 | #include "pxgl.h" |
||
15 | |||
16 | |||
17 | |||
18 | |||
19 | { |
||
20 | EGLConfig config = NULL; |
||
21 | EGLint config_attribs[32]; |
||
22 | EGLint num_configs, i; |
||
23 | |||
24 | |||
25 | config_attribs[i++] = EGL_RED_SIZE; |
||
26 | config_attribs[i++] = 1; |
||
27 | config_attribs[i++] = EGL_GREEN_SIZE; |
||
28 | config_attribs[i++] = 1; |
||
29 | config_attribs[i++] = EGL_BLUE_SIZE; |
||
30 | config_attribs[i++] = 1; |
||
31 | config_attribs[i++] = EGL_DEPTH_SIZE; |
||
32 | config_attribs[i++] = 1; |
||
33 | |||
34 | |||
35 | config_attribs[i++] = EGL_WINDOW_BIT; |
||
36 | |||
37 | |||
38 | config_attribs[i++] = EGL_OPENGL_BIT; |
||
39 | config_attribs[i] = EGL_NONE; |
||
40 | |||
41 | |||
42 | |||
43 | |||
44 | }; |
||
45 | |||
46 | |||
47 | { |
||
48 | EGLint major, minor; |
||
49 | int fd; |
||
50 | |||
51 | |||
52 | if(fd == 0) |
||
53 | return -1; |
||
54 | |||
55 | |||
56 | if( gbm == NULL) |
||
57 | { |
||
58 | DBG("failed to initialize GBM device\n"); |
||
59 | goto err_0; |
||
60 | }; |
||
61 | |||
62 | |||
63 | |||
64 | |||
65 | { |
||
66 | DBG("failed to initialize EGL display\n"); |
||
67 | goto err_1; |
||
68 | }; |
||
69 | |||
70 | |||
71 | DBG("EGL_VENDOR = %s\n", eglQueryString(*dpy, EGL_VENDOR)); |
||
72 | DBG("EGL_EXTENSIONS = %s\n", eglQueryString(*dpy, EGL_EXTENSIONS)); |
||
73 | DBG("EGL_CLIENT_APIS = %s\n", eglQueryString(*dpy, EGL_CLIENT_APIS)); |
||
74 | |||
75 | |||
76 | if( *config == NULL) |
||
77 | { |
||
78 | DBG("failed to choose a config\n"); |
||
79 | goto err_2; |
||
80 | }; |
||
81 | |||
82 | |||
83 | *context = eglCreateContext(*dpy, *config, EGL_NO_CONTEXT, NULL); |
||
84 | if (context == NULL) |
||
85 | { |
||
86 | DBG("failed to create context\n"); |
||
87 | goto err_2; |
||
88 | }; |
||
89 | |||
90 | |||
91 | { |
||
92 | DBG("failed to make context current"); |
||
93 | goto err_3; |
||
94 | }; |
||
95 | |||
96 | |||
97 | |||
98 | |||
99 | eglDestroyContext(*dpy, *context); |
||
100 | err_2: |
||
101 | eglTerminate(*dpy); |
||
102 | err_1: |
||
103 | gbm_device_destroy(gbm); |
||
104 | err_0: |
||
105 | return -1; |
||
106 | }; |
||
107 | |||
108 | |||
109 | { |
||
110 | eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
||
111 | eglDestroyContext(dpy, context); |
||
112 | eglTerminate(dpy); |
||
113 | gbm_device_destroy(gbm); |
||
114 | }; |
||
115 |