Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as text by dsfasdfasdf ( 18 years ago )
here is the hideous dirty code. some stuff cut out that is unrelated.

import qualified Data.ByteString.Lazy.Char8 as BC
--import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
import Data.ByteString (useAsCStringLen)

data NovaImage = NovaImage { nviPixels :: BC.ByteString }
	deriving (Show,Read)

loadImage :: GLuint -> String -> IO RImage
loadImage n fn = do
	i@(NovaImage {nviWidth=w,nviHeight=h}) <- loadNovaImage $ contentDir ++ fn ++ ".nvi"

	enable & Texture2D
	(bindTexture & Texture2D) n
	useAsCStringLen (nviPixels i) ((ptr,len)->
		build2DMipmaps (toConst Texture2D) (nviInternalFormat i) w h (nviFormat i) (toConst UnsignedByte) ptr)
	(bindTexture & Texture2D) 0 -- (texID defaultImage)
	disable & Texture2D

	return $ RImage fn w h n
	where
	--loadNovaImage f = BC.readFile f >>= return . read . BC.unpack . decompress
	loadNovaImage f = do
		x <- BC.readFile f
		let i = read $ BC.unpack x
		return i {nviPixels = decompress (nviPixels i)}

 

Revise this Paste

Your Name: Code Language: