Пример #1
0
/**
 * Create a GLX extension string for a set of enable bits.
 *
 * Creates a GLX extension string for the set of bit in \c enable_bits.  This
 * string is then stored in \c buffer if buffer is not \c NULL.  This allows
 * two-pass operation.  On the first pass the caller passes \c NULL for
 * \c buffer, and the function determines how much space is required to store
 * the extension string.  The caller allocates the buffer and calls the
 * function again.
 *
 * \param enable_bits  Bits representing the enabled extensions.
 * \param buffer       Buffer to store the extension string.  May be \c NULL.
 *
 * \return
 * The number of characters in \c buffer that were written to.  If \c buffer
 * is \c NULL, this is the size of buffer that must be allocated by the
 * caller.
 */
int
__glXGetExtensionString(const unsigned char *enable_bits, char *buffer)
{
    unsigned i;
    int length = 0;

    for (i = 0; known_glx_extensions[i].name != NULL; i++) {
        const unsigned bit = known_glx_extensions[i].bit;
        const size_t len = known_glx_extensions[i].name_len;

        if (EXT_ENABLED(bit, enable_bits)) {
            if (buffer != NULL) {
                (void) memcpy(&buffer[length], known_glx_extensions[i].name,
                              len);

                buffer[length + len + 0] = ' ';
                buffer[length + len + 1] = '\0';
            }

            length += len + 1;
        }
    }

    return length + 1;
}
Пример #2
0
/**
 * Check if a certain extension is enabled in a given context.
 *
 */
GLboolean
__glExtensionBitIsEnabled(struct glx_context *gc, unsigned bit)
{
   GLboolean enabled = GL_FALSE;

   if (gc != NULL) {
      enabled = EXT_ENABLED(bit, gc->gl_extension_bits);
   }

   return enabled;
}
Пример #3
0
/**
 * Check if a certain extension is enabled on a given screen.
 *
 * \param psc  Pointer to GLX per-screen record.
 * \param bit  Bit index in the direct-support table.
 * \returns If the extension bit is enabled for the screen, \c GL_TRUE is
 *          returned.  If the extension bit is not enabled or if \c psc is
 *          \c NULL, then \c GL_FALSE is returned.
 */
GLboolean
__glXExtensionBitIsEnabled(struct glx_screen * psc, unsigned bit)
{
   GLboolean enabled = GL_FALSE;

   if (psc != NULL) {
      __glXExtensionsCtr();
      __glXExtensionsCtrScreen(psc);
      enabled = EXT_ENABLED(bit, psc->direct_support);
   }

   return enabled;
}
Пример #4
0
/**
 * Convert a bit-field to a string of supported extensions.
 */
static char *
__glXGetStringFromTable(const struct extension_info *ext,
                        const unsigned char *supported)
{
   unsigned i;
   unsigned ext_str_len;
   char *ext_str;
   char *point;


   ext_str_len = 0;
   for (i = 0; ext[i].name != NULL; i++) {
      if (EXT_ENABLED(ext[i].bit, supported)) {
         ext_str_len += ext[i].name_len + 1;
      }
   }

   ext_str = malloc(ext_str_len + 1);
   if (ext_str != NULL) {
      point = ext_str;

      for (i = 0; ext[i].name != NULL; i++) {
         if (EXT_ENABLED(ext[i].bit, supported)) {
            (void) memcpy(point, ext[i].name, ext[i].name_len);
            point += ext[i].name_len;

            *point = ' ';
            point++;
         }
      }

      *point = '\0';
   }

   return ext_str;
}