2019-11-05 22:35:38 +00:00
# pragma once
# include "buffers.h"
2021-09-18 10:20:28 +00:00
# include "gl_load.h"
2019-11-05 22:35:38 +00:00
# ifdef _MSC_VER
// silence bogus warning C4250: 'GLVertexBuffer': inherits 'GLBuffer::GLBuffer::SetData' via dominance
// According to internet infos, the warning is erroneously emitted in this case.
# pragma warning(disable:4250)
# endif
namespace OpenGLRenderer
{
class GLBuffer : virtual public IBuffer
{
protected :
const int mUseType ;
unsigned int mBufferId ;
int mAllocationSize = 0 ;
bool mPersistent = false ;
bool nomap = true ;
2021-09-18 10:20:28 +00:00
GLsync mGLSync = 0 ;
2019-11-05 22:35:38 +00:00
GLBuffer ( int usetype ) ;
~ GLBuffer ( ) ;
2021-10-30 07:34:38 +00:00
void SetData ( size_t size , const void * data , BufferUsageType usage ) override ;
2019-11-05 22:35:38 +00:00
void SetSubData ( size_t offset , size_t size , const void * data ) override ;
void Map ( ) override ;
void Unmap ( ) override ;
void Resize ( size_t newsize ) override ;
void * Lock ( unsigned int size ) override ;
void Unlock ( ) override ;
2021-09-18 10:20:28 +00:00
void GPUDropSync ( ) ;
void GPUWaitSync ( ) ;
2019-11-05 22:35:38 +00:00
public :
void Bind ( ) ;
} ;
class GLVertexBuffer : public IVertexBuffer , public GLBuffer
{
// If this could use the modern (since GL 4.3) binding system, things would be simpler... :(
struct GLVertexBufferAttribute
{
int bindingpoint ;
int format ;
int size ;
int offset ;
} ;
int mNumBindingPoints ;
GLVertexBufferAttribute mAttributeInfo [ VATTR_MAX ] = { } ; // Thanks to OpenGL's state system this needs to contain info about every attribute that may ever be in use throughout the entire renderer.
size_t mStride = 0 ;
public :
GLVertexBuffer ( ) ;
void SetFormat ( int numBindingPoints , int numAttributes , size_t stride , const FVertexBufferAttribute * attrs ) override ;
void Bind ( int * offsets ) ;
} ;
class GLIndexBuffer : public IIndexBuffer , public GLBuffer
{
public :
GLIndexBuffer ( ) ;
} ;
class GLDataBuffer : public IDataBuffer , public GLBuffer
{
int mBindingPoint ;
public :
GLDataBuffer ( int bindingpoint , bool is_ssbo ) ;
void BindRange ( FRenderState * state , size_t start , size_t length ) ;
void BindBase ( ) ;
} ;
}