scrap nanovg in favour of raw OpenGL

This commit is contained in:
nek0 2019-01-31 22:00:29 +01:00
parent 9f6c292406
commit 7a242f9695
4 changed files with 19 additions and 12 deletions

View file

@ -31,7 +31,6 @@ executable ibis
, monad-loops
, OpenGL
, text
, nanovg
, magic
, split
, time

View file

@ -22,12 +22,14 @@ let
doCheck = false;
description = "Both high- and low-level bindings to the SDL library (version 2.0.4+).";
license = stdenv.lib.licenses.bsd3;
enableLibraryProfiling = true;
enableExecutableProfiling = true;
}) {};
inherit (nixpkgs) pkgs;
f = { mkDerivation, base, linear, monad-loops, optparse-applicative, OpenGL,
poppler, stdenv, text
f = { mkDerivation, base, containers, linear, magic, monad-loops,
optparse-applicative, OpenGL, poppler, split, stdenv, text, time
}:
mkDerivation {
pname = "ibis";
@ -35,8 +37,8 @@ let
src = ./.;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [ base linear sdl2 monad-loops
OpenGL optparse-applicative poppler text ];
executableHaskellDepends = [ base containers linear sdl2 magic
monad-loops OpenGL optparse-applicative poppler split text time ];
description = "A pdf presenter";
license = stdenv.lib.licenses.gpl3;
};

View file

@ -4,10 +4,11 @@ module Main where
import qualified SDL
import qualified SDL.Raw.Video as SDL (glSetAttribute)
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 NanoVG as NVG
-- import qualified NanoVG as NVG
import Linear
@ -30,6 +31,8 @@ import Data.Time.Clock
import System.Exit (exitFailure)
import Foreign.C.String
import Magic
-- internal imports
@ -59,6 +62,9 @@ main = do
verb opts ("Passed command line options: " ++ show opts)
-- set Render quality
SDL.HintRenderScaleQuality SDL.$= SDL.ScaleLinear
uncurry SDL.setHint =<< (,)
<$> newCString "SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS"
<*> newCString "0"
-- check render quality
renderQuality <- SDL.get SDL.HintRenderScaleQuality
when (renderQuality /= SDL.ScaleLinear) $
@ -83,9 +89,9 @@ main = do
void $ SDL.glSetAttribute SDL.SDL_GL_SHARE_WITH_CURRENT_CONTEXT 1
verb opts "Creating OpenGL context(s)"
contexts <- zip (map fst wins) <$> mapM (SDL.glCreateContext . snd) wins
verb opts "Creating NanoVG context"
_ <- glewInit
nano <- NVG.createGL3 (S.fromList [NVG.Antialias, NVG.StencilStrokes])
-- verb opts "Creating NanoVG context"
-- _ <- glewInit
-- nano <- NVG.createGL3 (S.fromList [NVG.Antialias, NVG.StencilStrokes])
verb opts "Initializing state"
state <- newMVar <$> (
State <$>

View file

@ -1,4 +1,4 @@
{-# LANGUAGE ForeignFunctionInterface #-}
-- {-# LANGUAGE ForeignFunctionInterface #-}
module Util where
import qualified SDL hiding (V2)
@ -21,8 +21,8 @@ import Linear
import Types
foreign import ccall unsafe "glewInit"
glewInit :: IO CInt
-- foreign import ccall unsafe "glewInit"
-- glewInit :: IO CInt
glWindowConfig :: SDL.WindowConfig
glWindowConfig = SDL.defaultWindow