[HOpenGL] Using RULES to improve OpenGLRaw
Andy Gill
andygill at ku.edu
Fri Dec 4 12:07:47 EST 2009
We've been hacking on ChalkBoard, and there is this import
optimization that we've added to our version of OpenGLRaw. It make
ChalkBoard run almost twice as fast. The problem was the conversions
between GLfloat and regular floats was using realToFrac, which uses
fromRational . toRational.
This can be fixed by using the GHC RULES. (inside the GHC specific
part of includes/CTypes.h)
#define GHC_RULE(N,R) {-# RULES "N" R #-}
#define FLOATING_TYPE(T,C,S,B) \
newtype T = T B deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES); \
INSTANCE_READ(T,B); \
INSTANCE_SHOW(T,B); \
INSTANCE_TYPEABLE0(T,C,S) ; \
GHC_RULE(realToFrac/a->T,realToFrac = \x -> T (realToFrac x)) ; \
GHC_RULE(realToFrac/T->a,realToFrac = \(T x) -> realToFrac x)
(the last two lines are the new lines)
We've asked for this change to be added to the office release of
OpenGLRaw.
Cheers!
Andy & Kevin
----
Andy Gill, <andygill at ku.edu>
Assistant Professor
The University of Kansas, EECS Department
Information and Telecommunication Technology Center
More information about the HOpenGL
mailing list