Created
July 27, 2015 18:51
-
-
Save fkaa/964bd909d86100034c3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int frameTexture; // shared | |
// main thread | |
// probably need some synchronization between decoding a frame | |
// on the decoder thread and displaying it on the main | |
glBindTexture(GL_TEXTURE_2D, frameTexture); | |
glDrawEverythingForMe(GL_MAGICAL_ENUM, 0xDEADBEEF); | |
// decode thread | |
// get secondary context | |
makeCurrent(); | |
// switching between two PBOs will make it double buffered, | |
// and consume 2x space | |
while ((data = decode(foo)) != null) { | |
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo); | |
byte *ptr = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, ...); | |
glBufferData(..., data); | |
glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER); | |
glBindTexture(GL_TEXTURE_2D, frameTexture); | |
glTexSubImage2D (GL_TEXTURE_2D, ..., (void *) 0); | |
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment