flip image at loading, not in shader

This commit is contained in:
nek0 2020-05-23 11:16:53 +02:00
parent 3dab16259e
commit 58db022a7b
4 changed files with 9 additions and 6 deletions

View File

@ -29,6 +29,7 @@ executable renderer-tutorial
, monad-loops
, random
, JuicyPixels
, JuicyPixels-extra
other-modules: BindableClass
, BufferClass
, VertexBuffer

View File

@ -8,5 +8,5 @@ out vec2 v_texCoord;
void main()
{
gl_Position = vec4(position, 1);
v_texCoord = vec2(texCoord.x, 1.0 - texCoord.y);
v_texCoord = texCoord;
}

View File

@ -4,8 +4,9 @@ let
inherit (nixpkgs) pkgs;
f = { mkDerivation, base, bytestring, JuicyPixels, linear
, monad-loops, OpenGL, OpenGLRaw, random, sdl2, stdenv, vector
f = { mkDerivation, base, bytestring, JuicyPixels
, JuicyPixels-extra, linear, monad-loops, OpenGL, OpenGLRaw, random
, sdl2, stdenv, vector
}:
mkDerivation {
pname = "renderer-tutorial";
@ -14,8 +15,8 @@ let
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [
base bytestring JuicyPixels linear monad-loops OpenGL OpenGLRaw
random sdl2 vector
base bytestring JuicyPixels JuicyPixels-extra linear monad-loops
OpenGL OpenGLRaw random sdl2 vector
];
license = stdenv.lib.licenses.gpl3;
};

View File

@ -5,6 +5,7 @@ import SDL (($=), get)
import qualified Graphics.Rendering.OpenGL as GL
import Codec.Picture
import Codec.Picture.Extra
import Data.Either
@ -40,7 +41,7 @@ newTexture :: FilePath -> GL.GLuint -> IO Texture
newTexture fp slot = do
-- read in image from filesystem
img <- convertRGBA8 <$>
img <- flipVertically <$> convertRGBA8 <$>
either (error $ "reading image file " <> fp <> " failed!") id <$>
readImage fp