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 , poppler
, sdl2 , sdl2
, linear , linear
, monad-loops
, OpenGL
, text , text
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010

View File

@ -26,8 +26,8 @@ let
inherit (nixpkgs) pkgs; inherit (nixpkgs) pkgs;
f = { mkDerivation, base, linear, optparse-applicative, poppler, stdenv, f = { mkDerivation, base, linear, monad-loops, optparse-applicative, OpenGL,
text poppler, stdenv, text
}: }:
mkDerivation { mkDerivation {
pname = "ibis"; pname = "ibis";
@ -35,8 +35,8 @@ let
src = ./.; src = ./.;
isLibrary = false; isLibrary = false;
isExecutable = true; isExecutable = true;
executableHaskellDepends = [ base linear sdl2 optparse-applicative executableHaskellDepends = [ base linear sdl2 monad-loops
poppler text ]; OpenGL optparse-applicative poppler text ];
description = "A pdf presenter"; description = "A pdf presenter";
license = stdenv.lib.licenses.gpl3; 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.Video as SDL (glSetAttribute)
import qualified SDL.Raw.Enum as SDL import qualified SDL.Raw.Enum as SDL
import qualified Graphics.Rendering.OpenGL as GL (clear, flush, ClearBuffer(..))
import Linear import Linear
import Options.Applicative import Options.Applicative
import Control.Monad import Control.Monad
import Control.Monad.Loops
import Control.Concurrent.MVar
import qualified Data.Text as T import qualified Data.Text as T
@ -48,3 +53,11 @@ main = do
void $ SDL.glSetAttribute SDL.SDL_GL_SHARE_WITH_CURRENT_CONTEXT 1 void $ SDL.glSetAttribute SDL.SDL_GL_SHARE_WITH_CURRENT_CONTEXT 1
contexts <- zip (map fst wins) <$> mapM (SDL.glCreateContext . snd) wins contexts <- zip (map fst wins) <$> mapM (SDL.glCreateContext . snd) wins
mapM_ (SDL.showWindow . 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