Merge remote-tracking branch 'origin/master' into Mapping

This commit is contained in:
Jonas Betzendahl 2014-04-23 14:00:17 +02:00
commit ca831692d2
5 changed files with 82 additions and 3 deletions

View File

@ -9,7 +9,7 @@ in vec3 tcNormal[];
out vec4 teColor; out vec4 teColor;
smooth out vec3 tePosition; smooth out vec3 tePosition;
smooth out vec3 teNormal; smooth out vec3 teNormal;
out float fogDist; smooth out float fogDist;
smooth out float gmix; //mixture of gravel smooth out float gmix; //mixture of gravel
//out vec3 tePatchDistance; //out vec3 tePatchDistance;
//constant projection matrix //constant projection matrix

View File

@ -6,6 +6,6 @@ varying vec2 texcoord;
void main() void main()
{ {
vec4 map = texture2D(tex[0], texcoord); vec4 map = texture2D(tex[0], texcoord);
vec4 hud = texture2D(tex[1], texcoord); vec4 hud = texture2D(tex[1], vec2(texcoord.x,-texcoord.y));
gl_FragColor = vec4(mix(map.rgb,hud.rgb,hud.a),1.0); gl_FragColor = vec4(mix(map.rgb,hud.rgb,hud.a),1.0);
} }

View File

@ -84,6 +84,7 @@ main =
--generate map vertices --generate map vertices
(mapBuffer, vert) <- getMapBufferObject (mapBuffer, vert) <- getMapBufferObject
(mapprog, ci, ni, vi, pri, vii, mi, nmi, tli, tlo, mapTex) <- initMapShader (mapprog, ci, ni, vi, pri, vii, mi, nmi, tli, tlo, mapTex) <- initMapShader
overTex <- GL.genObjectName
print window' print window'
eventQueue <- newTQueueIO :: IO (TQueue Event) eventQueue <- newTQueueIO :: IO (TQueue Event)
putStrLn "foo" putStrLn "foo"
@ -123,6 +124,7 @@ main =
, _mapVert = vert , _mapVert = vert
, _mapProgram = mapprog , _mapProgram = mapprog
, _mapTexture = mapTex , _mapTexture = mapTex
, _overviewTexture = overTex
} }
env = Env env = Env
{ _eventsChan = eventQueue { _eventsChan = eventQueue

View File

@ -180,6 +180,82 @@ initRendering = do
glCullFace gl_BACK glCullFace gl_BACK
checkError "initRendering" checkError "initRendering"
{-renderOverview :: Pioneers ()
renderOverview = do
liftIO $ do
---- RENDER OVERVIEW MAP ------------------------------------------
bindFramebuffer Framebuffer $= (state ^. gl.glFramebuffer)
bindRenderbuffer Renderbuffer $= (state ^. gl.glRenderbuffer)
framebufferRenderbuffer
Framebuffer
DepthAttachment
Renderbuffer
(state ^. gl.glRenderbuffer)
textureBinding Texture2D $= Just (state ^. gl.glMap.mapTexture)
framebufferTexture2D
Framebuffer
(ColorAttachment 0)
Texture2D
(state ^. gl.glMap.mapTexture)
0
-- Render to FrameBufferObject
drawBuffers $= [FBOColorAttachment 0]
checkError "setup Render-Target"
clear [ColorBuffer, DepthBuffer]
checkError "clear buffer"
currentProgram $= Just (state ^. gl.glMap.mapProgram)
checkError "setting up buffer"
--set up projection (= copy from state)
with (distribute frust) $ \ptr ->
glUniformMatrix4fv proj 1 0 (castPtr (ptr :: Ptr (L.M44 CFloat)))
checkError "copy projection"
--set up camera
let ! cam = getCam camPos zDist' xa ya
with (distribute cam) $ \ptr ->
glUniformMatrix4fv vmat 1 0 (castPtr (ptr :: Ptr (L.M44 CFloat)))
checkError "copy cam"
--set up normal--Mat transpose((model*camera)^-1)
let normal' = (case L.inv33 (fmap (^. L._xyz) cam ^. L._xyz) of
(Just a) -> a
Nothing -> L.eye3) :: L.M33 CFloat
nmap = collect id normal' :: L.M33 CFloat --transpose...
with (distribute nmap) $ \ptr ->
glUniformMatrix3fv nmat 1 0 (castPtr (ptr :: Ptr (L.M33 CFloat)))
checkError "nmat"
glUniform1f tli (fromIntegral tessFac)
glUniform1f tlo (fromIntegral tessFac)
bindBuffer ArrayBuffer $= Just map'
vertexAttribPointer ci $= fgColorIndex
vertexAttribArray ci $= Enabled
vertexAttribPointer ni $= fgNormalIndex
vertexAttribArray ni $= Enabled
vertexAttribPointer vi $= fgVertexIndex
vertexAttribArray vi $= Enabled
checkError "beforeDraw"
glPatchParameteri gl_PATCH_VERTICES 3
cullFace $= Just Front
glDrawArrays gl_PATCHES 0 (fromIntegral numVert)
checkError "draw map"
-}
render :: Pioneers () render :: Pioneers ()
render = do render = do
state <- RWS.get state <- RWS.get

View File

@ -89,6 +89,7 @@ data GLMapState = GLMapState
, _mapVert :: !GL.NumArrayIndices , _mapVert :: !GL.NumArrayIndices
, _mapProgram :: !GL.Program , _mapProgram :: !GL.Program
, _mapTexture :: !TextureObject , _mapTexture :: !TextureObject
, _overviewTexture :: !TextureObject
} }
data GLHud = GLHud data GLHud = GLHud