hsSDL2 icon indicating copy to clipboard operation
hsSDL2 copied to clipboard

Haskell RTS frees glContext prematurely

Open spikeyarmaku opened this issue 10 years ago • 0 comments

The problem: when writing a HsSDL2 code that uses OpenGL, no GL update gets displayed after a few frames.

Tha cause is that currently glContext is a ForeignPtr, which has a finalizer, that calls SDL_GL_DeleteContext when the Haskell RTS has no reference to the pointer. Unfortunately since we don't use this pointer explicitly in the code after we create it with glCreateContext, Haskell RTS frees it after some time. (Using touchForeignPtr will prevent the RTS from calling the finalizer.)

spikeyarmaku avatar Aug 16 '14 22:08 spikeyarmaku