Commit c4ee2fc8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

gl: add resize callback

At least the Wayland EGL backend needs to be notified of the size of
the window (which is independent of glViewport()).

This could conceivably also be implemented with a call to
glGetIntegerv(GL_VIEWPORT), but that would introduce a dependency on
the GL - which the EGL plugin has avoided so far.
parent 77028e4a
......@@ -47,6 +47,7 @@ struct vlc_gl_t
int (*makeCurrent)(vlc_gl_t *);
void (*releaseCurrent)(vlc_gl_t *);
void (*resize)(vlc_gl_t *, unsigned, unsigned);
void (*swap)(vlc_gl_t *);
int (*lock)(vlc_gl_t *);
void (*unlock)(vlc_gl_t *);
......@@ -83,6 +84,12 @@ static inline void vlc_gl_Unlock(vlc_gl_t *gl)
gl->unlock(gl);
}
static inline void vlc_gl_Resize(vlc_gl_t *gl, unsigned w, unsigned h)
{
if (gl->resize != NULL)
gl->resize(gl, w, h);
}
static inline void vlc_gl_Swap(vlc_gl_t *gl)
{
gl->swap(gl);
......
......@@ -308,6 +308,7 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
/* Initialize OpenGL callbacks */
gl->makeCurrent = MakeCurrent;
gl->releaseCurrent = ReleaseCurrent;
gl->resize = NULL;
gl->swap = SwapBuffers;
gl->getProcAddress = GetSymbol;
gl->lock = NULL;
......
......@@ -123,6 +123,8 @@ static int Open (vlc_object_t *obj)
if (sys->gl == NULL)
goto error;
vlc_gl_Resize (sys->gl, cfg.width, cfg.height);
/* Initialize video display */
const vlc_fourcc_t *spu_chromas;
......@@ -233,6 +235,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
vout_display_place_t place;
vout_display_PlacePicture (&place, src, c, false);
vlc_gl_Resize (sys->gl, place.width, place.height);
vlc_gl_MakeCurrent (sys->gl);
glViewport (place.x, place.y, place.width, place.height);
vlc_gl_ReleaseCurrent (sys->gl);
......
......@@ -205,6 +205,7 @@ static int Open (vlc_object_t *obj)
gl->sys = sys;
gl->makeCurrent = MakeCurrent;
gl->releaseCurrent = ReleaseCurrent;
gl->resize = NULL;
gl->swap = SwapBuffers;
gl->getProcAddress = GetSymbol;
gl->lock = NULL;
......
......@@ -133,8 +133,10 @@ vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
vlc_gl_t *gl = vlc_gl_Create(surface, VLC_OPENGL, "glx");
if (gl == NULL) {
vout_window_Delete(surface);
goto error;
return NULL;
}
vlc_gl_Resize(gl, cfg->width, cfg->height);
return gl;
error:
......@@ -165,6 +167,8 @@ bool vlc_gl_surface_CheckSize(vlc_gl_t *gl, unsigned *restrict width,
*height = sys->height;
sys->width = -1;
sys->height = -1;
vlc_gl_Resize(gl, *width, *height);
ret = true;
}
vlc_mutex_unlock(&sys->lock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment