schell / gelatin

A nice Haskell graphics API. There's always room for jello.
BSD 3-Clause "New" or "Revised" License
41 stars 4 forks source link

Create a texture strategy to remove the texture type parameter from Picture's signature. #9

Closed schell closed 8 years ago

schell commented 8 years ago

As @cies said

I can also imagine its great to have FillTexture take a DynamicImage or even a GLuint (pointing to the texture in GL'istan).

Just like fonts, there are many different kinds of textures. We should have gelatin-picture use a texture strategy similar to the way it uses FontData. That way the implementation details (GLuint or DynamicImage) aren't leaked in the top level API. This TextureData should be implemented in gelatin-core.

I'm thinking something like

data TextureData = TextureData 
    { textureShow :: String
    , textureHash :: Int -> Int
    , ...
    }

And then have the backend provide a function that maps a texture to a TextureData. I'm not certain of what other functions would be needed in the TextureData record though.

schell commented 8 years ago

The alternative is to encode the texture type in the type of Picture like was previously done with Font.