![Smile :)](./images/smilies/icon_smile.gif)
But I had to patch Irrlicht engine with two functions (in CIrrDeviceLinux class):
in private area:
Code: Select all
GLXWindow glxWin2;
GLXContext Context2;
Code: Select all
GLXContext const& createNewContext();;
void releaseContext( GLXContext const& a_context );
Code: Select all
glxWin2 = 0;
Context2 = 0;
Code: Select all
GLXContext const& CIrrDeviceLinux::createNewContext()
{
if( Context2 != 0 )
{
GLXContext cntx;
return cntx;
}
const int MAX_SAMPLES = 16;
int visualAttrBuffer[] =
{
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_ALPHA_SIZE, 4,
GLX_DEPTH_SIZE, 16,
GLX_DOUBLEBUFFER, GL_TRUE,
GLX_STENCIL_SIZE, 1,
GLX_SAMPLE_BUFFERS_ARB, GL_TRUE,
GLX_SAMPLES_ARB, MAX_SAMPLES,
None
};
int nitems = 0;
GLXFBConfig* configList = glXGetFBConfigs( display, screennr, &nitems );
Context2 = glXCreateNewContext( display, *configList, GLX_RGBA_TYPE, Context, True );//create a new context with common resources with first one
glxWin2 = glXCreateWindow( display, *configList, RootWindow( display, visual->screen ), NULL );//create a window
glXMakeContextCurrent( display, glxWin2, glxWin2, Context2 );//making second context current for this thread in specific window
return Context2;
}
void CIrrDeviceLinux::releaseContext( GLXContext const& a_context )
{
if( Context2 != a_context )
return;
glXDestroyContext( display, Context2 );
glXDestroyWindow( display, glxWin2 );
}
Code: Select all
static bool m_bScreenshotEnable;
Code: Select all
m_pIrrDriver->beginScene( true, true, SColor( 255, 0, 0, 0 ) );
if( DSIrrApp::m_bScreenshotEnable )
{
drawLoadingScreen();//just a function for drawing something
}
else
{
drawAll();//a function whitch draws all stuff
}
m_pIrrDriver->endScene();
Code: Select all
void* startLoadingThread( void *ptr )
{
tThreadData* data = (tThreadData*)ptr;
GLXContext context = ((CIrrDeviceLinux*)g_pIrrInterface->m_pIrrDevice)->createNewContext();
DSIrrApp::m_bLoadingScreen = true;
loadScene();
DSIrrApp::m_bLoadingScreen = false;
((CIrrDeviceLinux*)g_pIrrInterface->m_pIrrDevice)->releaseContext( context );
dsfree( data->fileName );
dsdelete( data );
return NULL;
}
Code: Select all
typedef struct _tThreadData
{
_tThreadData()
{
pIrrDriver = NULL;
fileName = NULL;
}
_tThreadData( IVideoDriver* pID, char* fN )
{
pIrrDriver = pID;
fileName = fN;
}
IVideoDriver* pIrrDriver;
char* fileName;
}tThreadData;
Code: Select all
//somwhere in the code
tThreadData* data = dsnew tThreadData( g_pIrrInterface->m_pIrrDriver, ascii );
int threadRet = pthread_create( &g_pLoadingThread, NULL, startLoadingThread, (void*)data );
Code: Select all
pthread_t g_pLoadingThread;
Code: Select all
#include <pthread.h>
#include <unistd.h>
![Wink ;-)](./images/smilies/icon_wink.gif)