Custom event loops...?

Hi all,

A seriously newbie question I’m afraid! I’m wanting to use OpenGL as a fast was to plot some 2D graphics. Essentially, I have an iterative statistical algorithm (MCMC for anyone who’s interested) that plays around with some spatial data. As part of the debug, I’d like to be able to visualise exactly how the algorithm is playing with the spatial aspect, and so I thought that following it with a map that is constantly updated would be a neat solution.

Trouble is, this algorithm already has its own event loop - where bits of spatial data get chosen, worked upon, and stored in an iterative sense. For each iteration, the map needs updating. Now, is there an easy way to use OpenGL with this? I’m guessing that GLUT is out because it has its own mainEventLoop? Could anyone suggest a suitable Linux API for me to get started with?

Thanks,

Chris

What you are looking for is GLX with manual window management through X system. Or rewrite the algorithm so it uses a parallel thread or something similar and use GLUT or GLFW.

You could use SDL for this. What you’ll probably want to do is write the main SDL event loop, then run 1+ iterations of the algorithm inside, update buffers, render, check for events, etc.

Look here for a simple example. :slight_smile:

Great! Thanks HexCat, the SDL idea looks like it’ll do exactly what I need it to.

Chris