Qt 4.8
Public Functions | Properties | List of all members
QGLExtensionMatcher Class Reference

#include <qgl_p.h>

Public Functions

bool match (const char *str) const
 

Properties

QByteArray m_extensions
 
QVector< int > m_offsets
 
 QGLExtensionMatcher (const char *str)
 
 QGLExtensionMatcher ()
 
void init (const char *str)
 

Detailed Description

Definition at line 900 of file qgl_p.h.

Constructors and Destructors

◆ QGLExtensionMatcher() [1/2]

QGLExtensionMatcher::QGLExtensionMatcher ( const char *  str)

Definition at line 5619 of file qgl.cpp.

5620 {
5621  init(str);
5622 }
void init(const char *str)
Definition: qgl.cpp:5654

◆ QGLExtensionMatcher() [2/2]

QGLExtensionMatcher::QGLExtensionMatcher ( )

Definition at line 5624 of file qgl.cpp.

5625 {
5626  const char *extensionStr = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
5627 
5628  if (extensionStr) {
5629  init(extensionStr);
5630  } else {
5631  // clear error state
5632  while (glGetError()) {}
5633 
5635  if (ctx) {
5636  qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress(QLatin1String("glGetStringi"));
5637 
5638  GLint numExtensions;
5639  glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
5640 
5641  for (int i = 0; i < numExtensions; ++i) {
5642  const char *str = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
5643 
5645 
5646  while (*str != 0)
5647  m_extensions.append(*str++);
5648  m_extensions.append(' ');
5649  }
5650  }
5651  }
5652 }
QByteArray & append(char c)
Appends the character ch to this byte array.
const GLubyte *(APIENTRY * qt_glGetStringi)(GLenum, GLuint)
Definition: qgl.cpp:5613
void * getProcAddress(const QString &proc) const
Returns a function pointer to the GL extension function passed in proc.
Definition: qgl_egl.cpp:379
static const QGLContext * currentContext()
Returns the current context, i.e.
Definition: qgl.cpp:3545
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
#define GL_EXTENSIONS
QVector< int > m_offsets
Definition: qgl_p.h:925
QByteArray m_extensions
Definition: qgl_p.h:924
void init(const char *str)
Definition: qgl.cpp:5654
#define ctx
Definition: qgl.cpp:6094
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
typedef GLint
Definition: glfunctions.h:67
#define GL_NUM_EXTENSIONS
Definition: qgl.cpp:5616

Functions

◆ init()

void QGLExtensionMatcher::init ( const char *  str)
private

Definition at line 5654 of file qgl.cpp.

5655 {
5656  m_extensions = str;
5657 
5658  // make sure extension string ends with a space
5659  if (!m_extensions.endsWith(' '))
5660  m_extensions.append(' ');
5661 
5662  int index = 0;
5663  int next = 0;
5664  while ((next = m_extensions.indexOf(' ', index)) >= 0) {
5665  m_offsets << index;
5666  index = next + 1;
5667  }
5668 }
QByteArray & append(char c)
Appends the character ch to this byte array.
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
QVector< int > m_offsets
Definition: qgl_p.h:925
QByteArray m_extensions
Definition: qgl_p.h:924
quint16 index
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ match()

bool QGLExtensionMatcher::match ( const char *  str) const
inline

Definition at line 906 of file qgl_p.h.

Referenced by QGL2PaintEngineEx::begin(), buildSpec(), qgl_use_font(), qglx_getProcAddress(), qt_gl_resolve_features(), qt_resolve_buffer_extensions(), and QGLContext::tryVisual().

906  {
907  int str_length = qstrlen(str);
908 
909  Q_ASSERT(str);
910  Q_ASSERT(str_length > 0);
911  Q_ASSERT(str[str_length-1] != ' ');
912 
913  for (int i = 0; i < m_offsets.size(); ++i) {
914  const char *extension = m_extensions.constData() + m_offsets.at(i);
915  if (qstrncmp(extension, str, str_length) == 0 && extension[str_length] == ' ')
916  return true;
917  }
918  return false;
919  }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QVector< int > m_offsets
Definition: qgl_p.h:925
uint qstrlen(const char *str)
Definition: qbytearray.h:79
QByteArray m_extensions
Definition: qgl_p.h:924
int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qbytearray.h:101
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

Properties

◆ m_extensions

QByteArray QGLExtensionMatcher::m_extensions
private

Definition at line 924 of file qgl_p.h.

◆ m_offsets

QVector<int> QGLExtensionMatcher::m_offsets
private

Definition at line 925 of file qgl_p.h.


The documentation for this class was generated from the following files: