Adding a shared VBO for streaming data.

This commit is contained in:
Martin Gräßlin 2010-12-11 15:52:21 +01:00
parent a352a0e6a8
commit 45f42cdea9
2 changed files with 30 additions and 1 deletions

View file

@ -1498,6 +1498,7 @@ class GLVertexBufferPrivate
int dimension;
bool useShader;
static bool supported;
static GLVertexBuffer *streamingBuffer;
QVector<float> legacyVertices;
QVector<float> legacyTexCoords;
bool useColor;
@ -1508,6 +1509,7 @@ class GLVertexBufferPrivate
void corePainting( const QRegion& region, GLenum primitiveMode );
};
bool GLVertexBufferPrivate::supported = false;
GLVertexBuffer *GLVertexBufferPrivate::streamingBuffer = NULL;
void GLVertexBufferPrivate::legacyPainting( QRegion region, GLenum primitiveMode )
{
@ -1721,6 +1723,16 @@ void GLVertexBuffer::setColor(const QColor& color, bool enable)
d->color = color;
}
void GLVertexBuffer::reset()
{
d->useColor = false;
d->color = QColor(0, 0, 0, 255);
d->numberVertices = 0;
d->dimension = 2;
d->useShader = false;
d->useTexCoords = true;
}
void GLVertexBuffer::initStatic()
{
#ifdef KWIN_HAVE_OPENGLES
@ -1728,8 +1740,13 @@ void GLVertexBuffer::initStatic()
#else
GLVertexBufferPrivate::supported = hasGLExtension( "GL_ARB_vertex_buffer_object" );
#endif
GLVertexBufferPrivate::streamingBuffer = new GLVertexBuffer(GLVertexBuffer::Stream);
}
GLVertexBuffer *GLVertexBuffer::streamingBuffer()
{
return GLVertexBufferPrivate::streamingBuffer;
}
} // namespace

View file

@ -62,7 +62,6 @@ void KWIN_EXPORT initGL();
// Initializes EGL function pointers
void KWIN_EXPORT initEGL();
// Number of supported texture units
extern KWIN_EXPORT int glTextureUnitsCount;
@ -552,6 +551,13 @@ class KWIN_EXPORT GLVertexBuffer
**/
void setUseColor(bool enable);
/**
* Resets the instance to default values.
* Useful for shared buffers.
* @since 4.7
**/
void reset();
/**
* @internal
*/
@ -563,6 +569,12 @@ class KWIN_EXPORT GLVertexBuffer
*/
static bool isSupported();
/**
* @return A shared VBO for streaming data
* @since 4.7
**/
static GLVertexBuffer *streamingBuffer();
private:
GLVertexBufferPrivate* const d;
};