scrap nanovg in favour of raw OpenGL
This commit is contained in:
parent
9f6c292406
commit
7a242f9695
4 changed files with 19 additions and 12 deletions
|
@ -31,7 +31,6 @@ executable ibis
|
||||||
, monad-loops
|
, monad-loops
|
||||||
, OpenGL
|
, OpenGL
|
||||||
, text
|
, text
|
||||||
, nanovg
|
|
||||||
, magic
|
, magic
|
||||||
, split
|
, split
|
||||||
, time
|
, time
|
||||||
|
|
10
shell.nix
10
shell.nix
|
@ -22,12 +22,14 @@ let
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
description = "Both high- and low-level bindings to the SDL library (version 2.0.4+).";
|
description = "Both high- and low-level bindings to the SDL library (version 2.0.4+).";
|
||||||
license = stdenv.lib.licenses.bsd3;
|
license = stdenv.lib.licenses.bsd3;
|
||||||
|
enableLibraryProfiling = true;
|
||||||
|
enableExecutableProfiling = true;
|
||||||
}) {};
|
}) {};
|
||||||
|
|
||||||
inherit (nixpkgs) pkgs;
|
inherit (nixpkgs) pkgs;
|
||||||
|
|
||||||
f = { mkDerivation, base, linear, monad-loops, optparse-applicative, OpenGL,
|
f = { mkDerivation, base, containers, linear, magic, monad-loops,
|
||||||
poppler, stdenv, text
|
optparse-applicative, OpenGL, poppler, split, stdenv, text, time
|
||||||
}:
|
}:
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "ibis";
|
pname = "ibis";
|
||||||
|
@ -35,8 +37,8 @@ let
|
||||||
src = ./.;
|
src = ./.;
|
||||||
isLibrary = false;
|
isLibrary = false;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
executableHaskellDepends = [ base linear sdl2 monad-loops
|
executableHaskellDepends = [ base containers linear sdl2 magic
|
||||||
OpenGL optparse-applicative poppler text ];
|
monad-loops OpenGL optparse-applicative poppler split text time ];
|
||||||
description = "A pdf presenter";
|
description = "A pdf presenter";
|
||||||
license = stdenv.lib.licenses.gpl3;
|
license = stdenv.lib.licenses.gpl3;
|
||||||
};
|
};
|
||||||
|
|
14
src/Main.hs
14
src/Main.hs
|
@ -4,10 +4,11 @@ module Main where
|
||||||
import qualified SDL
|
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 SDL.Raw.Basic as SDL
|
||||||
|
|
||||||
import qualified Graphics.Rendering.OpenGL as GL (clear, flush, ClearBuffer(..))
|
import qualified Graphics.Rendering.OpenGL as GL (clear, flush, ClearBuffer(..))
|
||||||
|
|
||||||
import qualified NanoVG as NVG
|
-- import qualified NanoVG as NVG
|
||||||
|
|
||||||
import Linear
|
import Linear
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@ import Data.Time.Clock
|
||||||
|
|
||||||
import System.Exit (exitFailure)
|
import System.Exit (exitFailure)
|
||||||
|
|
||||||
|
import Foreign.C.String
|
||||||
|
|
||||||
import Magic
|
import Magic
|
||||||
|
|
||||||
-- internal imports
|
-- internal imports
|
||||||
|
@ -59,6 +62,9 @@ main = do
|
||||||
verb opts ("Passed command line options: " ++ show opts)
|
verb opts ("Passed command line options: " ++ show opts)
|
||||||
-- set Render quality
|
-- set Render quality
|
||||||
SDL.HintRenderScaleQuality SDL.$= SDL.ScaleLinear
|
SDL.HintRenderScaleQuality SDL.$= SDL.ScaleLinear
|
||||||
|
uncurry SDL.setHint =<< (,)
|
||||||
|
<$> newCString "SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS"
|
||||||
|
<*> newCString "0"
|
||||||
-- check render quality
|
-- check render quality
|
||||||
renderQuality <- SDL.get SDL.HintRenderScaleQuality
|
renderQuality <- SDL.get SDL.HintRenderScaleQuality
|
||||||
when (renderQuality /= SDL.ScaleLinear) $
|
when (renderQuality /= SDL.ScaleLinear) $
|
||||||
|
@ -83,9 +89,9 @@ main = do
|
||||||
void $ SDL.glSetAttribute SDL.SDL_GL_SHARE_WITH_CURRENT_CONTEXT 1
|
void $ SDL.glSetAttribute SDL.SDL_GL_SHARE_WITH_CURRENT_CONTEXT 1
|
||||||
verb opts "Creating OpenGL context(s)"
|
verb opts "Creating OpenGL context(s)"
|
||||||
contexts <- zip (map fst wins) <$> mapM (SDL.glCreateContext . snd) wins
|
contexts <- zip (map fst wins) <$> mapM (SDL.glCreateContext . snd) wins
|
||||||
verb opts "Creating NanoVG context"
|
-- verb opts "Creating NanoVG context"
|
||||||
_ <- glewInit
|
-- _ <- glewInit
|
||||||
nano <- NVG.createGL3 (S.fromList [NVG.Antialias, NVG.StencilStrokes])
|
-- nano <- NVG.createGL3 (S.fromList [NVG.Antialias, NVG.StencilStrokes])
|
||||||
verb opts "Initializing state"
|
verb opts "Initializing state"
|
||||||
state <- newMVar <$> (
|
state <- newMVar <$> (
|
||||||
State <$>
|
State <$>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{-# LANGUAGE ForeignFunctionInterface #-}
|
-- {-# LANGUAGE ForeignFunctionInterface #-}
|
||||||
module Util where
|
module Util where
|
||||||
|
|
||||||
import qualified SDL hiding (V2)
|
import qualified SDL hiding (V2)
|
||||||
|
@ -21,8 +21,8 @@ import Linear
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
|
|
||||||
foreign import ccall unsafe "glewInit"
|
-- foreign import ccall unsafe "glewInit"
|
||||||
glewInit :: IO CInt
|
-- glewInit :: IO CInt
|
||||||
|
|
||||||
glWindowConfig :: SDL.WindowConfig
|
glWindowConfig :: SDL.WindowConfig
|
||||||
glWindowConfig = SDL.defaultWindow
|
glWindowConfig = SDL.defaultWindow
|
||||||
|
|
Loading…
Reference in a new issue