[Haskell-cafe] OpenGL performance issue on OSX

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Thu May 22 20:13:00 UTC 2014


Michael Baker wrote:
> I've added a VAO and reduced the inner loop to only a call to glDrawArrays
> which renders 8000 triangles (24000 vertices). The gameFrame function now
> benchmarks at ~86ms on my machine. I would expect it to be ~16ms because of
> vsync.

You're expecting too much from your graphics hardware. The total area of
the triangles that you are drawing covers approximately 80 million pixels
(they overlap a lot). If one uses non-overlapping triangles (with a total
area close to 60k pixels)

floats = concat $ [[0, 0, 0, cos ((x+1) / triangles), sin ((x+1) / triangles), 0, cos (x / triangles), sin (x / triangles), 0] | x <- [0..triangles]] :: [GLfloat]

the program becomes a lot faster.

Code:

let area [] = 0; area (x1:y1:_:x2:y2:_:x3:y3:_:xs) = ((x3-x1)*(y2-y1) - (x2-x1)*(y3-y1))/2*400*300 + area xs in area floats

Cheers,

Bertram


More information about the Haskell-Cafe mailing list