Couple loop with preload to allow for time "profiling"
This commit is contained in:
+1
-19
@@ -11,27 +11,9 @@ uniform vec2 translation;
|
|||||||
uniform float rotation;
|
uniform float rotation;
|
||||||
uniform mat4 worldMat;
|
uniform mat4 worldMat;
|
||||||
|
|
||||||
mat4 tranMat = mat4
|
|
||||||
( 1.0, 0.0, 0.0, 0.0
|
|
||||||
, 0.0, 1.0, 0.0, 0.0
|
|
||||||
, 0.0, 0.0, 1.0, 0.0
|
|
||||||
, -translation.x, -translation.y, 0.0, 1.0
|
|
||||||
) ;
|
|
||||||
mat4 rotMat = mat4
|
|
||||||
( cos(rotation), sin(-rotation), 0.0, 0.0
|
|
||||||
, sin(rotation), cos(rotation), 0.0, 0.0
|
|
||||||
, 0.0, 0.0, 1.0, 0.0
|
|
||||||
, 0.0, 0.0, 0.0, 1.0
|
|
||||||
) ;
|
|
||||||
mat4 scalMat = mat4
|
|
||||||
( 2*zoom/winSize.x, 0.0, 0.0, 0.0
|
|
||||||
, 0.0, 2*zoom/winSize.y, 0.0, 0.0
|
|
||||||
, 0.0, 0.0, 1.0, 0.0
|
|
||||||
, 0.0, 0.0, 0.0, 1.0
|
|
||||||
) ;
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = scalMat * rotMat * tranMat * vec4(position.xyz,1);
|
gl_Position = worldMat * vec4(position.xyz,1);
|
||||||
vColor = color;
|
vColor = color;
|
||||||
vRad = rad;
|
vRad = rad;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,14 +26,5 @@ void main()
|
|||||||
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, 0.9 , 1);
|
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, 0.9 , 1);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
// gl_Position = vec4 (0.5,0.5,0 , 1);
|
|
||||||
// EmitVertex();
|
|
||||||
// gl_Position = vec4 (0,0.5,0 , 1);
|
|
||||||
// EmitVertex();
|
|
||||||
// gl_Position = vec4 (0.5,0,0 , 1);
|
|
||||||
// EmitVertex();
|
|
||||||
// gl_Position = vec4 (0,0,0 , 1);
|
|
||||||
// EmitVertex();
|
|
||||||
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-5
@@ -12,6 +12,10 @@ import System.Mem
|
|||||||
import Foreign.C
|
import Foreign.C
|
||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
|
import Preload
|
||||||
|
|
||||||
|
import Control.Lens ((.~),(&))
|
||||||
|
|
||||||
winConfig x y = defaultWindow
|
winConfig x y = defaultWindow
|
||||||
{ windowGraphicsContext
|
{ windowGraphicsContext
|
||||||
= OpenGLContext (defaultOpenGL { glProfile = Core Normal 4 3
|
= OpenGLContext (defaultOpenGL { glProfile = Core Normal 4 3
|
||||||
@@ -22,13 +26,23 @@ winConfig x y = defaultWindow
|
|||||||
, windowResizable =True
|
, windowResizable =True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--setupLoop :: String
|
||||||
|
-- -> CInt
|
||||||
|
-- -> CInt
|
||||||
|
-- -> IO setupParams
|
||||||
|
-- -> (setupParams -> IO ())
|
||||||
|
-- -> world
|
||||||
|
-- -> (setupParams -> world -> IO setupParams)
|
||||||
|
-- -> (world -> Event -> Maybe world)
|
||||||
|
-- -> (world -> Maybe world)
|
||||||
|
-- -> IO ()
|
||||||
setupLoop :: String
|
setupLoop :: String
|
||||||
-> CInt
|
-> CInt
|
||||||
-> CInt
|
-> CInt
|
||||||
-> IO setupParams
|
-> IO (PreloadData a)
|
||||||
-> (setupParams -> IO ())
|
-> (PreloadData a -> IO ())
|
||||||
-> world
|
-> world
|
||||||
-> (setupParams -> world -> IO setupParams)
|
-> (PreloadData a -> world -> IO (PreloadData a))
|
||||||
-> (world -> Event -> Maybe world)
|
-> (world -> Event -> Maybe world)
|
||||||
-> (world -> Maybe world)
|
-> (world -> Maybe world)
|
||||||
-> IO ()
|
-> IO ()
|
||||||
@@ -62,11 +76,11 @@ doLoop setup window startWorld
|
|||||||
eventFn
|
eventFn
|
||||||
worldUpdate
|
worldUpdate
|
||||||
= do
|
= do
|
||||||
|
startLoopTicks <- ticks
|
||||||
GL.clear [GL.ColorBuffer,GL.DepthBuffer]
|
GL.clear [GL.ColorBuffer,GL.DepthBuffer]
|
||||||
newParams <- worldSideEffects setup startWorld
|
newParams <- worldSideEffects (setup & currentTime .~ startLoopTicks) startWorld
|
||||||
glSwapWindow window
|
glSwapWindow window
|
||||||
--worldSideEffects setup updatedWorld
|
--worldSideEffects setup updatedWorld
|
||||||
startLoopTicks <- ticks
|
|
||||||
events <- pollEvents
|
events <- pollEvents
|
||||||
--let-- maybeUpdatedWorld :: Maybe (WorldView world0)
|
--let-- maybeUpdatedWorld :: Maybe (WorldView world0)
|
||||||
-- maybeUpdatedWorld = applyEvents eventFn startWorld events worldUpdate
|
-- maybeUpdatedWorld = applyEvents eventFn startWorld events worldUpdate
|
||||||
|
|||||||
@@ -398,6 +398,12 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
|
|||||||
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
|
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
|
||||||
renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToFTree 2 pic
|
renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToFTree 2 pic
|
||||||
-- reset uniforms (hacky for now)
|
-- reset uniforms (hacky for now)
|
||||||
|
idmat <- (newMatrix RowMajor [1,0,0,0
|
||||||
|
,0,1,0,0
|
||||||
|
,0,0,1,0
|
||||||
|
,0,0,0,1
|
||||||
|
]
|
||||||
|
) :: IO (GLmatrix GLfloat)
|
||||||
forM_ [_basicShader pdata
|
forM_ [_basicShader pdata
|
||||||
,_textShader pdata
|
,_textShader pdata
|
||||||
,_circShader pdata
|
,_circShader pdata
|
||||||
@@ -411,6 +417,7 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
|
|||||||
uniform (snd shad !! 1) $= (1::Float)
|
uniform (snd shad !! 1) $= (1::Float)
|
||||||
uniform (snd shad !! 2) $= (0::Float)
|
uniform (snd shad !! 2) $= (0::Float)
|
||||||
uniform (snd shad !! 3) $= Vector2 (0::Float) 0
|
uniform (snd shad !! 3) $= Vector2 (0::Float) 0
|
||||||
|
uniform (snd shad !! 4) $= idmat
|
||||||
|
|
||||||
|
|
||||||
bufferOffset :: Integral a => a -> Ptr b
|
bufferOffset :: Integral a => a -> Ptr b
|
||||||
|
|||||||
Reference in New Issue
Block a user