import Graphics.Rendering.OpenGL import Graphics.UI.GLUT import Data.IORef import Textures main = do (progname, _) <- getArgsAndInitialize initialDisplayMode $= [DoubleBuffered,RGBAMode] createWindow "Hello World" [notSure] <- getAndCreateTextures ["other"] windowSize $= Size 800 500 displayCallback $= (display notSure) mainLoop display :: (Maybe TextureObject) -> IO() display image = do clear [ColorBuffer] texture Texture2D $= Enabled loadIdentity textureBinding Texture2D $= image let vertices = makeVertices [(0,0,0,0,0), (1,0,0,1,0), (1,1,0,1,1), (0,1,0,0,1)] renderPrimitive Quads vertices swapBuffers makeVertices ((x,y,z,tx,ty):[]) = do texCoord (TexCoord2 (tx::GLfloat) ty) vertex (Vertex3 x y z) makeVertices ((x,y,z,tx,ty):xs) = do texCoord (TexCoord2 (tx::GLfloat) ty) vertex (Vertex3 (x::GLfloat) y z) makeVertices xs