minimal window(s)

This commit is contained in:
nek0 2019-01-31 00:11:39 +01:00
parent a5fc7c2dbe
commit 1da8a65028
3 changed files with 19 additions and 4 deletions

View File

@ -26,6 +26,8 @@ executable ibis
, poppler
, sdl2
, linear
, monad-loops
, OpenGL
, text
hs-source-dirs: src
default-language: Haskell2010

View File

@ -26,8 +26,8 @@ let
inherit (nixpkgs) pkgs;
f = { mkDerivation, base, linear, optparse-applicative, poppler, stdenv,
text
f = { mkDerivation, base, linear, monad-loops, optparse-applicative, OpenGL,
poppler, stdenv, text
}:
mkDerivation {
pname = "ibis";
@ -35,8 +35,8 @@ let
src = ./.;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [ base linear sdl2 optparse-applicative
poppler text ];
executableHaskellDepends = [ base linear sdl2 monad-loops
OpenGL optparse-applicative poppler text ];
description = "A pdf presenter";
license = stdenv.lib.licenses.gpl3;
};

View File

@ -4,11 +4,16 @@ import qualified SDL
import qualified SDL.Raw.Video as SDL (glSetAttribute)
import qualified SDL.Raw.Enum as SDL
import qualified Graphics.Rendering.OpenGL as GL (clear, flush, ClearBuffer(..))
import Linear
import Options.Applicative
import Control.Monad
import Control.Monad.Loops
import Control.Concurrent.MVar
import qualified Data.Text as T
@ -48,3 +53,11 @@ main = do
void $ SDL.glSetAttribute SDL.SDL_GL_SHARE_WITH_CURRENT_CONTEXT 1
contexts <- zip (map fst wins) <$> mapM (SDL.glCreateContext . snd) wins
mapM_ (SDL.showWindow . snd) wins
run <- newMVar True
whileM_ (readMVar run) (do
GL.clear [GL.ColorBuffer, GL.DepthBuffer, GL.StencilBuffer]
GL.flush
mapM_ (SDL.glSwapWindow . snd) wins
)
mapM_ (SDL.glDeleteContext . snd) contexts
mapM_ (SDL.destroyWindow . snd) wins