1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

VBO implementation.

Thanks to Logan McNaughton for help.
This commit is contained in:
Sergey Lipskiy 2017-02-05 18:41:06 +07:00
parent dddb3ae1f7
commit a625225323
9 changed files with 350 additions and 4 deletions

View File

@ -314,6 +314,7 @@
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_TextureManipulationObjectFactory.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_UnbufferedDrawer.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_Utils.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_BufferedDrawer.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\windows\windows_DisplayWindow.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>
@ -447,6 +448,7 @@
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_TextureManipulationObjectFactory.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_UnbufferedDrawer.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_Utils.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_BufferedDrawer.h" />
<ClInclude Include="..\..\src\Graphics\Parameter.h" />
<ClInclude Include="..\..\src\Graphics\Parameters.h" />
<ClInclude Include="..\..\src\Graphics\PixelBuffer.h" />

View File

@ -326,6 +326,9 @@
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithBufferStorage.cpp">
<Filter>Source Files\Graphics\OpenGL</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_BufferedDrawer.cpp">
<Filter>Source Files\Graphics\OpenGL</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\3DMath.h">
@ -616,5 +619,8 @@
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithBufferStorage.h">
<Filter>Header Files\Graphics\OpenGL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_BufferedDrawer.h">
<Filter>Header Files\Graphics\OpenGL</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -64,6 +64,7 @@ set(GLideN64_SOURCES
Graphics/CombinerProgram.cpp
Graphics/OpenGLContext/GLFunctions.cpp
Graphics/OpenGLContext/opengl_Attributes.cpp
Graphics/OpenGLContext/opengl_BufferedDrawer.cpp
Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.cpp
Graphics/OpenGLContext/opengl_CachedFunctions.cpp
Graphics/OpenGLContext/opengl_ColorBufferReaderWithBufferStorage.cpp

View File

@ -95,6 +95,7 @@ PFNGLENABLEVERTEXATTRIBARRAYPROC g_glEnableVertexAttribArray;
PFNGLDISABLEVERTEXATTRIBARRAYPROC g_glDisableVertexAttribArray;
PFNGLVERTEXATTRIBPOINTERPROC g_glVertexAttribPointer;
PFNGLBINDATTRIBLOCATIONPROC g_glBindAttribLocation;
PFNGLVERTEXATTRIB1FPROC g_glVertexAttrib1f;
PFNGLVERTEXATTRIB4FPROC g_glVertexAttrib4f;
PFNGLVERTEXATTRIB4FVPROC g_glVertexAttrib4fv;
@ -116,6 +117,9 @@ PFNGLFRAMEBUFFERRENDERBUFFERPROC g_glFramebufferRenderbuffer;
PFNGLDELETERENDERBUFFERSPROC g_glDeleteRenderbuffers;
PFNGLCHECKFRAMEBUFFERSTATUSPROC g_glCheckFramebufferStatus;
PFNGLBLITFRAMEBUFFERPROC g_glBlitFramebuffer;
PFNGLGENVERTEXARRAYSPROC g_glGenVertexArrays;
PFNGLBINDVERTEXARRAYPROC g_glBindVertexArray;
PFNGLDELETEVERTEXARRAYSPROC g_glDeleteVertexArrays;
PFNGLGENBUFFERSPROC g_glGenBuffers;
PFNGLBINDBUFFERPROC g_glBindBuffer;
PFNGLBUFFERDATAPROC g_glBufferData;
@ -154,6 +158,7 @@ PFNGLCREATETEXTURESPROC g_glCreateTextures;
PFNGLCREATEBUFFERSPROC g_glCreateBuffers;
PFNGLCREATEFRAMEBUFFERSPROC g_glCreateFramebuffers;
PFNGLNAMEDFRAMEBUFFERTEXTUREPROC g_glNamedFramebufferTexture;
PFNGLDRAWELEMENTSBASEVERTEXPROC g_glDrawElementsBaseVertex;
void initGLFunctions()
{
@ -221,6 +226,7 @@ void initGLFunctions()
GL_GET_PROC_ADR(PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray);
GL_GET_PROC_ADR(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer);
GL_GET_PROC_ADR(PFNGLBINDATTRIBLOCATIONPROC, glBindAttribLocation);
GL_GET_PROC_ADR(PFNGLVERTEXATTRIB1FPROC, glVertexAttrib1f);
GL_GET_PROC_ADR(PFNGLVERTEXATTRIB4FPROC, glVertexAttrib4f);
GL_GET_PROC_ADR(PFNGLVERTEXATTRIB4FVPROC, glVertexAttrib4fv);
@ -241,6 +247,9 @@ void initGLFunctions()
GL_GET_PROC_ADR(PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers);
GL_GET_PROC_ADR(PFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus);
GL_GET_PROC_ADR(PFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer);
GL_GET_PROC_ADR(PFNGLGENVERTEXARRAYSPROC, glGenVertexArrays);
GL_GET_PROC_ADR(PFNGLBINDVERTEXARRAYPROC, glBindVertexArray);
GL_GET_PROC_ADR(PFNGLDELETEVERTEXARRAYSPROC, glDeleteVertexArrays);
GL_GET_PROC_ADR(PFNGLGENBUFFERSPROC, glGenBuffers);
GL_GET_PROC_ADR(PFNGLBINDBUFFERPROC, glBindBuffer);
GL_GET_PROC_ADR(PFNGLBUFFERDATAPROC, glBufferData);
@ -280,6 +289,7 @@ void initGLFunctions()
GL_GET_PROC_ADR(PFNGLCREATEBUFFERSPROC, glCreateBuffers);
GL_GET_PROC_ADR(PFNGLCREATEFRAMEBUFFERSPROC, glCreateFramebuffers);
GL_GET_PROC_ADR(PFNGLNAMEDFRAMEBUFFERTEXTUREPROC, glNamedFramebufferTexture);
GL_GET_PROC_ADR(PFNGLDRAWELEMENTSBASEVERTEXPROC, glDrawElementsBaseVertex);
#ifdef EGL
if (g_glBufferStorage == nullptr)
g_glBufferStorage = (PFNGLBUFFERSTORAGEPROC) eglGetProcAddress("glBufferStorageEXT");

View File

@ -117,6 +117,7 @@ extern PFNGLBLENDCOLORPROC g_glBlendColor;
#define glDisableVertexAttribArray g_glDisableVertexAttribArray
#define glVertexAttribPointer g_glVertexAttribPointer
#define glBindAttribLocation g_glBindAttribLocation
#define glVertexAttrib1f g_glVertexAttrib1f
#define glVertexAttrib4f g_glVertexAttrib4f
#define glVertexAttrib4fv g_glVertexAttrib4fv
@ -137,6 +138,9 @@ extern PFNGLBLENDCOLORPROC g_glBlendColor;
#define glFramebufferRenderbuffer g_glFramebufferRenderbuffer
#define glCheckFramebufferStatus g_glCheckFramebufferStatus
#define glBlitFramebuffer g_glBlitFramebuffer
#define glGenVertexArrays g_glGenVertexArrays
#define glBindVertexArray g_glBindVertexArray
#define glDeleteVertexArrays g_glDeleteVertexArrays;
#define glGenBuffers g_glGenBuffers
#define glBindBuffer g_glBindBuffer
#define glBufferData g_glBufferData
@ -175,6 +179,7 @@ extern PFNGLBLENDCOLORPROC g_glBlendColor;
#define glCreateBuffers g_glCreateBuffers
#define glCreateFramebuffers g_glCreateFramebuffers
#define glNamedFramebufferTexture g_glNamedFramebufferTexture
#define glDrawElementsBaseVertex g_glDrawElementsBaseVertex
extern PFNGLCREATESHADERPROC g_glCreateShader;
extern PFNGLCOMPILESHADERPROC g_glCompileShader;
@ -205,6 +210,7 @@ extern PFNGLENABLEVERTEXATTRIBARRAYPROC g_glEnableVertexAttribArray;
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC g_glDisableVertexAttribArray;
extern PFNGLVERTEXATTRIBPOINTERPROC g_glVertexAttribPointer;
extern PFNGLBINDATTRIBLOCATIONPROC g_glBindAttribLocation;
extern PFNGLVERTEXATTRIB1FPROC g_glVertexAttrib1f;
extern PFNGLVERTEXATTRIB4FPROC g_glVertexAttrib4f;
extern PFNGLVERTEXATTRIB4FVPROC g_glVertexAttrib4fv;
@ -225,6 +231,9 @@ extern PFNGLDELETERENDERBUFFERSPROC g_glDeleteRenderbuffers;
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC g_glFramebufferRenderbuffer;
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC g_glCheckFramebufferStatus;
extern PFNGLBLITFRAMEBUFFERPROC g_glBlitFramebuffer;
extern PFNGLGENVERTEXARRAYSPROC g_glGenVertexArrays;
extern PFNGLBINDVERTEXARRAYPROC g_glBindVertexArray;
extern PFNGLDELETEVERTEXARRAYSPROC g_glDeleteVertexArrays;
extern PFNGLGENBUFFERSPROC g_glGenBuffers;
extern PFNGLBINDBUFFERPROC g_glBindBuffer;
extern PFNGLBUFFERDATAPROC g_glBufferData;
@ -263,6 +272,7 @@ extern PFNGLCREATETEXTURESPROC g_glCreateTextures;
extern PFNGLCREATEBUFFERSPROC g_glCreateBuffers;
extern PFNGLCREATEFRAMEBUFFERSPROC g_glCreateFramebuffers;
extern PFNGLNAMEDFRAMEBUFFERTEXTUREPROC g_glNamedFramebufferTexture;
extern PFNGLDRAWELEMENTSBASEVERTEXPROC g_glDrawElementsBaseVertex;
void initGLFunctions();

View File

@ -0,0 +1,210 @@
#include <Config.h>
#include <CRC.h>
#include "GLFunctions.h"
#include "opengl_Attributes.h"
#include "opengl_BufferedDrawer.h"
using namespace graphics;
using namespace opengl;
const u32 BufferedDrawer::m_bufMaxSize = 4194304;
BufferedDrawer::BufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArray * _cachedAttribArray, CachedBindBuffer * _bindBuffer)
: m_glInfo(_glinfo)
, m_cachedAttribArray(_cachedAttribArray)
, m_bindBuffer(_bindBuffer)
{
/* Init buffers for rects */
glGenVertexArrays(1, &m_rectsBuffers.vao);
glBindVertexArray(m_rectsBuffers.vao);
_initBuffer(m_rectsBuffers.vbo, m_bufMaxSize);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, true);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, true);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, true);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::color, false);
glVertexAttribPointer(rectAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, x)));
glVertexAttribPointer(rectAttrib::texcoord0, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, s0)));
glVertexAttribPointer(rectAttrib::texcoord1, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), (const GLvoid *)(offsetof(RectVertex, s1)));
/* Init buffers for triangles */
glGenVertexArrays(1, &m_trisBuffers.vao);
glBindVertexArray(m_trisBuffers.vao);
_initBuffer(m_trisBuffers.vbo, m_bufMaxSize);
_initBuffer(m_trisBuffers.ebo, m_bufMaxSize);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::position, true);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::color, true);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, true);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, true);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::numlights, false);
glVertexAttribPointer(triangleAttrib::position, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, x)));
glVertexAttribPointer(triangleAttrib::color, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, r)));
glVertexAttribPointer(triangleAttrib::texcoord, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, s)));
//glVertexAttribPointer(SC_NUMLIGHTS, 1, GL_BYTE, GL_FALSE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, HWLight)));
glVertexAttribPointer(triangleAttrib::modify, 4, GL_BYTE, GL_TRUE, sizeof(Vertex), (const GLvoid *)(offsetof(Vertex, modify)));
}
void BufferedDrawer::_initBuffer(Buffer & _buffer, GLuint _bufSize)
{
_buffer.size = _bufSize;
glGenBuffers(1, &_buffer.handle);
m_bindBuffer->bind(Parameter(_buffer.type), ObjectHandle(_buffer.handle));
if (m_glInfo.bufferStorage) {
glBufferStorage(_buffer.type, _bufSize, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
_buffer.data = (GLubyte*)glMapBufferRange(_buffer.type, 0, _bufSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
} else {
glBufferData(_buffer.type, _bufSize, nullptr, GL_DYNAMIC_DRAW);
}
}
BufferedDrawer::~BufferedDrawer()
{
m_bindBuffer->bind(Parameter(GL_ARRAY_BUFFER), ObjectHandle());
m_bindBuffer->bind(Parameter(GL_ELEMENT_ARRAY_BUFFER), ObjectHandle());
GLuint buffers[3] = { m_rectsBuffers.vbo.handle, m_trisBuffers.vbo.handle, m_trisBuffers.ebo.handle };
glDeleteBuffers(3, buffers);
glBindVertexArray(0);
GLuint arrays[2] = { m_rectsBuffers.vao, m_trisBuffers.vao };
glDeleteVertexArrays(2, arrays);
}
void BufferedDrawer::_updateBuffer(Buffer & _buffer, u32 _dataSize, const void * _data)
{
if (_buffer.offset + _dataSize > _buffer.size) {
_buffer.offset = 0;
_buffer.pos = 0;
}
if (m_glInfo.bufferStorage) {
memcpy(&_buffer.data[_buffer.offset], _data, _dataSize);
}
else {
m_bindBuffer->bind(Parameter(GL_ARRAY_BUFFER), ObjectHandle(_buffer.handle));
void* buffer_pointer = glMapBufferRange(GL_ARRAY_BUFFER, _buffer.offset, _dataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
memcpy(buffer_pointer, _data, _dataSize);
glUnmapBuffer(GL_ARRAY_BUFFER);
}
}
void BufferedDrawer::_updateRectBuffer(const graphics::Context::DrawRectParameters & _params)
{
const BuffersType type = BuffersType::rects;
if (m_type != type) {
glBindVertexArray(m_rectsBuffers.vao);
m_type = type;
}
Buffer & buffer = m_rectsBuffers.vbo;
const size_t dataSize = _params.verticesCount * sizeof(RectVertex);
const u32 crc = CRC_Calculate(0xFFFFFFFF, _params.vertices, dataSize);
auto iter = m_rectBufferOffsets.find(crc);
if (iter != m_rectBufferOffsets.end()) {
buffer.pos = iter->second;
return;
}
_updateBuffer(buffer, dataSize, _params.vertices);
if (buffer.pos == 0)
m_rectBufferOffsets.clear();
buffer.offset += dataSize;
buffer.pos = buffer.offset / sizeof(RectVertex);
m_rectBufferOffsets[crc] = buffer.pos;
}
void BufferedDrawer::drawRects(const graphics::Context::DrawRectParameters & _params)
{
_updateRectBuffer(_params);
glVertexAttrib4fv(rectAttrib::color, _params.rectColor.data());
glDrawArrays(GLenum(_params.mode), m_rectsBuffers.vbo.pos - _params.verticesCount, _params.verticesCount);
}
void BufferedDrawer::_convertFromSPVertex(bool _flatColors, u32 _count, const SPVertex * _data)
{
for (u32 i = 0; i < _count; ++i) {
const SPVertex & src = _data[i];
Vertex & dst = m_vertices[i];
dst.x = src.x;
dst.y = src.y;
dst.z = src.z;
dst.w = src.w;
if (_flatColors) {
dst.r = src.flat_r;
dst.g = src.flat_g;
dst.b = src.flat_b;
dst.a = src.flat_a;
} else {
dst.r = src.r;
dst.g = src.g;
dst.b = src.b;
dst.a = src.a;
}
dst.s = src.s;
dst.t = src.t;
dst.modify = src.modify;
}
}
void BufferedDrawer::_updateTrianglesBuffers(const graphics::Context::DrawTriangleParameters & _params)
{
const BuffersType type = BuffersType::triangles;
if (m_type != type) {
glBindVertexArray(m_trisBuffers.vao);
m_type = type;
}
_convertFromSPVertex(_params.flatColors, _params.verticesCount, _params.vertices);
const GLsizeiptr vboDataSize = _params.verticesCount * sizeof(Vertex);
Buffer & vboBuffer = m_trisBuffers.vbo;
_updateBuffer(vboBuffer, vboDataSize, m_vertices);
vboBuffer.offset += vboDataSize;
vboBuffer.pos += _params.verticesCount;
if (_params.elements == nullptr)
return;
const GLsizeiptr eboDataSize = sizeof(GLubyte) * _params.elementsCount;
Buffer & eboBuffer = m_trisBuffers.ebo;
_updateBuffer(eboBuffer, eboDataSize, _params.elements);
eboBuffer.offset += eboDataSize;
eboBuffer.pos += _params.elementsCount;
}
void BufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParameters & _params)
{
_updateTrianglesBuffers(_params);
if (config.generalEmulation.enableHWLighting != 0)
glVertexAttrib1f(triangleAttrib::numlights, GLfloat(_params.vertices[0].HWLight));
if (_params.elements == nullptr) {
glDrawArrays(GLenum(_params.mode), m_trisBuffers.vbo.pos - _params.verticesCount, _params.verticesCount);
return;
}
glDrawElementsBaseVertex(GLenum(_params.mode), _params.elementsCount, GL_UNSIGNED_BYTE,
(char*)nullptr + m_trisBuffers.ebo.pos - _params.elementsCount, m_trisBuffers.vbo.pos - _params.verticesCount);
}
void BufferedDrawer::drawLine(f32 _width, SPVertex * _vertices)
{
const BuffersType type = BuffersType::triangles;
if (m_type != type) {
glBindVertexArray(m_trisBuffers.vao);
m_type = type;
}
_convertFromSPVertex(false, 2, _vertices);
const GLsizeiptr vboDataSize = 2 * sizeof(Vertex);
Buffer & vboBuffer = m_trisBuffers.vbo;
_updateBuffer(vboBuffer, vboDataSize, m_vertices);
vboBuffer.offset += vboDataSize;
vboBuffer.pos += 2;
glDrawArrays(GL_LINES, m_trisBuffers.vbo.pos - 2, 2);
}

View File

@ -0,0 +1,102 @@
#pragma once
#include <unordered_map>
#include "opengl_GLInfo.h"
#include "opengl_GraphicsDrawer.h"
#include "opengl_CachedFunctions.h"
namespace opengl {
class BufferedDrawer : public GraphicsDrawer
{
public:
BufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArray * _cachedAttribArray,
CachedBindBuffer * _bindBuffer);
~BufferedDrawer();
void drawTriangles(const graphics::Context::DrawTriangleParameters & _params) override;
void drawRects(const graphics::Context::DrawRectParameters & _params) override;
void drawLine(f32 _width, SPVertex * _vertices) override;
private:
void _updateRectBuffer(const graphics::Context::DrawRectParameters & _params);
void _updateTrianglesBuffers(const graphics::Context::DrawTriangleParameters & _params);
enum class BuffersType {
none,
rects,
triangles
};
struct Buffer {
Buffer(GLenum _type) : type(_type) {}
GLenum type;
GLuint handle = 0;
GLintptr offset = 0;
GLint pos = 0;
GLuint size = 0;
GLubyte * data = nullptr;
};
struct RectBuffers {
GLuint vao = 0;
Buffer vbo = Buffer(GL_ARRAY_BUFFER);
};
struct TrisBuffers {
GLuint vao = 0;
Buffer vbo = Buffer(GL_ARRAY_BUFFER);
Buffer ebo = Buffer(GL_ELEMENT_ARRAY_BUFFER);
};
struct Vertex
{
f32 x, y, z, w;
f32 r, g, b, a;
f32 s, t;
u32 modify;
};
void _initBuffer(Buffer & _buffer, GLuint _bufSize);
void _updateBuffer(Buffer & _buffer, u32 _dataSize, const void * _data);
void _convertFromSPVertex(bool _flatColors, u32 _count, const SPVertex * _data);
const GLInfo & m_glInfo;
CachedVertexAttribArray * m_cachedAttribArray;
CachedBindBuffer * m_bindBuffer;
RectBuffers m_rectsBuffers;
TrisBuffers m_trisBuffers;
BuffersType m_type = BuffersType::none;
Vertex m_vertices[VERTBUFF_SIZE];
typedef std::unordered_map<u32, u32> BufferOffsets;
BufferOffsets m_rectBufferOffsets;
/*
GLuint m_vao;
enum {
TRI_VBO = 0,
RECT_VBO,
IBO,
BO_COUNT
};
GLuint m_bufObj[BO_COUNT];
GLenum m_bufType[BO_COUNT];
char* m_bufData[BO_COUNT];
u32 m_bufOffset[BO_COUNT];
u32 m_bufFormatSize[BO_COUNT];
u32 m_bufMaxSize;
GLbitfield m_bufAccess;
GLbitfield m_bufMapAccess;
*/
static const u32 m_bufMaxSize;
};
}

View File

@ -2,6 +2,7 @@
#include <Log.h>
#include <Graphics/Parameters.h>
#include "opengl_ContextImpl.h"
#include "opengl_BufferedDrawer.h"
#include "opengl_UnbufferedDrawer.h"
#include "opengl_DummyTextDrawer.h"
#include "opengl_ColorBufferReaderWithPixelBuffer.h"
@ -58,7 +59,10 @@ void ContextImpl::init()
}
{
m_graphicsDrawer.reset(new UnbufferedDrawer(m_glInfo, m_cachedFunctions->getCachedVertexAttribArray()));
if ((m_glInfo.isGLESX && (m_glInfo.bufferStorage && m_glInfo.majorVersion * 10 + m_glInfo.minorVersion > 32)) || !m_glInfo.isGLESX)
m_graphicsDrawer.reset(new BufferedDrawer(m_glInfo, m_cachedFunctions->getCachedVertexAttribArray(), m_cachedFunctions->getCachedBindBuffer()));
else
m_graphicsDrawer.reset(new UnbufferedDrawer(m_glInfo, m_cachedFunctions->getCachedVertexAttribArray()));
m_textDrawer.reset(new DummyTextDrawer);
}
@ -72,7 +76,6 @@ void ContextImpl::init()
void ContextImpl::destroy()
{
m_cachedFunctions.reset();
m_createTexture.reset();
m_init2DTexture.reset();
m_set2DTextureParameters.reset();
@ -81,9 +84,10 @@ void ContextImpl::destroy()
m_createRenderbuffer.reset();
m_initRenderbuffer.reset();
m_addFramebufferRenderTarget.reset();
m_graphicsDrawer.reset();
m_combinerProgramBuilder.reset();
m_cachedFunctions.reset();
}
void ContextImpl::enable(graphics::EnableParam _parameter, bool _enable)

View File

@ -84,6 +84,7 @@ MY_LOCAL_SRC_FILES := \
$(SRCDIR)/Graphics/CombinerProgram.cpp \
$(SRCDIR)/Graphics/OpenGLContext/GLFunctions.cpp \
$(SRCDIR)/Graphics/OpenGLContext/opengl_Attributes.cpp \
$(SRCDIR)/Graphics/OpenGLContext/opengl_BufferedDrawer.cpp \
$(SRCDIR)/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.cpp \
$(SRCDIR)/Graphics/OpenGLContext/opengl_CachedFunctions.cpp \
$(SRCDIR)/Graphics/OpenGLContext/opengl_ColorBufferReaderWithBufferStorage.cpp \