moved GLMapState: _renderedMapTexture to State: _mapTexture
This commit is contained in:
parent
b095907d9b
commit
8605440539
@ -14,7 +14,7 @@ import Control.Lens ((^.), (.~), (%~))
|
|||||||
-- data consistency/conversion
|
-- data consistency/conversion
|
||||||
import Control.Concurrent (threadDelay)
|
import Control.Concurrent (threadDelay)
|
||||||
import Control.Concurrent.STM (TQueue, newTQueueIO, atomically)
|
import Control.Concurrent.STM (TQueue, newTQueueIO, atomically)
|
||||||
import Control.Concurrent.STM.TVar (newTVarIO, writeTVar, readTVar)
|
import Control.Concurrent.STM.TVar (newTVarIO, writeTVar, readTVar, readTVarIO)
|
||||||
|
|
||||||
import Control.Monad.RWS.Strict (ask, evalRWST, get, liftIO, modify)
|
import Control.Monad.RWS.Strict (ask, evalRWST, get, liftIO, modify)
|
||||||
import Data.Functor ((<$>))
|
import Data.Functor ((<$>))
|
||||||
@ -89,7 +89,8 @@ main = do
|
|||||||
initRendering
|
initRendering
|
||||||
--generate map vertices
|
--generate map vertices
|
||||||
curMap <- exportedMap
|
curMap <- exportedMap
|
||||||
glMap' <- initMapShader 4 =<< getMapBufferObject curMap
|
(glMap', tex) <- initMapShader 4 =<< getMapBufferObject curMap
|
||||||
|
tex' <- newTVarIO tex
|
||||||
eventQueue <- newTQueueIO :: IO (TQueue SDL.Event)
|
eventQueue <- newTQueueIO :: IO (TQueue SDL.Event)
|
||||||
now <- getCurrentTime
|
now <- getCurrentTime
|
||||||
--font <- TTF.openFont "fonts/ttf-04B_03B_/04B_03B_.TTF" 10
|
--font <- TTF.openFont "fonts/ttf-04B_03B_/04B_03B_.TTF" 10
|
||||||
@ -140,6 +141,7 @@ main = do
|
|||||||
, _tessClockTime = now
|
, _tessClockTime = now
|
||||||
}
|
}
|
||||||
, _camera = cam'
|
, _camera = cam'
|
||||||
|
, _mapTexture = tex'
|
||||||
, _camStack = camStack'
|
, _camStack = camStack'
|
||||||
, _mouse = MouseState
|
, _mouse = MouseState
|
||||||
{ _isDragging = False
|
{ _isDragging = False
|
||||||
@ -325,8 +327,8 @@ adjustWindow = do
|
|||||||
|
|
||||||
|
|
||||||
let hudtexid = state ^. gl.glHud.hudTexture
|
let hudtexid = state ^. gl.glHud.hudTexture
|
||||||
maptexid = state ^. gl.glMap.renderedMapTexture
|
|
||||||
smaptexid = state ^. gl.glMap.shadowMapTexture
|
smaptexid = state ^. gl.glMap.shadowMapTexture
|
||||||
|
maptexid <- liftIO $ readTVarIO (state ^. mapTexture)
|
||||||
allocaBytes (fbWidth*fbHeight*4) $ \ptr -> do
|
allocaBytes (fbWidth*fbHeight*4) $ \ptr -> do
|
||||||
--default to ugly pink to see if
|
--default to ugly pink to see if
|
||||||
--somethings go wrong.
|
--somethings go wrong.
|
||||||
|
@ -62,7 +62,7 @@ initBuffer varray =
|
|||||||
initMapShader ::
|
initMapShader ::
|
||||||
Int -- ^ initial Tessallation-Factor
|
Int -- ^ initial Tessallation-Factor
|
||||||
-> (BufferObject,NumArrayIndices) -- ^ Buffer with Data and DataDescriptor
|
-> (BufferObject,NumArrayIndices) -- ^ Buffer with Data and DataDescriptor
|
||||||
-> IO GLMapState
|
-> IO (GLMapState, TextureObject)
|
||||||
initMapShader tessFac (buf, vertDes) = do
|
initMapShader tessFac (buf, vertDes) = do
|
||||||
! vertexSource <- B.readFile mapVertexShaderFile
|
! vertexSource <- B.readFile mapVertexShaderFile
|
||||||
! tessControlSource <- B.readFile mapTessControlShaderFile
|
! tessControlSource <- B.readFile mapTessControlShaderFile
|
||||||
@ -210,11 +210,10 @@ initMapShader tessFac (buf, vertDes) = do
|
|||||||
, shdrMOTessOuterIndex = UniformLocation 0 --tessLevelOuter'
|
, shdrMOTessOuterIndex = UniformLocation 0 --tessLevelOuter'
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLMapState
|
return (GLMapState
|
||||||
{ _mapProgram = program
|
{ _mapProgram = program
|
||||||
, _mapShaderData = sdata
|
, _mapShaderData = sdata
|
||||||
, _mapObjectShaderData = smodata
|
, _mapObjectShaderData = smodata
|
||||||
, _renderedMapTexture = tex
|
|
||||||
, _stateTessellationFactor = tessFac
|
, _stateTessellationFactor = tessFac
|
||||||
, _stateMap = buf
|
, _stateMap = buf
|
||||||
, _mapVert = vertDes
|
, _mapVert = vertDes
|
||||||
@ -224,7 +223,7 @@ initMapShader tessFac (buf, vertDes) = do
|
|||||||
, _mapObjects = objs
|
, _mapObjects = objs
|
||||||
, _objectProgram = objProgram
|
, _objectProgram = objProgram
|
||||||
, _shadowMapProgram = shadowProgram
|
, _shadowMapProgram = shadowProgram
|
||||||
}
|
}, tex)
|
||||||
|
|
||||||
initHud :: IO GLHud
|
initHud :: IO GLHud
|
||||||
initHud = do
|
initHud = do
|
||||||
@ -444,12 +443,13 @@ render = do
|
|||||||
|
|
||||||
---- RENDER MAP IN TEXTURE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
---- RENDER MAP IN TEXTURE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||||
-- COLORMAP
|
-- COLORMAP
|
||||||
textureBinding Texture2D $= Just (state ^. gl.glMap.renderedMapTexture)
|
tex <- liftIO $ readTVarIO (state ^. mapTexture)
|
||||||
|
textureBinding Texture2D $= Just tex
|
||||||
framebufferTexture2D
|
framebufferTexture2D
|
||||||
Framebuffer
|
Framebuffer
|
||||||
(ColorAttachment 0)
|
(ColorAttachment 0)
|
||||||
Texture2D
|
Texture2D
|
||||||
(state ^. gl.glMap.renderedMapTexture)
|
tex
|
||||||
0
|
0
|
||||||
|
|
||||||
-- Render to FrameBufferObject
|
-- Render to FrameBufferObject
|
||||||
@ -501,7 +501,8 @@ render = do
|
|||||||
uniform (hud ^. hudTexIndex) $= Index1 (0::GLint)
|
uniform (hud ^. hudTexIndex) $= Index1 (0::GLint)
|
||||||
|
|
||||||
activeTexture $= TextureUnit 1
|
activeTexture $= TextureUnit 1
|
||||||
textureBinding Texture2D $= Just (state ^. gl.glMap.renderedMapTexture)
|
tex <- liftIO $ readTVarIO (state ^. mapTexture)
|
||||||
|
textureBinding Texture2D $= Just tex
|
||||||
uniform (hud ^. hudBackIndex) $= Index1 (1::GLint)
|
uniform (hud ^. hudBackIndex) $= Index1 (1::GLint)
|
||||||
|
|
||||||
bindBuffer ArrayBuffer $= Just (hud ^. hudVBO)
|
bindBuffer ArrayBuffer $= Just (hud ^. hudVBO)
|
||||||
|
@ -11,7 +11,7 @@ import Linear.Matrix (M44)
|
|||||||
import Linear (V3)
|
import Linear (V3)
|
||||||
import Control.Monad.RWS.Strict (RWST, liftIO, get)
|
import Control.Monad.RWS.Strict (RWST, liftIO, get)
|
||||||
import Control.Monad.Writer.Strict
|
import Control.Monad.Writer.Strict
|
||||||
import Control.Monad (when)
|
--import Control.Monad (when)
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Graphics.Rendering.OpenGL.GL.Texturing.Objects (TextureObject)
|
import Graphics.Rendering.OpenGL.GL.Texturing.Objects (TextureObject)
|
||||||
import Render.Types
|
import Render.Types
|
||||||
@ -111,7 +111,6 @@ data GLMapState = GLMapState
|
|||||||
, _stateMap :: !GL.BufferObject
|
, _stateMap :: !GL.BufferObject
|
||||||
, _mapVert :: !GL.NumArrayIndices
|
, _mapVert :: !GL.NumArrayIndices
|
||||||
, _mapProgram :: !GL.Program
|
, _mapProgram :: !GL.Program
|
||||||
, _renderedMapTexture :: !TextureObject --TODO: Probably move to UI?
|
|
||||||
, _overviewTexture :: !TextureObject
|
, _overviewTexture :: !TextureObject
|
||||||
, _shadowMapTexture :: !TextureObject
|
, _shadowMapTexture :: !TextureObject
|
||||||
, _mapTextures :: ![TextureObject] --TODO: Fix size on list?
|
, _mapTextures :: ![TextureObject] --TODO: Fix size on list?
|
||||||
@ -174,8 +173,8 @@ data GLState = GLState
|
|||||||
|
|
||||||
data UIState = UIState
|
data UIState = UIState
|
||||||
{ _uiHasChanged :: !Bool
|
{ _uiHasChanged :: !Bool
|
||||||
, _uiMap :: !(Map.HashMap UIId (GUIWidget Pioneers))
|
, _uiMap :: Map.HashMap UIId (GUIWidget Pioneers)
|
||||||
, _uiObserverEvents :: !(Map.HashMap EventKey [EventHandler Pioneers])
|
, _uiObserverEvents :: Map.HashMap EventKey [EventHandler Pioneers]
|
||||||
, _uiRoots :: !([UIId])
|
, _uiRoots :: !([UIId])
|
||||||
, _uiButtonState :: !UIButtonState
|
, _uiButtonState :: !UIButtonState
|
||||||
}
|
}
|
||||||
@ -183,6 +182,7 @@ data UIState = UIState
|
|||||||
data State = State
|
data State = State
|
||||||
{ _window :: !WindowState
|
{ _window :: !WindowState
|
||||||
, _camera :: TVar CameraState
|
, _camera :: TVar CameraState
|
||||||
|
, _mapTexture :: TVar TextureObject
|
||||||
, _camStack :: TVar (Map.HashMap UIId (CameraState, TextureObject))
|
, _camStack :: TVar (Map.HashMap UIId (CameraState, TextureObject))
|
||||||
, _io :: !IOState
|
, _io :: !IOState
|
||||||
, _mouse :: !MouseState
|
, _mouse :: !MouseState
|
||||||
|
Loading…
Reference in New Issue
Block a user