packages feed

GLUtil 0.10.3 → 0.10.4

raw patch · 4 files changed

+45/−12 lines, 4 filesdep +GLFW-bdep +GLUtildep +binarydep −hppdep ~OpenGLdep ~basenew-component:exe:example1

Dependencies added: GLFW-b, GLUtil, binary

Dependencies removed: hpp

Dependency ranges changed: OpenGL, base

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.10.4++- Fix profiled builds with GHC >= 8.8 (@maoe)+- Fix floating point RGBA texture support+ # 0.10.1 Bump `OpenGLRaw` upper bound 
GLUtil.cabal view
@@ -1,5 +1,5 @@ Name:                GLUtil-Version:             0.10.3+Version:             0.10.4 Synopsis:            Miscellaneous OpenGL utilities. License:             BSD3 License-file:        LICENSE@@ -19,12 +19,18 @@                     examples/shaders/hello-gl.frag,                     examples/shaders/hello-gl.vert,                     CHANGELOG.md-tested-with:        GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1+tested-with:        GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3,+                    GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1  source-repository head   type:     git   location: http://github.com/acowley/GLUtil.git +flag demos+  description: Build demonstration programs+  default:     False+  manual:      True+ Library   Exposed-modules:     Graphics.GLUtil,                        Graphics.GLUtil.GLError,@@ -54,9 +60,14 @@                        transformers >= 0.3,                        vector >= 0.7   if (impl(ghc >= 7.10.1) && (!os(windows)))-    Build-depends:      hpp >= 0.3.1 && < 0.7-    Build-tool-depends: hpp:hpp-    GHC-Options:        -pgmPhpp -optP--cpp -optP-P+    -- Build-depends:      hpp >= 0.3.1 && < 0.7+    Build-tool-depends: hpp:hpp >= 0.3.1 && < 0.7+    if impl(ghc >= 8.8.1)+      -- As of GHC 8.8.1, GHC started complaining about -optP--cpp when profling+      -- is enabled. See https://gitlab.haskell.org/ghc/ghc/issues/17185.+      GHC-Options:        -pgmP "hpp --cpp -P"+    else+      GHC-Options:        -pgmPhpp -optP--cpp -optP-P   else     Build-tool-depends: cpphs:cpphs     GHC-Options:        -pgmPcpphs -optP--cpp -optP--hashes@@ -64,3 +75,13 @@   GHC-Options:         -O2 -Wall   HS-Source-Dirs:      src   default-language:    Haskell2010++executable example1+  if !flag(demos)+    buildable: False+  main-is: example1.hs+  other-modules: TGA+  build-depends: base, bytestring, binary, filepath, OpenGL, GLUtil+               , GLFW-b >= 3.3.0.0 && < 3.4+  hs-source-dirs: examples+  default-language: Haskell2010
examples/example1.hs view
@@ -15,7 +15,7 @@ -- | A value to carry around a shader program and its parameters. data Shaders = Shaders { getProgram        :: Program                        , fadeFactorU    :: UniformLocation-                       , texturesU      :: [UniformLocation] +                       , texturesU      :: [UniformLocation]                        , positionA      :: AttribLocation }  -- | The resources used for drawing our scene.@@ -31,7 +31,7 @@  -- | Load a texture and set some texturing parameters. makeTexture :: FilePath -> IO TextureObject-makeTexture filename = +makeTexture filename =     do (width,height,pixels) <- readTGA filename        tex <- loadTexture $ texInfo width height TexBGR pixels        textureFilter   Texture2D   $= ((Linear', Nothing), Linear')@@ -42,21 +42,22 @@ -- | Load and compile our GLSL program, and pull out the parameters we -- want. initShaders :: IO Shaders-initShaders = do vs <- loadShader VertexShader $ "shaders" </> "hello-gl.vert"-                 fs <- loadShader FragmentShader $ "shaders" </> "hello-gl.frag"+initShaders = do vs <- loadShader VertexShader $ shaderDir </> "hello-gl.vert"+                 fs <- loadShader FragmentShader $ shaderDir </> "hello-gl.frag"                  p <- linkShaderProgram [vs,fs]                  Shaders p                    <$> get (uniformLocation p "fade_factor")                    <*> mapM (get . uniformLocation p)                          ["textures[0]", "textures[1]"]                    <*> get (attribLocation p "position")+  where shaderDir = "examples" </> "shaders"  -- | Load our geometry and textures into OpenGL. makeResources :: IO Resources makeResources =  Resources              <$> makeBuffer ArrayBuffer vertexBufferData              <*> makeBuffer ElementArrayBuffer [0..3::GLuint]-             <*> mapM (makeTexture . ("images" </>)) +             <*> mapM (makeTexture . (("examples" </> "images") </>))                       ["hello1.tga", "hello2.tga"]              <*> initShaders              <*> pure 0.0@@ -102,7 +103,7 @@ main :: IO () main = do ok <- init           when (not ok) (error "Error initializing GLFW!")-          windowHint $ WindowHint'RefreshRate 100+          windowHint $ WindowHint'RefreshRate (Just 100)           m@(~(Just w)) <- createWindow 500 500 "Chapter 2" Nothing Nothing           when (isNothing m) (error "Couldn't create window!")           makeContextCurrent m
src/Graphics/GLUtil/Textures.hs view
@@ -111,7 +111,13 @@                           _ -> error "Unknown pixelType for TexRG"         loadTex TexRGB = loadAux RGBA' RGB         loadTex TexBGR = loadAux RGBA' BGR-        loadTex TexRGBA = loadAux RGBA' RGBA+        loadTex TexRGBA = case pixelType of+                            GL.UnsignedShort -> loadAux RGBA16 RGBA+                            GL.Float -> loadAux RGBA32F RGBA+                            GL.HalfFloat -> loadAux RGBA16F RGBA+                            GL.Int -> loadAux RGBA32I RGBAInteger+                            GL.UnsignedInt -> loadAux RGBA32UI RGBAInteger+                            _ -> loadAux RGBA' RGBA         sz = TextureSize2D (texWidth tex) (texHeight tex)         pixelType = glType (undefined::Elem a)         loadAux i e = withPixels (texData tex) $