Skip to content

Multi-context rendering #4

@Noeda

Description

@Noeda

I'm going to leave this issue here to track a problem with a way caramia (and OpenGLRaw) handle multiple OpenGL contexts.

The way things work now that all OpenGL functions are stored in top-level IORefs and when a function is called, it is fetched from IORef and called.

This works most of the time and with most drivers but some drivers report different function pointers when a new OpenGL context is set up (I've been told some drivers on Windows do this). So this is relevant for having multiple contexts active at the same time and also programs that may set up one context, tear it down, set up another one etc. in the same process (one application type that may do this is automated testing programs).

The second type of application (that doesn't use multiple contexts at the same time) can be dealt with by forcing the load of new function pointers whenever flextInit is called. The FlextGL module does this but the way of calling the function has a peculiar usage of unsafePerformIO in a normal IO action that might not actually end up using the reloaded function pointer.

Right now I don't think this is a serious problem because most applications just want one context in their lifetime as a process. I think safe multi-context might be difficult to implement without thread-local storage unless we want to abandon purely IO interface (I don't).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions