Re: Plans for more extensions?

Glynn Clements <[email protected]>
Newsgroups gmane.comp.lang.haskell.hopengl
Message-ID <[email protected]>
Sven Panne wrote:

> BTW: I still fail to see a good "Haskellish" API for NURBS. Again, API
> proposals are highly welcome.

The obvious Haskellisation would seem to be along the lines of:

> newtype NurbsRendererObj = NurbsRendererObj (Ptr ())
> -- GLUnurbsObj*

> withNurbsRendererObj :: (NurbsRendererObj -> IO a) -> IO a
> -- gluNewNurbsRenderer, gluDeleteNurbsRenderer

> renderCurve :: NurbsRendererObj -> IO a -> IO a
> -- gluBeginCurve, gluEndCurve

> renderSurface :: NurbsRendererObj -> IO a -> IO a
> -- gluBeginSurface, gluEndSurface

> trimNurbs :: NurbsRendererObj -> IO a -> IO a
> -- gluBeginTrim, gluEndTrim

> pwlCurve :: NurbsRendererObj
> 	-> [GLfloat]		-- vertices
> 	-> MapTarget		-- type
> 	-> IO ()
> -- gluPwlCurve

> nurbsCurve :: NurbsRendererObj
> 	-> [GLfloat]		-- knots
> 	-> [GLfloat]		-- control points
> 	-> MapTarget		-- type
> 	-> IO ()
> -- gluNurbsCurve

> nurbsSurface :: NurbsRendererObj
> 	-> [GLfloat]		-- s knots
> 	-> [GLfloat]		-- t knots
> 	-> [[GLfloat]]		-- control points
> 	-> MapTarget		-- type
> 	-> IO ()
> -- gluNurbsSurface

[The control points would arguably better as an Array, but the above
matches how 2D evaluators are handled.]

> various :: NurbsRendererObj -> StateVar a
> -- gluNurbsProperty, gluGetNurbsProperty

> samplingMatrices :: Matrix m => NurbsRendererObj
> 	-> SettableStateVar (m GLfloat, m GLfloat, (Position, Size))
> -- gluLoadSamplingMatrices

> data NurbsCallbackTarget = ...

> nurbsCallback :: NurbsRendererObj
> 	-> NurbsCallbackTarget	-- which
> 	-> SettableStateVar (IO ())
> -- gluNurbsCallback

For the functions which can only be called within a begin/end pair,
you might want to stuff the NurbsRendererObj into an IORef rather than
having to pass it around .

-- 
Glynn Clements <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.