packages feed

wgpu-raw-hs 0.1.0.3 → 0.2.0.0

raw patch · 6 files changed

+91/−13 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for wgpu-raw-hs +## 0.2.0.0 -- 2021-08-22++- Microsoft Windows support.+ ## 0.1.0.3 -- 2021-08-20  - Removed slightly-broken `triangle` example. There is now a fully-working
+ LICENSE view
@@ -0,0 +1,26 @@+Copyright 2021 Jonathan Merritt.++Redistribution and use in source and binary forms, with or without modification,+are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+   list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice,+   this list of conditions and the following disclaimer in the documentation+   and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors+   may be used to endorse or promote products derived from this software without+   specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
src/WGPU/Raw/Dynamic.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE CPP #-} --- | module WGPU.Raw.Dynamic   ( -- * Functions     withWGPU,@@ -25,7 +24,7 @@ #endif  #ifdef WGPUHS_WINDOWS-import Foreign (castPtrToFunPtr)+import Foreign (FunPtr, castPtrToFunPtr) import System.Win32.DLL (loadLibrary, freeLibrary, getProcAddress)  -- | Load WGPU from a dynamic library and run a program using an instance.@@ -40,8 +39,9 @@   -- TODO: safer bracketing   hInstance <- loadLibrary dynlibFile   let load :: String -> IO (FunPtr a)-      load = castPtrToFunPtr <$> getProcAddress+      load = fmap castPtrToFunPtr . getProcAddress hInstance   wgpuHsInstance <- loadDynamicInstance load-  action wgpuHsInstance+  result <- action wgpuHsInstance   freeLibrary hInstance+  pure result #endif
src/WGPU/Raw/GLFWSurface.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE ForeignFunctionInterface #-}+{-# OPTIONS_GHC -Wno-unused-imports #-} --- | module WGPU.Raw.GLFWSurface where  import Foreign (Ptr, alloca, castPtr, nullPtr, poke)@@ -10,11 +10,12 @@ import WGPU.Raw.Generated.Fun (WGPUHsInstance, wgpuInstanceCreateSurface) import WGPU.Raw.Generated.Struct.WGPUChainedStruct import WGPU.Raw.Generated.Struct.WGPUSurfaceDescriptor-import WGPU.Raw.Generated.Struct.WGPUSurfaceDescriptorFromMetalLayer import WGPU.Raw.Types (WGPUInstance (WGPUInstance), WGPUSurface)  #ifdef WGPUHS_TARGET_MACOS +import WGPU.Raw.Generated.Struct.WGPUSurfaceDescriptorFromMetalLayer+ createSurface ::   WGPUHsInstance ->   GLFW.Window ->@@ -71,5 +72,57 @@   GLFW.Window ->   IO WGPUSurface createSurface inst window = error "Linux: not yet implemented."++#endif++#ifdef WGPUHS_TARGET_WINDOWS++import System.Win32.DLL (getModuleHandle)+import WGPU.Raw.Generated.Struct.WGPUSurfaceDescriptorFromWindowsHWND++createSurface ::+  WGPUHsInstance ->+  GLFW.Window ->+  IO WGPUSurface+createSurface inst window = do+  hWnd <- GLFW.getWin32Window window+  hInstance <- getModuleHandle Nothing++  alloca $ \ptr_surfaceDescriptor -> do+    alloca $ \ptr_chainedStruct -> do+      alloca $ \ptr_surfaceDescriptorFromWindowHWND -> do++        let surfaceDescriptorFromWindowHWND =+              WGPUSurfaceDescriptorFromWindowsHWND+              { chain =+                  WGPUChainedStruct+                  { next = nullPtr,+                    sType = WGPUSType.SurfaceDescriptorFromWindowsHWND+                  },+                hinstance = hInstance,+                hwnd = hWnd+              }+        poke+          ptr_surfaceDescriptorFromWindowHWND+          surfaceDescriptorFromWindowHWND++        let chainedStruct =+             WGPUChainedStruct+               { next = castPtr ptr_surfaceDescriptorFromWindowHWND,+                 sType = WGPUSType.SurfaceDescriptorFromWindowsHWND+               }+        poke ptr_chainedStruct chainedStruct++        let surfaceDescriptor =+              WGPUSurfaceDescriptor+                { nextInChain = ptr_chainedStruct,+                  label = nullPtr+                }+        poke ptr_surfaceDescriptor surfaceDescriptor++        wgpuInstanceCreateSurface+          inst+          (WGPUInstance nullPtr)+          ptr_surfaceDescriptor  #endif
src/WGPU/Raw/Types.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} --- | module WGPU.Raw.Types where  import Data.Word (Word32)
wgpu-raw-hs.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               wgpu-raw-hs-version:            0.1.0.3+version:            0.2.0.0 synopsis:           WGPU Raw description:   A very low-level WGPU binding.@@ -9,6 +9,7 @@  bug-reports:        https://github.com/lancelet/wgpu-hs/issues license:            BSD-3-Clause+license-file:       LICENSE author:             Jonathan Merritt maintainer:         j.s.merritt@gmail.com copyright:          Copyright (C) Jonathan Merritt, 2021@@ -20,11 +21,6 @@  flag glfw   description: Enable GLFW integration-  default:     True-  manual:      True--flag examples-  description: Build the example(s)   default:     True   manual:      True