How do I generate a random GLfloat value in Haskell?
There is no instance declaration for Random GLfloat.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When there is no instance, make an instance. That’s the first thing they teach you.
There are many ways, but the easiest is probably to generate a type of sufficient resolution then cast that to a GLfloat:
Doubleshould suffice seeing as that’s a 64 bit floating value whileGLFloat(which wrapsCFloat) is a 32 bit float.Floatshould be sufficient, but I’m not well-versed enough in the specifics of Floating point to know for sure that this is true for all platforms.