Advertisement
tinyevil

Untitled

Aug 24th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. HGLRC rc1 = wglCreateContext(hDC);
  2. HGLRC rc2 = wglCreateContext(hDC);
  3.  
  4. wglMakeCurrent(hDC, rc1);
  5. // generate some texture names
  6. GLuint texs[10];
  7. GLuint tex = 0;
  8. glGenTextures(10, texs);
  9.  
  10. // this gives us 8
  11. tex = texs[7];
  12.  
  13. // bind it and reserve some space
  14. glBindTexture(GL_TEXTURE_2D, tex);
  15. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
  16.  
  17. // share resources with other context
  18. wglShareLists(rc1, rc2);
  19.  
  20. // switch to the second context
  21. wglMakeCurrent(hDC, rc2);
  22. // tex belongs to this context too
  23. assert(glIsTexture(tex));
  24. // delete tex from the second context
  25. glDeleteTextures(1, &tex);
  26.  
  27. // switch back
  28. wglMakeCurrent(hDC, rc1);
  29. // tex is no longer a texture (even in rc1)
  30. assert(!glIsTexture(tex));
  31.  
  32. GLint tex2;
  33. // get the binding
  34. glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex2);
  35. // tex2 comes back as 8
  36. // it is not a texture
  37. assert(!glIsTexture(tex2));
  38.  
  39. // trying to upload it...
  40. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
  41. // still fails
  42. assert(!glIsTexture(tex2));
  43.  
  44. // bind it again
  45. glBindTexture(GL_TEXTURE_2D, tex2);
  46. // now its all good!
  47. assert(glIsTexture(tex2));
  48.  
  49. GLuint tex3;
  50. // this returns 8
  51. glGenTextures(1, &tex3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement