From 45f42cdea993f3e173588f4254dc432be58c69ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 11 Dec 2010 15:52:21 +0100 Subject: [PATCH] Adding a shared VBO for streaming data. --- lib/kwinglutils.cpp | 17 +++++++++++++++++ lib/kwinglutils.h | 14 +++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index 051026dfaa..ae0ed72453 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -1498,6 +1498,7 @@ class GLVertexBufferPrivate int dimension; bool useShader; static bool supported; + static GLVertexBuffer *streamingBuffer; QVector legacyVertices; QVector 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 diff --git a/lib/kwinglutils.h b/lib/kwinglutils.h index 8ff045b71d..7e9eebb705 100644 --- a/lib/kwinglutils.h +++ b/lib/kwinglutils.h @@ -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; };