Tools for asynchronous texture loading

How will texture loading be performed asynchronously while the 3D application is running? I understand that OpenGL contexts are not thread safe and that I have to split them into different threads.

But my main problem is to choose a suitable multithreaded tool / framework to actually implement this using Windows and C ++, I heard a lot about C ++ 11, including streaming support in standard lbrary, but could anyone then lay out only the basic steps?

What would be the safest way to do this? And how to update the state of another context so that it logs changes made in another thread? I suspect glFlushand glBind*?

+5
source share
2 answers

The most time-consuming part of loading textures is usually disk access and any format conversion, both of which are not dependent on OpenGL and thus can safely take place in another thread. After the texture has been read in memory and in the desired format, the actual copy to the OpenGL buffer is pretty fast.

Getting into the details of streaming programming is too complicated for this answer, but there is some documentation there, and as soon as it clicks on your head, it is pretty simple (like pointers and memory).

- (, , /, - ), . , , , , , . , OpenGL . , , , ( ).

. API-, (DirectX), , OpenGL , , . - , , , , . ( , , GPU ). OpenGL, .

Windows , , , ( , API). ++ 11 , Visual Studio, , .

+5

@ssube , , "OpenGL , , ", .

( ) ( ) , :

m_hRCDrawing = wglCreateContext(m_hDC);
m_hRCSecondary = wglCreateContext(m_hDC);

m_hRCSecondary m_hRCDrawing

wglShareLists(m_hRCSecondary, m_hRCDrawing);

, " ", GL, :

wglMakeCurrent(m_hDC, m_hRCSecondary); 

, , .

.

0

All Articles