Thanks for that Jules, it looks much more flexible now !
Here are the missing things :
. Setting the pixel format without re-creating the window fails on the messy win32 implementation,
here is what msdn says :
“Setting the pixel format of a window more than once can lead to significant complications for the Window Manager and for multithread applications, so it is not allowed” (…)
Here is a not-completly updated version of my test application if you want to try.
. When writing a multi threaded app, we need to initialise the context in the opengl worker thread, OpenGLContext::createContextForWindow() does the initialisation, but we need a way to use it in an OpenGLComponent after, it would be nice to have it as an optional parameter in the constructor for example.
Or maybe I missed something ?
. OpenGLPixelFormat::getAvailablePixelFormats() uses a temporary Component to find which pixel formats are available. However it will not work with multi-gpu systems cause you may not have the same extensions or pixel formats on a window that is positioned on a secondary display plugged to another graphic card. The component used should be a parameter to the function, or at least the position of this component.
. there are no way to get the current thread’s currently active context, it should be a simple addition (see the first post in this thread)
. Another simple and effective addition would be the ‘swap interval’ control aka ‘vertical synchronization’, which tells the graphic card to wait for the next screen’s refresh period to draw the next frame. It avoids dirty artifacts on the screen.
on win32 :
[code]void setSwapInterval(int swapInt)
{
StringArray wglExtensions;
getWglExtensions(oc->dc, wglExtensions);
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
if (wglExtensions.contains(“WGL_EXT_swap_control”) &&
WGL_EXT_FUNCTION_INIT(PFNWGLSWAPINTERVALEXTPROC, wglSwapIntervalEXT))
wglSwapIntervalEXT(swapInt) == TRUE;
}
int getSwapInterval()
{
StringArray wglExtensions;
getWglExtensions(oc->dc, wglExtensions);
PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT = NULL;
if (wglExtensions.contains(“WGL_EXT_swap_control”) &&
WGL_EXT_FUNCTION_INIT(PFNWGLGETSWAPINTERVALEXTPROC, wglGetSwapIntervalEXT))
{
return wglGetSwapIntervalEXT();
}
return 0;
}[/code]
on mac it should be :
[code]void setSwapInterval(int swapInt)
{
aglSetInteger (renderContext, AGL_SWAP_INTERVAL, &swapInt);
}
int getSwapInterval()
{
GLint swapInt;
aglGetInteger(renderContext, AGL_SWAP_INTERVAL, &swapInt);
return swapInt
}[/code]
… linux anyone ?