63
63
EGLConfig configs[2];
64
64
EGLint config_count;
66
gboolean is_offscreen;
66
EGLint cfg_attribs[] = {
67
EGL_BUFFER_SIZE, EGL_DONT_CARE,
72
EGL_ALPHA_SIZE, EGL_DONT_CARE,
74
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
68
77
CLUTTER_NOTE (BACKEND, "Realizing main stage");
70
g_object_get (stage_egl->wrapper, "offscreen", &is_offscreen, NULL);
72
79
backend_egl = CLUTTER_BACKEND_EGL (clutter_get_default_backend ());
74
if (G_LIKELY (!is_offscreen))
76
EGLint cfg_attribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE,
81
EGL_ALPHA_SIZE, EGL_DONT_CARE,
83
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
86
status = eglGetConfigs (backend_egl->edpy,
91
if (status != EGL_TRUE)
92
g_warning ("eglGetConfigs failed");
94
status = eglChooseConfig (backend_egl->edpy,
97
G_N_ELEMENTS (configs),
100
if (status != EGL_TRUE)
102
g_critical ("eglChooseConfig failed");
103
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
107
if (stage_egl->egl_surface != EGL_NO_SURFACE)
109
eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface);
110
stage_egl->egl_surface = EGL_NO_SURFACE;
113
if (backend_egl->egl_context)
115
eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
116
backend_egl->egl_context = NULL;
119
stage_egl->egl_surface =
120
eglCreateWindowSurface (backend_egl->edpy,
127
if (stage_egl->egl_surface == EGL_NO_SURFACE)
129
g_critical ("Unable to create an EGL surface");
130
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
134
eglQuerySurface (backend_egl->edpy,
135
stage_egl->egl_surface,
137
&stage_egl->surface_width);
139
eglQuerySurface (backend_egl->edpy,
140
stage_egl->egl_surface,
142
&stage_egl->surface_height);
144
CLUTTER_NOTE (BACKEND, "EGL surface is %ix%i",
145
stage_egl->surface_width,
146
stage_egl->surface_height);
149
if (G_UNLIKELY (backend_egl->egl_context == NULL))
151
CLUTTER_NOTE (GL, "Creating EGL Context");
153
backend_egl->egl_context = eglCreateContext (backend_egl->edpy,
158
if (backend_egl->egl_context == EGL_NO_CONTEXT)
160
g_critical ("Unable to create a suitable EGL context");
162
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
167
/* this will make sure to set the current context */
168
CLUTTER_NOTE (BACKEND, "Setting context");
170
/* this should be done in ClutterBackend::ensure_context */
171
status = eglMakeCurrent (backend_egl->edpy,
172
stage_egl->egl_surface,
173
stage_egl->egl_surface,
174
backend_egl->egl_context);
176
if (status != EGL_TRUE)
178
g_critical ("eglMakeCurrent failed");
179
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
185
g_warning("EGL Backend does not yet support offscreen rendering\n");
186
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
81
status = eglGetConfigs (backend_egl->edpy,
86
if (status != EGL_TRUE)
87
g_warning ("eglGetConfigs failed");
89
status = eglChooseConfig (backend_egl->edpy,
92
G_N_ELEMENTS (configs),
95
if (status != EGL_TRUE)
97
g_critical ("eglChooseConfig failed");
98
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
102
if (stage_egl->egl_surface != EGL_NO_SURFACE)
104
eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface);
105
stage_egl->egl_surface = EGL_NO_SURFACE;
108
if (backend_egl->egl_context)
110
eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
111
backend_egl->egl_context = NULL;
114
stage_egl->egl_surface =
115
eglCreateWindowSurface (backend_egl->edpy,
122
if (stage_egl->egl_surface == EGL_NO_SURFACE)
124
g_critical ("Unable to create an EGL surface");
125
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
129
eglQuerySurface (backend_egl->edpy,
130
stage_egl->egl_surface,
132
&stage_egl->surface_width);
134
eglQuerySurface (backend_egl->edpy,
135
stage_egl->egl_surface,
137
&stage_egl->surface_height);
139
CLUTTER_NOTE (BACKEND, "EGL surface is %ix%i",
140
stage_egl->surface_width,
141
stage_egl->surface_height);
144
if (G_UNLIKELY (backend_egl->egl_context == NULL))
146
CLUTTER_NOTE (GL, "Creating EGL Context");
148
backend_egl->egl_context = eglCreateContext (backend_egl->edpy,
153
if (backend_egl->egl_context == EGL_NO_CONTEXT)
155
g_critical ("Unable to create a suitable EGL context");
157
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
162
/* this will make sure to set the current context */
163
CLUTTER_NOTE (BACKEND, "Setting context");
165
/* this should be done in ClutterBackend::ensure_context */
166
status = eglMakeCurrent (backend_egl->edpy,
167
stage_egl->egl_surface,
168
stage_egl->egl_surface,
169
backend_egl->egl_context);
171
if (status != EGL_TRUE)
173
g_critical ("eglMakeCurrent failed");
174
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);