Original Post
Hi All,
I''ve got a small problem Ive been working on for hours trying to solve. I''m trying to render stuff in a thread other then my main one. I''m using the win32 stuff _beginthread()
my thread function right now is just :
void LoadBar(void *pData)
{
bool blocalDie = false;
while(!blocalDie)
{
EnterCriticalSection(&cs);
// Clear the color Buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, ((Game*)pData)->texs[1]);
((Game*)pData)->StartOrtho();
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(0.0f, 100.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(100.0f, 100.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(100.0f, 0.0f);
glEnd();
((Game*)pData)->EndOrtho();
// Swap the Buffers
SwapBuffers(((Game*)pData)->Hdc);
if (((Game*)pData)->percentLoaded == 100)
blocalDie = true;
LeaveCriticalSection(&cs);
}
}
This exact section of code works on the normal thread but on the other thread it doesn''t render anything. I dont crash it just runs the main thread and does what it needs to do. However, when debugging I can get into this function and see that it is being called. I''m just wondering if there is anything I need to know about running a thread like this in OpenGL. I am concerend because when I use glGetFloatv(GL_COLOR_CLEAR_VALUE) in the main thread it returns 0 but in the second thread it says a non initialized number making me think the thread knows nothing about the OpenGL rendering context.
Well if anyone has done this before or knows my problem I would appreciate any help.
Thanks,
Nextgengamer
www.celestialwake.com