OpenGL2: Fix issues running under WebGL

This commit is contained in:
Zack Middleton 2024-06-06 16:12:08 -05:00
parent 980147721a
commit 551fa6c797
5 changed files with 24 additions and 10 deletions

View File

@ -80,7 +80,6 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
GLE(void, TexParameterf, GLenum target, GLenum pname, GLfloat param) \
GLE(void, TexParameteri, GLenum target, GLenum pname, GLint param) \
GLE(void, TexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) \
GLE(void, Translatef, GLfloat x, GLfloat y, GLfloat z) \
GLE(void, Viewport, GLint x, GLint y, GLsizei width, GLsizei height) \
// OpenGL 1.0/1.1 and OpenGL ES 1.x but not OpenGL 3.2 core profile
@ -98,6 +97,7 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
GLE(void, ShadeModel, GLenum mode) \
GLE(void, TexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
GLE(void, TexEnvf, GLenum target, GLenum pname, GLfloat param) \
GLE(void, Translatef, GLfloat x, GLfloat y, GLfloat z) \
GLE(void, VertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
// OpenGL 1.0/1.1 and 3.2 core profile but not OpenGL ES 1.x

View File

@ -52,10 +52,9 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa
#endif
float zLimit = 5.0 / zFar;
int i, j;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
for (j = 1; j < BLUR_SIZE; j++)
for (int j = 1; j < BLUR_SIZE; j++)
{
vec2 offset = direction * (float(j) - 0.25) + nudge;
#if defined(USE_DEPTH)

View File

@ -77,8 +77,7 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN
float invZFar = 1.0 / zFar;
float zLimit = 20.0 * invZFar;
int i;
for (i = 0; i < NUM_SAMPLES; i++)
for (int i = 0; i < NUM_SAMPLES; i++)
{
vec2 offset = rmat * poissonDisc[i] * offsetScale;
float sampleDiff = getLinearDepth(depthMap, tex + offset, zFarDivZNear) - sampleZ;

View File

@ -73,12 +73,23 @@ void GLimp_InitExtraExtensions(void)
goto done;
extension = "GL_EXT_occlusion_query_boolean";
if (SDL_GL_ExtensionSupported(extension))
if (qglesMajorVersion >= 3 || SDL_GL_ExtensionSupported(extension))
{
glRefConfig.occlusionQuery = qtrue;
glRefConfig.occlusionQueryTarget = GL_ANY_SAMPLES_PASSED;
QGL_ARB_occlusion_query_PROCS;
if (qglesMajorVersion >= 3) {
QGL_ARB_occlusion_query_PROCS;
} else {
// GL_EXT_occlusion_query_boolean uses EXT suffix
#undef GLE
#define GLE(ret, name, ...) qgl##name = (name##proc *) SDL_GL_GetProcAddress("gl" #name "EXT");
QGL_ARB_occlusion_query_PROCS;
#undef GLE
#define GLE(ret, name, ...) qgl##name = (name##proc *) SDL_GL_GetProcAddress("gl" #name);
}
ri.Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension);
}
@ -137,7 +148,7 @@ void GLimp_InitExtraExtensions(void)
// GL_OES_element_index_uint
extension = "GL_OES_element_index_uint";
if (SDL_GL_ExtensionSupported(extension))
if (qglesMajorVersion >= 3 || SDL_GL_ExtensionSupported(extension))
{
glRefConfig.vaoCacheGlIndexType = GL_UNSIGNED_INT;
glRefConfig.vaoCacheGlIndexSize = sizeof(unsigned int);

View File

@ -283,7 +283,12 @@ static void InitOpenGL( void )
glRefConfig.maxVertexAttribs = temp;
// reserve 160 components for other uniforms
qglGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS, &temp );
if ( qglesMajorVersion ) {
qglGetIntegerv( GL_MAX_VERTEX_UNIFORM_VECTORS, &temp );
temp *= 4;
} else {
qglGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS, &temp );
}
glRefConfig.glslMaxAnimatedBones = Com_Clamp( 0, IQM_MAX_JOINTS, ( temp - 160 ) / 16 );
if ( glRefConfig.glslMaxAnimatedBones < 12 ) {
glRefConfig.glslMaxAnimatedBones = 0;