[Haskell-cafe] Loading a texture in OpenGL

Clark Gaebel cgaebel at csclub.uwaterloo.ca
Tue Feb 7 01:07:05 CET 2012

Thank you both. I'll be sure to try these out.

As a matter of fact, I _am_ using JuicyPixels. I didn't realize there was a
version on github which uses Vector. Thanks for letting me know.

  - clark

On Mon, Feb 6, 2012 at 5:55 PM, Jason Dagit <dagitj at gmail.com> wrote:

> On Mon, Feb 6, 2012 at 12:00 PM, Clark Gaebel
> <cgaebel at csclub.uwaterloo.ca> wrote:
> > Using the OpenGL package on Hackage, how do I load a texture from an
> array?
> The answer will depend on a few things:
>  * Which OpenGL package you use, for example OpenGL vs. OpenGLRaw
>  * What type of 'array' you use.
> In the case of the OpenGL package you need to create a PixelData value
> and pass that on.  You can find example code here:
> https://github.com/dagit/nehe-tuts/blob/447f5471f3e7fe07b44dc5d2d87c4a95be35ce75/lesson06.hs
> https://github.com/dagit/nehe-tuts/blob/447f5471f3e7fe07b44dc5d2d87c4a95be35ce75/Util.hs
> > In the red book[1], I see their code using glGenTextures and
> glBindTexture,
> > but I can't find these in the documentation. Are there different
> functions I
> > should be calling?
> Yes. As you've noticed the API of the OpenGL package sometimes
> (often?) differs from that of the C OpenGL api.  If that's what you're
> more familiar with then take a look at OpenGLRaw.  Here is how to do
> the same thing as the previous two links but using OpenGLRaw:
> https://github.com/dagit/nehe-tuts/blob/master/lesson06.hs
> https://github.com/dagit/nehe-tuts/blob/master/Util.hs
> Instead of using Arrays as defined by Haskell98, I would recommend
> using something else like Data.Vector. The standard arrays must be
> converted to something else to work with OpenGL. Data.Vector on the
> other hand allows direct access to the pinned pointer and is thus
> suitable for use with OpenGL as is.
> Have you seen JuicyPixels? The version on hackage uses arrays, but the
> version in github uses vector. I'd recommend using the version from
> github. It's faster and it will be easier to pass the data to OpenGL:
> https://github.com/Twinside/Juicy.Pixels
> Good luck!
> Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120206/49dd9b56/attachment.htm>

More information about the Haskell-Cafe mailing list