Some finitions
This commit is contained in:
parent
79409a8a72
commit
c0900ea16c
3 changed files with 20 additions and 10 deletions
|
@ -6,8 +6,11 @@ Some points:
|
|||
In particular the `mainLoop` function is a direct link to the C library (FFI).
|
||||
This function is clearly far from the functional paradigm.
|
||||
Could we make this better?
|
||||
We will have two choices, or create our own `mainLoop` function to make it more functional.
|
||||
Or deal with the imperative nature of the GLUT `mainLoop` function.
|
||||
We will have two choices:
|
||||
|
||||
- create our own `mainLoop` function to make it more functional.
|
||||
- deal with the imperative nature of the GLUT `mainLoop` function.
|
||||
|
||||
As one of the goal of this article is to understand how to deal with existing libraries and particularly the one coming from imperative languages, we will continue to use the `mainLoop` function.
|
||||
2. Our main problem come from user interaction.
|
||||
If you ask "the Internet",
|
||||
|
@ -237,9 +240,9 @@ The rest is similar to the preceding sections.
|
|||
> ymandel :: Point -> Point -> Point -> Point
|
||||
> ymandel x y z = fromIntegral (mandel x y z 64) / 64
|
||||
|
||||
I won't put how the magic occurs directly here.
|
||||
But all the magic occurs in the file `YGL.hs`.
|
||||
This file is commented a lot.
|
||||
I won't explain how the magic occurs here.
|
||||
If you are interested, just read the file [`YGL.hs`](code/05_Mandelbulb/YGL.hs).
|
||||
It is commented a lot.
|
||||
|
||||
- [`YGL.hs`](code/05_Mandelbulb/YGL.hs), the 3D rendering framework
|
||||
- [`Mandel`](code/05_Mandelbulb/Mandel.hs), the mandel function
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
-- The languages include needed because I wanted to use
|
||||
-- (Point,Point,Point) instead of
|
||||
-- data Point3D = Point3D (Point,Point,Point) deriving ...
|
||||
{-
|
||||
The module YGL will contains most boilerplate
|
||||
And display details.
|
||||
|
@ -37,11 +34,20 @@ module YGL (
|
|||
-- The main loop function to call
|
||||
, yMainLoop) where
|
||||
|
||||
import Numeric (readHex)
|
||||
-- A bunch of imports
|
||||
import Numeric (readHex) -- to read hexadecimal values
|
||||
|
||||
-- Import of OpenGL and GLUT
|
||||
-- but, I use my own Color type, therefore I hide the definition
|
||||
-- of Color inside GLUT and OpenGL packages
|
||||
import Graphics.Rendering.OpenGL hiding (Color)
|
||||
import Graphics.UI.GLUT hiding (Color)
|
||||
import Data.IORef
|
||||
|
||||
-- I use Map to deal with user interaction
|
||||
import qualified Data.Map as Map
|
||||
|
||||
-- Some standard stuff
|
||||
import Control.Monad (when)
|
||||
import Data.Maybe (isNothing)
|
||||
|
||||
|
@ -49,6 +55,7 @@ import Data.Maybe (isNothing)
|
|||
- Just take the time to follow me.
|
||||
--}
|
||||
|
||||
|
||||
-- | A 1D point
|
||||
type Point = GLfloat
|
||||
-- | A Scalar value
|
||||
|
|
|
@ -22,4 +22,4 @@ Such an optimization would have been harder by using directly the OpenGL library
|
|||
|
||||
You should also want to make a more precise object. Because, the Mandelbulb is
|
||||
clearly not convex. But a precise rendering might be very long from
|
||||
\\(O(n^2log n)\\) to \\(O(n^3)\\).
|
||||
O(n².log(n)) to O(n³).
|
||||
|
|
Loading…
Reference in a new issue