Skip to content

Commit

Permalink
wgl: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
msiglreith committed Jun 27, 2019
1 parent 6ab3d33 commit c6e95e7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
23 changes: 17 additions & 6 deletions src/backend/gl/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ impl d::Device<B> for Device {
}
n::ImageKind::Texture {
texture: name,
target: glow::TEXTURE_2D,
target: glow::TEXTURE_2D,
format: iformat,
pixel_type: itype,
}
Expand Down Expand Up @@ -1333,7 +1333,7 @@ impl d::Device<B> for Device {
}
n::ImageKind::Texture {
texture: name,
target: glow::TEXTURE_2D_ARRAY,
target: glow::TEXTURE_2D_ARRAY,
format: iformat,
pixel_type: itype,
}
Expand Down Expand Up @@ -1796,6 +1796,17 @@ impl d::Device<B> for Device {
unimplemented!()
}

#[cfg(target_arch = "wasm32")]
unsafe fn create_swapchain(
&self,
surface: &mut Surface,
config: c::SwapchainConfig,
_old_swapchain: Option<Swapchain>,
) -> Result<(Swapchain, Vec<n::Image>), c::window::CreationError> {
Ok(self.create_swapchain_impl(surface, config))
}

#[cfg(not(target_arch = "wasm32"))]
unsafe fn create_swapchain(
&self,
surface: &mut Surface,
Expand Down Expand Up @@ -1845,12 +1856,12 @@ impl d::Device<B> for Device {
n::ImageKind::Surface(surface) => {
gl.framebuffer_renderbuffer(glow::FRAMEBUFFER, glow::COLOR_ATTACHMENT0, glow::RENDERBUFFER, Some(surface));
}
n::ImageKind::Texture(texture, textype) => {
n::ImageKind::Texture { texture, target, .. } => {
if self.share.private_caps.framebuffer_texture {
gl.framebuffer_texture(glow::FRAMEBUFFER, glow::COLOR_ATTACHMENT0, Some(texture), 0);
} else {
gl.bind_texture(textype, Some(texture));
gl.framebuffer_texture_2d(glow::FRAMEBUFFER, glow::COLOR_ATTACHMENT0, textype, Some(texture), 0);
gl.bind_texture(target, Some(texture));
gl.framebuffer_texture_2d(glow::FRAMEBUFFER, glow::COLOR_ATTACHMENT0, target, Some(texture), 0);
}
}
}
Expand All @@ -1868,7 +1879,7 @@ impl d::Device<B> for Device {
let swapchain = Swapchain {
fbos,
extent: config.extent,
window: surface.window.clone(),
context: surface.context.clone(),
};

Ok((swapchain, images))
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gl/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ impl hal::queue::RawCommandQueue<Backend> for CommandQueue {
);

#[cfg(feature = "glutin")]
swapchain.0.borrow().context.swap_buffers().unwrap();
swapchain.borrow().context.swap_buffers().unwrap();
#[cfg(feature = "wgl")]
swapchain.borrow().swap_buffers();
}
Expand Down
6 changes: 3 additions & 3 deletions src/backend/gl/src/window/glutin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl hal::Swapchain<B> for Swapchain {
// and actually respect the swapchain configuration provided by the user.
#[derive(Debug)]
pub struct Surface {
context: Starc<glutin::WindowedContext<glutin::PossiblyCurrent>>,
pub(crate) context: Starc<glutin::WindowedContext<glutin::PossiblyCurrent>>,
}

impl Surface {
Expand Down Expand Up @@ -172,7 +172,7 @@ impl hal::Surface<B> for Surface {
impl hal::Instance for Surface {
type Backend = B;
fn enumerate_adapters(&self) -> Vec<hal::Adapter<B>> {
let adapter = PhysicalDevice::new_adapter(GlContainer::from_fn_proc(|s| {
let adapter = PhysicalDevice::new_adapter((), GlContainer::from_fn_proc(|s| {
self.context.get_proc_address(s) as *const _
}));
vec![adapter]
Expand Down Expand Up @@ -212,7 +212,7 @@ impl Headless {
impl hal::Instance for Headless {
type Backend = B;
fn enumerate_adapters(&self) -> Vec<hal::Adapter<B>> {
let adapter = PhysicalDevice::new_adapter(GlContainer::from_fn_proc(|s| {
let adapter = PhysicalDevice::new_adapter((), GlContainer::from_fn_proc(|s| {
self.0.get_proc_address(s) as *const _
}));
vec![adapter]
Expand Down

0 comments on commit c6e95e7

Please sign in to comment.