diff options
author | Joe Crayne <joe@jerkface.net> | 2019-04-30 12:00:46 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-05-06 19:44:07 -0400 |
commit | fcf51c414e06ff24e7f2ec350ef0cef20b6238d2 (patch) | |
tree | 2a22c83cd3bd333667a729b66e13488816c93acd /src/LambdaCube/GL/Backend.hs | |
parent | 154b25e0ad8a8ecedb02876215d29c12e87e6c93 (diff) |
TextureCube support.
Diffstat (limited to 'src/LambdaCube/GL/Backend.hs')
-rw-r--r-- | src/LambdaCube/GL/Backend.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/LambdaCube/GL/Backend.hs b/src/LambdaCube/GL/Backend.hs index 08f10d4..f3bfe47 100644 --- a/src/LambdaCube/GL/Backend.hs +++ b/src/LambdaCube/GL/Backend.hs | |||
@@ -4,6 +4,7 @@ module LambdaCube.GL.Backend where | |||
4 | import Control.Applicative | 4 | import Control.Applicative |
5 | import Control.Monad | 5 | import Control.Monad |
6 | import Control.Monad.State.Strict | 6 | import Control.Monad.State.Strict |
7 | import Data.Coerce | ||
7 | import Data.Maybe | 8 | import Data.Maybe |
8 | import Data.Bits | 9 | import Data.Bits |
9 | import Data.IORef | 10 | import Data.IORef |
@@ -489,7 +490,7 @@ createStreamCommands texUnitMap topUnis attrs primitive prg = streamUniCmds ++ s | |||
489 | , let texUnit = Map.findWithDefault (error "internal error (createStreamCommands - Texture Unit)") n texUnitMap | 490 | , let texUnit = Map.findWithDefault (error "internal error (createStreamCommands - Texture Unit)") n texUnitMap |
490 | ] | 491 | ] |
491 | uniInputType (GLTypedUniform ty _) = unwitnessType ty | 492 | uniInputType (GLTypedUniform ty _) = unwitnessType ty |
492 | uniInputType (GLUniform ty _) = ty | 493 | uniInputType (GLUniform r) = objectType r |
493 | 494 | ||
494 | 495 | ||
495 | -- object attribute stream commands | 496 | -- object attribute stream commands |
@@ -768,12 +769,10 @@ renderSlot glDrawCallCounterRef glVertexBufferRef glIndexBufferRef cmds = forM_ | |||
768 | glDrawElements mode count typ indicesPtr | 769 | glDrawElements mode count typ indicesPtr |
769 | modifyIORef glDrawCallCounterRef succ | 770 | modifyIORef glDrawCallCounterRef succ |
770 | GLSetUniform idx (GLTypedUniform ty ref) -> setUniform idx ty (readIORef ref) | 771 | GLSetUniform idx (GLTypedUniform ty ref) -> setUniform idx ty (readIORef ref) |
771 | GLSetUniform idx (GLUniform ty ref) -> return () -- putStrLn $ "TODO: setUniform FTexture2D" | 772 | GLSetUniform idx (GLUniform ref) -> return () -- putStrLn $ "TODO: setUniform FTexture2D" |
772 | GLBindTexture txTarget tuRef (GLUniform _ ref) -> do | 773 | GLBindTexture txTarget tuRef (GLUniform ref) -> do |
773 | txObjVal <- readIORef ref | 774 | txObj <- coerce <$> readIORef ref |
774 | -- HINT: ugly and hacky | 775 | do |
775 | with txObjVal $ \txObjPtr -> do | ||
776 | txObj <- peek $ castPtr txObjPtr :: IO GLuint | ||
777 | texUnit <- readIORef tuRef | 776 | texUnit <- readIORef tuRef |
778 | glActiveTexture $ GL_TEXTURE0 + fromIntegral texUnit | 777 | glActiveTexture $ GL_TEXTURE0 + fromIntegral texUnit |
779 | glBindTexture txTarget txObj | 778 | glBindTexture txTarget txObj |