[HOpenGL] Plans for more extensions?

Glynn Clements glynn at gclements.plus.com
Mon Jun 13 04:37:35 EDT 2005


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 <glynn at gclements.plus.com>


More information about the HOpenGL mailing list