Hi,
i was trying to create a multithreaded application that uses openGL, however when it came to text and textured quads i noticed interesting behaviour. I believe this is due to the initalisation of the text and texture data in the second (rear) thread.
If openGL is intialised in Winmain, it appears that the openGL states are not shared across winmain and the rear thread, i have a sample piece of code below
Winmain(…)
{
CBitmapDraw CBitmap;CpBitmap=&CBitmap;
int iReturn = CBitmap.SetBitmap(“NeHe.bmp”);
hThread = StartThread();
while(!bTexInitialised)
{};ReSizeGLScene(800,600);
.
.
.
Windows message loop and whatnot
}
this is followed by a windows message loop using peekmessage. note that bThreadInitalised is a global boolean variable initalised to false.
In the second thread
DWORD WINAPI ThreadProc(LPVOID pvoid)
{
//int iReturn = CpBitmap->SetBitmap(“NeHe.bmp”);
bTexInitialised = true;
.
.
.
Adds object to a drawing list
}
This draws just fine. however if i uncomment the int iReturn = CpBitmap->SetBitmap(“NeHe.bmp”); line in the thread and comment out that line in the winmain, the code no longer displays the bitmap. as far as i can tell both bits of code are identical, unless openGL has 2 state machines running.
Is this the case? if so how can i get around it without having to put all my openGL initialisation code in the front thread?