Refactor level/room generation modules
This commit is contained in:
+2
-23
@@ -6,13 +6,8 @@ module Picture.Preload
|
||||
import Picture.Data
|
||||
|
||||
import Graphics.Rendering.OpenGL hiding (Point (..),translate,scale,imageHeight,imageWidth)
|
||||
import qualified Graphics.Rendering.OpenGL as GL
|
||||
|
||||
import Codec.Picture
|
||||
import qualified Data.Vector.Storable as V
|
||||
|
||||
import Control.Lens
|
||||
--import Control.Monad
|
||||
|
||||
import Foreign
|
||||
import Shader
|
||||
@@ -20,12 +15,10 @@ import Shader
|
||||
import Geometry (Point2)
|
||||
|
||||
data RenderData = RenderData
|
||||
{ _textures :: [TextureObject]
|
||||
, _lightSourceShader :: FullShader (Float,Float,Float,Float)
|
||||
{ _lightSourceShader :: FullShader (Float,Float,Float,Float)
|
||||
, _wallShadowShader :: FullShader (Point2,Point2,Point2,Point2)
|
||||
, _backgroundShader :: FullShader (Point2,Point2,Point2,Point2)
|
||||
, _listShaders :: [FullShader RenderType]
|
||||
, _backVAO :: VAO
|
||||
, _dummyVBO :: BufferObject
|
||||
, _dummyPtr :: Ptr Float
|
||||
}
|
||||
@@ -87,26 +80,12 @@ preloadRender = do
|
||||
bindBuffer ArrayBuffer $= Just dummyvbo
|
||||
bufferData ArrayBuffer $= (fromIntegral floatSize, dummyptr, StaticDraw)
|
||||
|
||||
Right cmap' <- readImage "data/texture/smudgedDirt.png"
|
||||
let dirt = convertRGBA8 cmap'
|
||||
dirttex <- genObjectName
|
||||
textureBinding Texture2D $= Just dirttex
|
||||
let texData' = V.toList $ imageData dirt
|
||||
wtex' = fromIntegral $ imageWidth dirt
|
||||
htex' = fromIntegral $ imageHeight dirt
|
||||
withArray texData' $ \ptr -> do
|
||||
texImage2D Texture2D NoProxy 0 RGBA8 (TextureSize2D wtex' htex') 0
|
||||
(PixelData RGBA UnsignedByte ptr)
|
||||
generateMipmap' Texture2D
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Nearest)
|
||||
|
||||
-- input a list of (attribute location, attrib length) pairs
|
||||
-- these will have buffers and pointers created
|
||||
backgroundvao <- setupVAO [(0,4),(1,2)]
|
||||
|
||||
return $ RenderData
|
||||
{ _textures = [dirttex,dirttex]
|
||||
, _listShaders = [bslist,lslist,cslist,aslist,eslist]
|
||||
{ _listShaders = [bslist,lslist,cslist,aslist,eslist]
|
||||
, _dummyVBO = dummyvbo
|
||||
, _dummyPtr = dummyptr
|
||||
, _lightSourceShader = lsShad
|
||||
|
||||
Reference in New Issue
Block a user