From a19530559244936e827d60bb0ef369a5a69ce5cd Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 25 Apr 2022 23:23:55 +0200 Subject: [PATCH] GL3: Fix particles on RPi4 tested V3D 4.2; OpenGL ES 3.1 Mesa 20.3.5 --- src/client/refresh/gl3/gl3_main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c index 330f78df..2fd028dc 100644 --- a/src/client/refresh/gl3/gl3_main.c +++ b/src/client/refresh/gl3/gl3_main.c @@ -965,7 +965,11 @@ GL3_DrawParticles(void) glDepthMask(GL_FALSE); glEnable(GL_BLEND); -#ifndef YQ2_GL3_GLES +#ifdef YQ2_GL3_GLES + // the RPi4 GLES3 implementation doesn't draw particles if culling is + // enabled (at least with GL_FRONT which seems to be default in q2?) + glDisable(GL_CULL_FACE); +#else // GLES doesn't have this, maybe it's always enabled? (https://gamedev.stackexchange.com/a/15528 says it works) // luckily we don't use glPointSize() but set gl_PointSize in shader anyway glEnable(GL_PROGRAM_POINT_SIZE); @@ -984,7 +988,7 @@ GL3_DrawParticles(void) cur->size = pointSize; cur->dist = VectorLength(offset); - for(int j=0; j<3; ++j) cur->color[j] = color[j]/255.0f; + for(int j=0; j<3; ++j) cur->color[j] = color[j]*(1.0f/255.0f); cur->color[3] = p->alpha; } @@ -994,10 +998,12 @@ GL3_DrawParticles(void) glBufferData(GL_ARRAY_BUFFER, sizeof(part_vtx)*numParticles, buf, GL_STREAM_DRAW); glDrawArrays(GL_POINTS, 0, numParticles); - glDisable(GL_BLEND); glDepthMask(GL_TRUE); -#ifndef YQ2_GL3_GLES +#ifdef YQ2_GL3_GLES + if(gl_cull->value != 0.0f) + glEnable(GL_CULL_FACE); +#else glDisable(GL_PROGRAM_POINT_SIZE); #endif