kwin: Add a new GLVertexBuffer::draw() method
Expose bindArrays(), unbindArrays() and add a draw() method that takes an offset and a count. This makes it possible to upload geometry, call bindArrays(), and then call draw() multiple times to draw different subsets of the uploaded geometry.icc-effect-5.14.5
parent
40d6bd66d4
commit
993b50cf1c
|
@ -1600,18 +1600,31 @@ void GLVertexBuffer::render(GLenum primitiveMode)
|
|||
void GLVertexBuffer::render(const QRegion& region, GLenum primitiveMode, bool hardwareClipping)
|
||||
{
|
||||
d->bindArrays();
|
||||
draw(region, primitiveMode, 0, d->vertexCount, hardwareClipping);
|
||||
d->unbindArrays();
|
||||
}
|
||||
|
||||
void GLVertexBuffer::bindArrays()
|
||||
{
|
||||
d->bindArrays();
|
||||
}
|
||||
|
||||
void GLVertexBuffer::unbindArrays()
|
||||
{
|
||||
d->unbindArrays();
|
||||
}
|
||||
|
||||
void GLVertexBuffer::draw(const QRegion ®ion, GLenum primitiveMode, int first, int count, bool hardwareClipping)
|
||||
{
|
||||
if (!hardwareClipping) {
|
||||
glDrawArrays(primitiveMode, 0, d->vertexCount);
|
||||
glDrawArrays(primitiveMode, first, count);
|
||||
} else {
|
||||
// Clip using scissoring
|
||||
foreach (const QRect &r, region.rects()) {
|
||||
glScissor(r.x(), displayHeight() - r.y() - r.height(), r.width(), r.height());
|
||||
glDrawArrays(primitiveMode, 0, d->vertexCount);
|
||||
glDrawArrays(primitiveMode, first, count);
|
||||
}
|
||||
}
|
||||
|
||||
d->unbindArrays();
|
||||
}
|
||||
|
||||
bool GLVertexBuffer::isSupported()
|
||||
|
|
|
@ -707,6 +707,21 @@ public:
|
|||
*/
|
||||
void unmap();
|
||||
|
||||
/**
|
||||
* Binds the vertex arrays to the context.
|
||||
*/
|
||||
void bindArrays();
|
||||
|
||||
/**
|
||||
* Disables the vertex arrays.
|
||||
*/
|
||||
void unbindArrays();
|
||||
|
||||
/**
|
||||
* Draws count vertices beginning with first.
|
||||
*/
|
||||
void draw(const QRegion ®ion, GLenum primitiveMode, int first, int count, bool hardwareClipping = false);
|
||||
|
||||
/**
|
||||
* Renders the vertex data in given @a primitiveMode.
|
||||
* Please refer to OpenGL documentation of glDrawArrays or glDrawElements for allowed
|
||||
|
|
Loading…
Reference in New Issue