Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
9.8 KiB

  1. Paula Womack
  2. September 29, 1995
  3. A. SPECIFICATION
  4. Is there already an extension that does what I want?
  5. The specifications for extensions that have already been
  6. proposed by licensees can be obtained from sgiblab.sgi.com.
  7. via ftp using the opengl_l account. (Get the tar file
  8. extension_info.tar.Z.) Check out the extensions
  9. here before creating your own. There may be another licensee
  10. working on a similar extension.
  11. Some of the extension specifications are also available
  12. to the public on sgigate (using anonymous ftp). Look
  13. in pub/opengl/extensions.
  14. What is the best way to create a new extension?
  15. The best way to create a new extension is to first write
  16. a specification. A template can be found in the extension_info.tar.Z
  17. file. It is important to think about all the different areas of
  18. the OpenGL (and maybe GLX) specification that are affected. (For
  19. example, if you are defining a new attribute, can it be pushed and
  20. popped? How do you read back the values?) The template can help
  21. you with this.
  22. syntax.rules is also included in extension_info.tar.Z. Your
  23. extension should follow the OpenGL syntax guidelines.
  24. All the new names introduced by the extension should have a
  25. vendor-specific suffix appended to them. (e.g., glNewCommandSGI
  26. or glXNewCommandSGI) If another licensee agrees to support the
  27. extension, or if the ARB approves the extension, then the EXT
  28. designation can be used.
  29. How do I name my extension?
  30. All extensions must be named and the name should be included in
  31. the extension specification. The extension name must have the
  32. vendor-specific acronym or EXT prepended to the front. (e.g.,
  33. SGI_new_extension or EXT_new_extension)
  34. If the extension modifies OpenGL then the token GL_<ext_name>
  35. (e.g., GL_SGI_new_extension or GL_EXT_new_extension) must be
  36. included in the extension string that is returned by
  37. glGetString and it also must be defined in gl.h (or an
  38. include file that gl.h includes).
  39. If the extension modifies GLX then the token GLX_<ext_name>
  40. (e.g., GLX_SGI_new_extension or GLX_EXT_new_extension) must
  41. be included in the extension string that is returned by
  42. glXQueryExtensionsString, glXGetClientString, and glXQueryServerString
  43. (See below for a description of the different routines) and it
  44. also must be defined in glx.h (or an include file that glx.h
  45. includes).
  46. Note that extensions can have both OpenGL components and windowing system
  47. components. For example, the SGI multisampling extension modifies both
  48. GLX and OpenGL. In this case there will be two tokens associated
  49. with the extension (e.g., GL_SGIS_multisample and GLX_SGIS_multisample)
  50. and the extension will be advertised by both OpenGL and GLX.
  51. What else do I need to do?
  52. SGI keeps a registry of enumerated type values, GLX codes (vendor private opcodes,
  53. vendor private with reply opcodes, new visual attribute type values, GLX error
  54. codes and GLX event codes), OpenGL rendering codes for GLX, OpenGL rendering
  55. codes for gls and extension numbers.
  56. If an extension defines new enumerated types then you need to register a block
  57. of values from SGI (they are allocated in blocks of 16). If an extension
  58. defines new OpenGL rendering commands then you need to register gls rendering
  59. codes for it. Also, if you want the extensions to work with the X windowing
  60. system (i.e., with GLX), then you need to request some GLX opcodes and define
  61. GLX protocol for it.
  62. All new extensions should have a number associated with them for documentation
  63. purposes. If an extension depends on another extension, the other extension
  64. must have a lower number. (Note that when an extension is deprecated the number
  65. associated with it is not reassigned.) This number must also be registered
  66. with SGI.
  67. It is a good idea to include the new enumerated values, GLX codes and extension
  68. number in the specification.
  69. Once you have completed the extension, you should consider making it available
  70. to other licensees by mailing it to [email protected]. SGI will then
  71. include the new extension in the extension_info.tar file on sgiblab.sgi.com.
  72. B. IMPLEMENTATION
  73. Errors:
  74. Whenever possible, extensions should use existing errors instead of defining
  75. new error returns. For GLX, if a new protocol error is introduced, then a
  76. error number must be registered with SGI.
  77. Vendors may ship a single OpenGL library, containing extensions, for a variety of
  78. platforms. It is possible that some of the extension routines defined in the
  79. library may not be supported on some of the platforms. If this is the case and
  80. an application calls a routine that is not supported by the current OpenGL
  81. renderer then a GL_INVALID_OPERATION error should be returned.
  82. Extension availability:
  83. OpenGL extensions must be advertised in the extension string returned by
  84. glGetString. Note that in a client-server environment, this call returns the
  85. set of extensions that can be supported on the connection. GLX client libraries
  86. must send a glXClientInfo request to the server at start up time (if the client
  87. libarary is 1.1 or later) indicating the version of the client library and the
  88. the OpenGL extensions that it supports. Then, when glGetString is called,
  89. the client issues a GetString request. The server intersects the set of
  90. extensions that the client supports with the set of extensions that it
  91. supports (if a glXClientInfo request was never received then the server
  92. assumes that the client supports no OpenGL extensions) and returns the result
  93. to the client. The client library then appends any client-side only extensions
  94. to the list and returns the result.
  95. Extension names for OpenGL extensions recognized by libGL.x must be defined in gl.h,
  96. or a header file that gl.h includes (e.g., #define GL_SGI_new_extension)
  97. GLX client-side extensions must be advertised in the extension string
  98. returned by glXGetClientString(); server-side extensions must be advertised
  99. in the extension string returned by glXQueryServerString().
  100. glXQueryExtensionsString() returns the list of extensions that can be
  101. supported on the connection. If the server supports GLX version 1.1 or
  102. greater then the client issues a glXQueryServerString request, intersects
  103. the returned string with the set of extensions it can support and then
  104. appends any client-side only extensions to the list.
  105. Extension names for OpenGL extensions recognized by libGL.x must be defined in
  106. glx.h, or a header file that glx.h includes (e.g., #define GLX_SGI_new_extension)
  107. C. USING EXTENSIONS
  108. Programmers that wish to use a particular OpenGL extension should check
  109. both compile-time defines (to ensure that the extension is supported
  110. by the library they are compiling against) and the extension string
  111. returned by glGetString (to ensure that the renderer supports
  112. the extension).
  113. For example, the following code could be used to check whether the renderer
  114. supports an OpenGL extension called GL_EXT_new_extension. This code would
  115. need to be executed after the context had been made current:
  116. static GLboolean CheckExtension(char *extName, const char *extString)
  117. {
  118. /*
  119. ** Search for extName in the extensions string. Use of strstr()
  120. ** is not sufficient because extension names can be prefixes of
  121. ** other extension names. Could use strtok() but the constant
  122. ** string returned by glGetString can be in read-only memory.
  123. */
  124. char *p = (char *)extString;
  125. char *end;
  126. int extNameLen;
  127. extNameLen = strlen(extName);
  128. end = p + strlen(p);
  129. while (p < end) {
  130. int n = strcspn(p, " ");
  131. if ((extNameLen == n) && (strncmp(extName, p, n) == 0)) {
  132. return GL_TRUE;
  133. }
  134. p += (n + 1);
  135. }
  136. return GL_FALSE;
  137. }
  138. const GLubyte *ext_string;
  139. int new_ext_supported = GL_FALSE;
  140. if ( CheckExtension("GL_EXT_new_extension", glGetString(GL_EXTENSIONS)) )
  141. new_ext_supported = GL_TRUE;
  142. If the renderer supports the extension, then it is safe to use it at runtime.
  143. (Note that in a client-server environment, glGetString will only return
  144. the set of extensions that can be supported by the client and server.)
  145. However, compile time checks must be made to ensure that the library
  146. that you are linked against supports the extension. For example:
  147. #ifdef GL_EXT_new_extension
  148. if (new_ext_supported)
  149. glNewExtensionEXT(...)
  150. #endif
  151. Before using a GLX extension, programmers should check the compile time
  152. defines and the extension string returned by glXQueryExtensionsString.
  153. Since glXQueryExtensionsString, is only available in GLX versions
  154. 1.1 and later, programmers must also check the GLX version.
  155. For example, the following code could be used to check whether an extension
  156. called GLX_EXT_new_extension can be used on the connection. This code would
  157. need to be executed after the connection had been opened and the existence
  158. of the GLX extension had been established.
  159. Display *dpy;
  160. int new_ext_supported = GL_FALSE;
  161. int major, minor, screen;
  162. if( !glXQueryVersion(dpy, &major, &minor) )
  163. exit(1);
  164. screen = DefaultScreen(dpy);
  165. #ifdef GLX_VERSION_1_1
  166. if ( minor > 0 || major > 1 )
  167. if ( CheckExtension("GLX_EXT_new_extension",
  168. glXQueryExtensionsString(dpy, screen)) )
  169. new_ext_supported = GL_TRUE;
  170. #endif
  171. If the extension is supported on the connection, then it is safe to use
  172. it at runtime. However, compile time checks must be made to ensure that
  173. the library that you are linked against supports the extension. For example:
  174. #ifdef GLX_EXT_new_extension
  175. if (new_ext_supported)
  176. glNewExtensionEXT(...)
  177. #endif