[HOpenGL] Texture Mapping??

Claude Heiland-Allen claudiusmaximus at goto10.org
Sun Jul 11 10:36:09 EDT 2010


Hi Hector,

On 11/07/10 03:02, Hector Guilarte wrote:
 > I've been looking for a way to map a texture into a Quad primitive with
 > HOpenGL with no luck.
[snip]

I'm having trouble understanding where your problem is.

There are three steps to texturing using an image file:

load   :: FilePath -> IO Image      -- read file to raw pixel buffer
upload :: Image -> IO TextureObject -- upload to graphics card
draw   :: TextureObject -> IO ()    -- use the texture on something

where
data Image = Image{ width, height, channels :: Int, pixels :: Ptr () }

Which step is problematic?

'load' is the hardest IMO, and doesn't have anything to do with OpenGL.
'upload' I would implement with 'build2DMipmaps'
'draw' is easy: bind the texture, add a 'texCoord' before each 'vertex'

I could provide some example code for 'upload' and 'draw' if you think 
it would help.


Claude
-- 
http://claudiusmaximus.goto10.org


More information about the HOpenGL mailing list