PDA

View Full Version : OpenGL, mpeg2, avi files and threads



yooyo
04-07-2003, 03:28 AM
Hi...

I have a small problem with OpenGL in multithread env. Im try to play mpeg2 or AVI
files in OpenGL texture object. I'll try to modify Texture3D example from DirectX sdk.
The problem is video didn't show on screen. My app create two rendering contexts and share lists between. If I upload texture in CTexRenderer: http://www.opengl.org/discussion_boards/ubb/biggrin.gifoRenderSample and render in main app thread, nothing happends. But if I upload texture CTexRenderer: http://www.opengl.org/discussion_boards/ubb/biggrin.gifoRenderSample
and render in same func, texture show's up in
window.

Whats going on? I have lock/unlock code in all functions that call gl. Also I have
context switching in CTexRenderer: http://www.opengl.org/discussion_boards/ubb/biggrin.gifoRenderSample, and in main render loop.

pseudo code...
hDC and hRC are globals...
Lock are CCritSect global object

CTexRenderer:OnRenderSample()
{
if (LocalRC!=NULL)
{
LocalDC = hDC;
LocalRC = wglCreateContext(hDC);
wglShareLists(hRC, LocalRC);
}
}

CTexRenderer: http://www.opengl.org/discussion_boards/ubb/biggrin.gifoRenderSample(Sample *pSample)
{
Lock.Lock();
wglMakeCurrent(LocalDC, LocalRC);
bind texture...
glTexSubImage(...); //upload image data...
// if I put RenderFrame code here, it show's
// in window
Lock.Unlock();
}

App:RenderFrame()
{
Lock.Lock();
wglMakeCurrent(hDC, hRC);
enable texture...
bind texture...
render quad
Lock.Unlock();
}

yooyo