egl: Allow displays to specify surface_type

This commit is contained in:
Victor Brekenfeld 2020-04-22 22:12:15 +02:00
parent 726624cbd8
commit 4647141770
2 changed files with 7 additions and 2 deletions

View File

@ -180,6 +180,7 @@ impl<B: native::Backend, N: native::NativeDisplay<B>> EGLDisplay<B, N> {
) -> Result<(PixelFormat, ffi::egl::types::EGLConfig), Error> { ) -> Result<(PixelFormat, ffi::egl::types::EGLConfig), Error> {
let descriptor = { let descriptor = {
let mut out: Vec<c_int> = Vec::with_capacity(37); let mut out: Vec<c_int> = Vec::with_capacity(37);
let surface_type = self.native.borrow().surface_type();
if self.egl_version >= (1, 2) { if self.egl_version >= (1, 2) {
trace!(self.logger, "Setting COLOR_BUFFER_TYPE to RGB_BUFFER"); trace!(self.logger, "Setting COLOR_BUFFER_TYPE to RGB_BUFFER");
@ -187,12 +188,12 @@ impl<B: native::Backend, N: native::NativeDisplay<B>> EGLDisplay<B, N> {
out.push(ffi::egl::RGB_BUFFER as c_int); out.push(ffi::egl::RGB_BUFFER as c_int);
} }
trace!(self.logger, "Setting SURFACE_TYPE to WINDOW"); trace!(self.logger, "Setting SURFACE_TYPE to {}", surface_type);
out.push(ffi::egl::SURFACE_TYPE as c_int); out.push(ffi::egl::SURFACE_TYPE as c_int);
// TODO: Some versions of Mesa report a BAD_ATTRIBUTE error // TODO: Some versions of Mesa report a BAD_ATTRIBUTE error
// if we ask for PBUFFER_BIT as well as WINDOW_BIT // if we ask for PBUFFER_BIT as well as WINDOW_BIT
out.push((ffi::egl::WINDOW_BIT) as c_int); out.push(surface_type);
match attributes.version { match attributes.version {
Some((3, _)) => { Some((3, _)) => {

View File

@ -133,6 +133,10 @@ pub unsafe trait NativeDisplay<B: Backend> {
fn attributes(&self) -> Vec<ffi::EGLint> { fn attributes(&self) -> Vec<ffi::EGLint> {
vec![ffi::egl::NONE as ffi::EGLint] vec![ffi::egl::NONE as ffi::EGLint]
} }
/// Type of surfaces created
fn surface_type(&self) -> ffi::EGLint {
ffi::egl::WINDOW_BIT as ffi::EGLint
}
/// Create a surface /// Create a surface
fn create_surface(&mut self, args: Self::Arguments) -> Result<B::Surface, Self::Error>; fn create_surface(&mut self, args: Self::Arguments) -> Result<B::Surface, Self::Error>;
} }