Fixed map buffer for GLES2 mode

This commit is contained in:
Emile Belanger 2021-03-18 22:18:11 +00:00
parent 70d7ff77aa
commit 1ff5040692
7 changed files with 81 additions and 30 deletions

View file

@ -1,12 +1,16 @@
/*
OpenGL ES loader generated by glad 0.1.34 on Sat Feb 20 22:25:17 2021.
OpenGL ES loader generated by glad 0.1.34 on Thu Mar 18 23:06:03 2021.
Language/Generator: C/C++
Specification: gl
APIs: gles2=2.0
Profile: compatibility
Extensions:
GL_OES_depth24,
GL_OES_depth32,
GL_OES_depth_texture,
GL_OES_mapbuffer,
GL_OES_packed_depth_stencil
Loader: True
Local files: False
@ -14,9 +18,9 @@
Reproducible: False
Commandline:
--profile="compatibility" --api="gles2=2.0" --generator="c" --spec="gl" --extensions="GL_OES_packed_depth_stencil"
--profile="compatibility" --api="gles2=2.0" --generator="c" --spec="gl" --extensions="GL_OES_depth24,GL_OES_depth32,GL_OES_depth_texture,GL_OES_mapbuffer,GL_OES_packed_depth_stencil"
Online:
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gles2%3D2.0&extensions=GL_OES_packed_depth_stencil
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gles2%3D2.0&extensions=GL_OES_depth24&extensions=GL_OES_depth32&extensions=GL_OES_depth_texture&extensions=GL_OES_mapbuffer&extensions=GL_OES_packed_depth_stencil
*/
@ -493,11 +497,6 @@ GLAPI PFNGLCLEARCOLORPROC glad_glClearColor;
typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d);
GLAPI PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
#define glClearDepthf glad_glClearDepthf
typedef void (APIENTRYP PFNGLCLEARDEPTHPROC)(double d);
GLAPI PFNGLCLEARDEPTHPROC glad_glClearDepth;
#define glClearDepth glad_glClearDepth
typedef void (APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s);
GLAPI PFNGLCLEARSTENCILPROC glad_glClearStencil;
#define glClearStencil glad_glClearStencil
@ -871,9 +870,40 @@ typedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsi
GLAPI PFNGLVIEWPORTPROC glad_glViewport;
#define glViewport glad_glViewport
#endif
#define GL_DEPTH_COMPONENT24_OES 0x81A6
#define GL_DEPTH_COMPONENT32_OES 0x81A7
#define GL_WRITE_ONLY_OES 0x88B9
#define GL_BUFFER_ACCESS_OES 0x88BB
#define GL_BUFFER_MAPPED_OES 0x88BC
#define GL_BUFFER_MAP_POINTER_OES 0x88BD
#define GL_DEPTH_STENCIL_OES 0x84F9
#define GL_UNSIGNED_INT_24_8_OES 0x84FA
#define GL_DEPTH24_STENCIL8_OES 0x88F0
#ifndef GL_OES_depth24
#define GL_OES_depth24 1
GLAPI int GLAD_GL_OES_depth24;
#endif
#ifndef GL_OES_depth32
#define GL_OES_depth32 1
GLAPI int GLAD_GL_OES_depth32;
#endif
#ifndef GL_OES_depth_texture
#define GL_OES_depth_texture 1
GLAPI int GLAD_GL_OES_depth_texture;
#endif
#ifndef GL_OES_mapbuffer
#define GL_OES_mapbuffer 1
GLAPI int GLAD_GL_OES_mapbuffer;
typedef void * (APIENTRYP PFNGLMAPBUFFEROESPROC)(GLenum target, GLenum access);
GLAPI PFNGLMAPBUFFEROESPROC glad_glMapBufferOES;
#define glMapBufferOES glad_glMapBufferOES
typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFEROESPROC)(GLenum target);
GLAPI PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES;
#define glUnmapBufferOES glad_glUnmapBufferOES
typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC)(GLenum target, GLenum pname, void **params);
GLAPI PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES;
#define glGetBufferPointervOES glad_glGetBufferPointervOES
#endif
#ifndef GL_OES_packed_depth_stencil
#define GL_OES_packed_depth_stencil 1
GLAPI int GLAD_GL_OES_packed_depth_stencil;

View file

@ -1,12 +1,16 @@
/*
OpenGL ES loader generated by glad 0.1.34 on Sat Feb 20 22:25:17 2021.
OpenGL ES loader generated by glad 0.1.34 on Thu Mar 18 23:06:03 2021.
Language/Generator: C/C++
Specification: gl
APIs: gles2=2.0
Profile: compatibility
Extensions:
GL_OES_depth24,
GL_OES_depth32,
GL_OES_depth_texture,
GL_OES_mapbuffer,
GL_OES_packed_depth_stencil
Loader: True
Local files: False
@ -14,9 +18,9 @@
Reproducible: False
Commandline:
--profile="compatibility" --api="gles2=2.0" --generator="c" --spec="gl" --extensions="GL_OES_packed_depth_stencil"
--profile="compatibility" --api="gles2=2.0" --generator="c" --spec="gl" --extensions="GL_OES_depth24,GL_OES_depth32,GL_OES_depth_texture,GL_OES_mapbuffer,GL_OES_packed_depth_stencil"
Online:
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gles2%3D2.0&extensions=GL_OES_packed_depth_stencil
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gles2%3D2.0&extensions=GL_OES_depth24&extensions=GL_OES_depth32&extensions=GL_OES_depth_texture&extensions=GL_OES_mapbuffer&extensions=GL_OES_packed_depth_stencil
*/
#include <stdio.h>
@ -142,7 +146,6 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
PFNGLCLEARPROC glad_glClear = NULL;
PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL;
PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL;
PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
PFNGLCOLORMASKPROC glad_glColorMask = NULL;
PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
@ -267,7 +270,14 @@ PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
PFNGLVIEWPORTPROC glad_glViewport = NULL;
int GLAD_GL_OES_depth24 = 0;
int GLAD_GL_OES_depth32 = 0;
int GLAD_GL_OES_depth_texture = 0;
int GLAD_GL_OES_mapbuffer = 0;
int GLAD_GL_OES_packed_depth_stencil = 0;
PFNGLMAPBUFFEROESPROC glad_glMapBufferOES = NULL;
PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES = NULL;
PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES = NULL;
static void load_GL_ES_VERSION_2_0(GLADloadproc load) {
if(!GLAD_GL_ES_VERSION_2_0) return;
glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture");
@ -288,7 +298,6 @@ static void load_GL_ES_VERSION_2_0(GLADloadproc load) {
glad_glClear = (PFNGLCLEARPROC)load("glClear");
glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor");
glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC)load("glClearDepthf");
glad_glClearDepth = (PFNGLCLEARDEPTHFPROC)load("glClearDepth"); // When testing with OpenGL real
glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil");
glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask");
glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader");
@ -414,8 +423,18 @@ static void load_GL_ES_VERSION_2_0(GLADloadproc load) {
glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer");
glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport");
}
static void load_GL_OES_mapbuffer(GLADloadproc load) {
if(!GLAD_GL_OES_mapbuffer) return;
glad_glMapBufferOES = (PFNGLMAPBUFFEROESPROC)load("glMapBufferOES");
glad_glUnmapBufferOES = (PFNGLUNMAPBUFFEROESPROC)load("glUnmapBufferOES");
glad_glGetBufferPointervOES = (PFNGLGETBUFFERPOINTERVOESPROC)load("glGetBufferPointervOES");
}
static int find_extensionsGLES2(void) {
if (!get_exts()) return 0;
GLAD_GL_OES_depth24 = has_ext("GL_OES_depth24");
GLAD_GL_OES_depth32 = has_ext("GL_OES_depth32");
GLAD_GL_OES_depth_texture = has_ext("GL_OES_depth_texture");
GLAD_GL_OES_mapbuffer = has_ext("GL_OES_mapbuffer");
GLAD_GL_OES_packed_depth_stencil = has_ext("GL_OES_packed_depth_stencil");
free_exts();
return 1;
@ -473,6 +492,7 @@ int gladLoadGLES2Loader(GLADloadproc load) {
load_GL_ES_VERSION_2_0(load);
if (!find_extensionsGLES2()) return 0;
load_GL_OES_mapbuffer(load);
return GLVersion.major != 0 || GLVersion.minor != 0;
}

View file

@ -74,7 +74,7 @@ GLBuffer::~GLBuffer()
if (gles.useMappedBuffers)
{
glBindBuffer(mUseType, mBufferId);
glUnmapBuffer(mUseType);
glUnmapBufferOES(mUseType);
}
glBindBuffer(mUseType, 0);
glDeleteBuffers(1, &mBufferId);
@ -151,7 +151,7 @@ void GLBuffer::Map()
if (!isData && gles.useMappedBuffers)
{
Bind();
map = (FFlatVertex*)glMapBuffer(mUseType, GL_WRITE_ONLY);
map = (FFlatVertex*)glMapBufferOES(mUseType, GL_WRITE_ONLY_OES);
}
else
{
@ -165,7 +165,7 @@ void GLBuffer::Unmap()
if (!isData && gles.useMappedBuffers)
{
Bind();
glUnmapBuffer(mUseType);
glUnmapBufferOES(mUseType);
InvalidateBufferState();
}
}
@ -176,7 +176,7 @@ void *GLBuffer::Lock(unsigned int size)
SetData(size, nullptr, true);
if (!isData && gles.useMappedBuffers)
{
return glMapBuffer(mUseType, GL_WRITE_ONLY);
return glMapBufferOES(mUseType, GL_WRITE_ONLY_OES);
}
else
{
@ -191,7 +191,7 @@ void GLBuffer::Unlock()
if (gles.useMappedBuffers)
{
Bind();
glUnmapBuffer(mUseType);
glUnmapBufferOES(mUseType);
InvalidateBufferState();
}
else

View file

@ -157,10 +157,9 @@ void OpenGLFrameBuffer::InitializeState()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
if(glClearDepthf)
glClearDepthf(1.0f);
else
glClearDepth(1.0f);
glClearDepthf(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetViewportRects(nullptr);

View file

@ -56,7 +56,11 @@ void FGLRenderer::PostProcessScene(int fixedcm, float flash, const std::function
#ifndef NO_RENDER_BUFFER
mBuffers->BindCurrentFB();
#endif
gl_RenderState.SetSpecialColormap(fixedcm);
if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D();
gl_RenderState.SetSpecialColormap(0);
}

View file

@ -341,10 +341,7 @@ namespace OpenGLESRenderer
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthValue);
glDisable(GL_SCISSOR_TEST);
glClearColor(0.0, 0.0, 0.0, 0.0);
if (glClearDepthf)
glClearDepthf(0.0f);
else
glClearDepth(0.0f);
glClearDepthf(0.0f);
glClearStencil(0);
GLenum flags = GL_COLOR_BUFFER_BIT;
if (stencil)
@ -353,10 +350,7 @@ namespace OpenGLESRenderer
flags |= GL_DEPTH_BUFFER_BIT;
glClear(flags);
glClearStencil(stencilValue);
if (glClearDepthf)
glClearDepthf(depthValue);
else
glClearDepth(depthValue);
glClearDepthf(depthValue);
if (scissorEnabled)
glEnable(GL_SCISSOR_TEST);
}

View file

@ -30,6 +30,10 @@
#else
#include "gl_load/gl_load.h"
#define GL_DEPTH24_STENCIL8_OES GL_DEPTH24_STENCIL8
//#define glClearDepthf glClearDepth
#define GL_WRITE_ONLY_OES GL_WRITE_ONLY
#define glUnmapBufferOES glUnmapBuffer
#define glMapBufferOES glMapBuffer
#endif
#if defined(__APPLE__)