Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HGLRC rc1 = wglCreateContext(hDC);
- HGLRC rc2 = wglCreateContext(hDC);
- wglMakeCurrent(hDC, rc1);
- // generate some texture names
- GLuint texs[10];
- GLuint tex = 0;
- glGenTextures(10, texs);
- // this gives us 8
- tex = texs[7];
- // bind it and reserve some space
- glBindTexture(GL_TEXTURE_2D, tex);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
- // share resources with other context
- wglShareLists(rc1, rc2);
- // switch to the second context
- wglMakeCurrent(hDC, rc2);
- // tex belongs to this context too
- assert(glIsTexture(tex));
- // delete tex from the second context
- glDeleteTextures(1, &tex);
- // switch back
- wglMakeCurrent(hDC, rc1);
- // tex is no longer a texture (even in rc1)
- assert(!glIsTexture(tex));
- GLint tex2;
- // get the binding
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex2);
- // tex2 comes back as 8
- // it is not a texture
- assert(!glIsTexture(tex2));
- // trying to upload it...
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
- // still fails
- assert(!glIsTexture(tex2));
- // bind it again
- glBindTexture(GL_TEXTURE_2D, tex2);
- // now its all good!
- assert(glIsTexture(tex2));
- GLuint tex3;
- // this returns 8
- glGenTextures(1, &tex3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement