From 636b93a7b5be235369a85fad39b4575f1585b493 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 5 Jun 2014 12:54:01 +0200 Subject: [PATCH] GL3: Cleanup --HG-- branch : opengl3 --- .../src/3d/driver/opengl3/driver_opengl.cpp | 8 ++--- .../nel/src/3d/driver/opengl3/driver_opengl.h | 21 ++++++------ .../driver/opengl3/driver_opengl_vertex.cpp | 6 ++-- .../opengl3/driver_opengl_vertex_buffer.cpp | 32 +++++++++---------- .../opengl3/driver_opengl_vertex_buffer.h | 24 ++++++++------ 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp index c43005b6e..a20a72ab5 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp @@ -1080,7 +1080,7 @@ void CDriverGL3::enableUsedTextureMemorySum (bool enable) H_AUTO_OGL(CDriverGL3_enableUsedTextureMemorySum) if (enable) - nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL"); + nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL3"); _SumTextureMemoryUsed=enable; } @@ -1426,10 +1426,10 @@ void CDriverGL3::profileVBHardAllocation(std::vector &result) result.push_back(toString("Num VBHard: %d", _VertexBufferGLSet.Set.size())); uint totalMemUsed= 0; - set::iterator it; + set::iterator it; for (it= _VertexBufferGLSet.Set.begin(); it!=_VertexBufferGLSet.Set.end(); it++) { - IVertexBufferGL *vbHard= *it; + IVertexBufferGL3 *vbHard= *it; if (vbHard) { uint vSize= vbHard->VB->getVertexSize(); @@ -1441,7 +1441,7 @@ void CDriverGL3::profileVBHardAllocation(std::vector &result) for (it= _VertexBufferGLSet.Set.begin(); it!=_VertexBufferGLSet.Set.end(); it++) { - IVertexBufferGL *vbHard= *it; + IVertexBufferGL3 *vbHard= *it; if (vbHard) { uint vSize= vbHard->VB->getVertexSize(); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.h b/code/nel/src/3d/driver/opengl3/driver_opengl.h index 2d52e6446..c988497da 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.h @@ -87,8 +87,7 @@ namespace NLDRIVERGL3 { #endif class CDriverGL3; -class IVertexArrayRange; -class IVertexBufferGL; +class IVertexBufferGL3; class COcclusionQueryGL3; void displayGLError(GLenum error); @@ -190,7 +189,7 @@ public: CVBDrvInfosGL3(CDriverGL3 *drv, ItVBDrvInfoPtrList it, CVertexBuffer *vb); // Verex buffer hard ? - IVertexBufferGL *_VBHard; + IVertexBufferGL3 *_VBHard; CDriverGL3 *_DriverGL; // From IVBDrvInfos @@ -250,7 +249,7 @@ public: } void setupVertexBuffer(CVertexBuffer &vb); - void setupVertexBufferHard(IVertexBufferGL &vb); + void setupVertexBufferHard(IVertexBufferGL3 &vb); }; @@ -690,7 +689,7 @@ public: #endif private: - virtual class IVertexBufferGL *createVertexBufferGL(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb); + virtual class IVertexBufferGL3 *createVertexBufferGL(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb); friend class CTextureDrvInfosGL3; friend class CVertexProgamDrvInfosGL3; @@ -790,7 +789,7 @@ private: #elif defined(NL_OS_MAC) - friend bool GlWndProc(CDriverGL*, const void*); + friend bool GlWndProc(CDriverGL3*, const void*); CocoaOpenGLView* _glView; NSAutoreleasePool* _autoreleasePool; @@ -1125,17 +1124,17 @@ private: /// \name Vertex Buffer // @{ - CPtrSet _VertexBufferGLSet; - friend class CVertexBufferGL; + CPtrSet _VertexBufferGLSet; + friend class CVertexBufferGL3; friend class CVBDrvInfosGL3; // The VertexBufferHardGL activated. - IVertexBufferGL *_CurrentVertexBufferGL; + IVertexBufferGL3 *_CurrentVertexBufferGL; GLenum vertexBufferUsageGL3(CVertexBuffer::TPreferredMemory usage); // Handle lost buffers void updateLostBuffers(); - std::list _LostVBList; + std::list _LostVBList; // @} @@ -1329,7 +1328,7 @@ protected: public: void incrementResetCounter() { ++_ResetCounter; } bool isWndActive() const { return _WndActive; } - const IVertexBufferGL *getCurrentVertexBufferHard() const { return _CurrentVertexBufferGL; } + const IVertexBufferGL3 *getCurrentVertexBufferHard() const { return _CurrentVertexBufferGL; } // For debug : dump list of mapped buffers #ifdef NL_DEBUG void dumpMappedBuffers(); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp index 8ef0e4c3a..1349c7f45 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex.cpp @@ -260,7 +260,7 @@ GLenum CDriverGL3::vertexBufferUsageGL3(CVertexBuffer::TPreferredMemory usage) } // *************************************************************************** -IVertexBufferGL *CDriverGL3::createVertexBufferGL(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb) +IVertexBufferGL3 *CDriverGL3::createVertexBufferGL(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb) { H_AUTO_OGL(CDriverGL3_createVertexBufferGL) @@ -269,7 +269,7 @@ IVertexBufferGL *CDriverGL3::createVertexBufferGL(uint size, uint numVertices, C nglGenBuffers(1, &vertexBufferID); _DriverGLStates.forceBindARBVertexBuffer(vertexBufferID); nglBufferData(GL_ARRAY_BUFFER, size, NULL, vertexBufferUsageGL3(vbType)); - CVertexBufferGL *newVbHard = new CVertexBufferGL(this, vb); + CVertexBufferGL3 *newVbHard = new CVertexBufferGL3(this, vb); newVbHard->initGL(vertexBufferID, vbType); _DriverGLStates.forceBindARBVertexBuffer(0); return _VertexBufferGLSet.insert(newVbHard); @@ -284,7 +284,7 @@ void CDriverGL3::updateLostBuffers() // We do this only if the app is active, because if vb were lost, it is likely that there are no resources available. if (isWndActive()) { - for (std::list::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it) + for (std::list::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it) { nlassert((*it)->VertexObjectId); GLuint id = (GLuint) (*it)->VertexObjectId; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.cpp index ba2d87ef7..679bbdd27 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.cpp @@ -31,21 +31,21 @@ namespace NLDRIVERGL3 { #endif // *************************************************************************** -IVertexBufferGL::IVertexBufferGL(CDriverGL3 *drv, CVertexBuffer *vb) : VB (vb) +IVertexBufferGL3::IVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb, TVBType vbType) + : VB(vb), VBType(vbType), m_Driver(drv), m_Invalid(false) { H_AUTO_OGL(IVertexBufferGL_IVertexBufferGL) - m_Driver= drv; - m_Invalid = false; } + // *************************************************************************** -IVertexBufferGL::~IVertexBufferGL() +IVertexBufferGL3::~IVertexBufferGL3() { H_AUTO_OGL(IVertexBufferGL_IVertexBufferGLDtor) } // *************************************************************************** -CVertexBufferGL::CVertexBufferGL(CDriverGL3 *drv, CVertexBuffer *vb) - : IVertexBufferGL(drv, vb), +CVertexBufferGL3::CVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb) + : IVertexBufferGL3(drv, vb, IVertexBufferGL3::GL3), m_VertexPtr(NULL), VertexObjectId(0) { @@ -53,7 +53,7 @@ CVertexBufferGL::CVertexBufferGL(CDriverGL3 *drv, CVertexBuffer *vb) } // *************************************************************************** -CVertexBufferGL::~CVertexBufferGL() +CVertexBufferGL3::~CVertexBufferGL3() { H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARBDtor) if (m_Driver && VertexObjectId) @@ -83,7 +83,7 @@ CVertexBufferGL::~CVertexBufferGL() } // *************************************************************************** -void *CVertexBufferGL::lock() +void *CVertexBufferGL3::lock() { H_AUTO_OGL(CVertexBufferGLARB_lock); @@ -184,7 +184,7 @@ void *CVertexBufferGL::lock() } // *************************************************************************** -void CVertexBufferGL::unlock() +void CVertexBufferGL3::unlock() { H_AUTO_OGL(CVertexBufferGLARB_unlock); @@ -228,21 +228,21 @@ void CVertexBufferGL::unlock() } // *************************************************************************** -void *CVertexBufferGL::getPointer() +void *CVertexBufferGL3::getPointer() { H_AUTO_OGL(CVertexBufferGLARB_getPointer) return m_VertexPtr; } // *************************************************************************** -void CVertexBufferGL::unlock(uint /* startVert */,uint /* endVert */) +void CVertexBufferGL3::unlock(uint /* startVert */,uint /* endVert */) { H_AUTO_OGL(CVertexBufferGLARB_unlock) unlock(); // can't do a lock on a range of the vb.. } // *************************************************************************** -void CVertexBufferGL::enable() +void CVertexBufferGL3::enable() { H_AUTO_OGL(CVertexBufferGLARB_enable) if (m_Driver->_CurrentVertexBufferGL != this) @@ -254,7 +254,7 @@ void CVertexBufferGL::enable() } // *************************************************************************** -void CVertexBufferGL::disable() +void CVertexBufferGL3::disable() { H_AUTO_OGL(CVertexBufferGLARB_disable) if (m_Driver->_CurrentVertexBufferGL != NULL) @@ -266,7 +266,7 @@ void CVertexBufferGL::disable() } // *************************************************************************** -void CVertexBufferGL::initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemory memType) +void CVertexBufferGL3::initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemory memType) { H_AUTO_OGL(CVertexBufferGLARB_initGL) VertexObjectId = vertexObjectID; @@ -274,14 +274,14 @@ void CVertexBufferGL::initGL(uint vertexObjectID, CVertexBuffer::TPreferredMemor } // *************************************************************************** -void CVertexBufferGL::setupVBInfos(CVertexBufferInfo &vb) +void CVertexBufferGL3::setupVBInfos(CVertexBufferInfo &vb) { H_AUTO_OGL(CVertexBufferGLARB_setupVBInfos) vb.VertexObjectId = VertexObjectId; } // *************************************************************************** -void CVertexBufferGL::invalidate() +void CVertexBufferGL3::invalidate() { H_AUTO_OGL(CVertexBufferGLARB_invalidate) nlassert(!m_Invalid); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.h b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.h index ad84eaf43..6be121d76 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_buffer.h @@ -25,16 +25,19 @@ namespace NL3D { namespace NLDRIVERGL3 { #endif -class CDriverGL; -class IVertexBufferGL; +class CDriverGL3; +class IVertexBufferGL3; class CVertexBufferInfo; -class CVertexBufferGL; +class CVertexBufferGL3; -class IVertexBufferGL +class IVertexBufferGL3 { public: - IVertexBufferGL(CDriverGL3 *drv, CVertexBuffer *vb); - virtual ~IVertexBufferGL(); + enum TVBType { GL3 }; + + IVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb, TVBType vbType); + virtual ~IVertexBufferGL3(); + virtual void *lock() = 0; virtual void unlock() = 0; virtual void unlock(uint start, uint end) = 0; @@ -48,6 +51,7 @@ public: public: CVertexBuffer *VB; + TVBType VBType; protected: CDriverGL3 *m_Driver; @@ -55,11 +59,11 @@ protected: }; /* GL Core vertex buffer. */ -class CVertexBufferGL : public IVertexBufferGL +class CVertexBufferGL3 : public IVertexBufferGL3 { public: - CVertexBufferGL(CDriverGL3 *drv, CVertexBuffer *vb); - virtual ~CVertexBufferGL(); + CVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb); + virtual ~CVertexBufferGL3(); /// \name Implementation // @{ @@ -88,7 +92,7 @@ private: // if buffer has been invalidated, returns a dummy memory block and silently fails rendering std::vector m_DummyVB; // for use by CVertexArrayRange - std::list::iterator m_IteratorInLostVBList; + std::list::iterator m_IteratorInLostVBList; public: uint VertexObjectId;