/Doc/Texture.html

https://bitbucket.org/alsh/pygui-mirror · HTML · 56 lines · 55 code · 1 blank · 0 comment · 0 complexity · 0d33e3b522ddab9d1171051264d36381 MD5 · raw file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>PyGUI - GL.Texture class</title></head>
  3. <body>
  4. <h1>class <span style="font-family: monospace;">GL.Texture</span></h1>
  5. The Texture class in the GL submodule provides a context-independent
  6. representation of an OpenGL texture. You can use a single Texture
  7. object with multiple GLViews and/or GLPixmaps without being concerned
  8. whether they are sharing texture spaces or not, and without having to
  9. keep track of OpenGL texture numbers.<br>
  10. <br>
  11. Texture is an abstract class. To use it, you subclass it and define the <span style="font-family: monospace;">do_setup</span>
  12. method to make whatever OpenGL calls are necessary to set up the
  13. texture. Then, when you want to draw with the texture, you call the <span style="font-family: monospace;">bind</span>
  14. method to make it the current OpenGL texture. Whenever the Texture is
  15. used in a context where it has not been used before, your <span style="font-family: monospace;">do_setup</span> method will be called to create a representation of the texture appropriate to that context.<br>
  16. <br>
  17. Keep in mind that any call to <span style="font-family: monospace;">bind</span> can trigger allocation of a texture number and a call to your <span style="font-family: monospace;">do_setup</span>
  18. method, and this will usually happen while you are in the middle of
  19. doing OpenGL drawing. If this would be inconvenient, you may need to
  20. "preload" the texture by calling the <span style="font-family: monospace;">bind</span> method once in each context where the texture might be used, before you start drawing.<br>
  21. <h2>Constructor</h2>
  22. <div style="margin-left: 40px;">
  23. <dl>
  24. <dt style="font-family: monospace;">Texture(texture_type)</dt>
  25. <dd>Constructs a texture of the given type. The <span style="font-style: italic;">texture_type</span> should be one of the OpenGL texture type constants (GL_TEXTURE_2D etc).<br>
  26. </dd>
  27. </dl>
  28. </div>
  29. <h2>Methods</h2>
  30. <div style="margin-left: 40px;">
  31. <dl>
  32. <dt style="font-family: monospace;">bind()</dt>
  33. <dd>Makes this
  34. texture the current texture for the current context by calling
  35. glBindTexture. If this texture has not previously been used
  36. with the current context (or one with which it is sharing
  37. textures), an OpenGL texture number is allocated and <span style="font-family: monospace;">do_setup</span> is called to initialise a representation of the texture.<br>
  38. <br>
  39. </dd><dt style="font-family: monospace;">deallocate()</dt>
  40. <dd>Deallocates any OpenGL resources currently allocated to the Texture. If it is used again, new resources will be allocated.<br>
  41. </dd>
  42. </dl>
  43. </div>
  44. <h2>Abstract methods</h2>
  45. <div style="margin-left: 40px;">
  46. <dl>
  47. <dt style="font-family: monospace;">do_setup()</dt>
  48. <dd>This method should be implemented to make the necessary OpenGL
  49. calls to initialise the texture. When this method is called, a texture
  50. number will already have been allocated and <span style="font-family: monospace;">glBindTexture</span> called to make it the current texture.<br>
  51. </dd>
  52. </dl>
  53. </div>
  54. <br>
  55. </body></html>