From 04c59b434bc722147fbaab75bbd621174b38c796 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Aug 2016 00:40:31 +0200 Subject: [PATCH] - renamed WipeVertexBuffer to FSimpleVertexBuffer because this will be useful elsewhere, too. --- src/gl/data/gl_vertexbuffer.cpp | 28 ++++++++++++++++++++ src/gl/data/gl_vertexbuffer.h | 10 +++++++ src/gl/system/gl_framebuffer.h | 4 +-- src/gl/system/gl_wipe.cpp | 47 +-------------------------------- 4 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index fc17f7ff8..2f38a720e 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -71,6 +71,34 @@ FVertexBuffer::~FVertexBuffer() } } + +void FSimpleVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (gl.glslversion > 0) + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); + glDisableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); + } + else + { + glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &VTO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } +} + +void FSimpleVertexBuffer::set(FFlatVertex *verts, int count) +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.SetVertexBuffer(this); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW); +} + //========================================================================== // // diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 0223c5791..4d39a7f58 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -41,6 +41,16 @@ struct FFlatVertex #define VTO ((FFlatVertex*)NULL) +class FSimpleVertexBuffer : public FVertexBuffer +{ + TArray mBuffer; +public: + FSimpleVertexBuffer() + { + } + void BindVBO(); + void set(FFlatVertex *verts, int count); +}; class FFlatVertexBuffer : public FVertexBuffer { diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 2ba90ff5b..d648da30c 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -7,6 +7,7 @@ #endif class FHardwareTexture; +class FSimpleVertexBuffer; extern long gl_frameMS; extern long gl_frameCount; @@ -94,10 +95,9 @@ private: class Wiper { - class WipeVertexBuffer; protected: - WipeVertexBuffer *mVertexBuf; + FSimpleVertexBuffer *mVertexBuf; void MakeVBO(OpenGLFrameBuffer *fb); diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index bc1708061..2978dd55d 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -271,51 +271,6 @@ void OpenGLFrameBuffer::WipeCleanup() FMaterial::ClearLastTexture(); } -//========================================================================== -// -// The wiper vertex buffer -// -// Note that this will recreate the buffer each frame, although -// only for melt its contents will change. -// -// But since this is no time critical code, ease of implementation -// was chosen over maximum efficiency. -// -//========================================================================== - -class OpenGLFrameBuffer::Wiper::WipeVertexBuffer : public FVertexBuffer -{ -public: - WipeVertexBuffer() - { - } - void BindVBO() - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - if (gl.glslversion > 0) - { - glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); - glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); - glDisableVertexAttribArray(VATTR_COLOR); - glDisableVertexAttribArray(VATTR_VERTEX2); - } - else - { - glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &VTO->x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &VTO->u); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - } - } - void set(FFlatVertex *verts, int count) - { - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - gl_RenderState.SetVertexBuffer(this); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW); - } -}; - //========================================================================== // // OpenGLFrameBuffer :: Wiper Constructor @@ -323,7 +278,7 @@ public: //========================================================================== OpenGLFrameBuffer::Wiper::Wiper() { - mVertexBuf = new WipeVertexBuffer; + mVertexBuf = new FSimpleVertexBuffer; } OpenGLFrameBuffer::Wiper::~Wiper()