From 7f29608ddd4cd17ff3924c9bde1e76eb8dd39462 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 9 Dec 2021 12:54:05 -0500 Subject: [PATCH] =?UTF-8?q?From=20e62f9af658fea7ce475cb23d1c5d06f9c15e45f2?= =?UTF-8?q?=20Mon=20Sep=2017=2000:00:00=202001=20From:=20Andrey=20Nazarov?= =?UTF-8?q?=20=20Date:=20Sun,=2010=20Jun=202018=2020:?= =?UTF-8?q?10:08=20+0300=20Subject:=20[PATCH=20155/396]=20=3D=3FUTF-8=3Fq?= =?UTF-8?q?=3FAdd=3D20=3DE2=3D80=3D98gl=3D5Fpartshape=3DE2=3D80=3D99=3F=3D?= =?UTF-8?q?=20=20=3D=3FUTF-8=3Fq=3F=3D20variable.=3F=3D=20MIME-Version:=20?= =?UTF-8?q?1.0=20Content-Type:=20text/plain;=20charset=3DUTF-8=20Content-T?= =?UTF-8?q?ransfer-Encoding:=208bit?= Based on changes suggested by Slipyx (see #143). --- src/refresh/gl/gl.h | 2 +- src/refresh/gl/qgl.h | 4 +++ src/refresh/gl/surf.c | 6 +++++ src/refresh/gl/texture.c | 56 +++++++++++++++++++++++++++++----------- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/refresh/gl/gl.h b/src/refresh/gl/gl.h index fbd9b7412..152d810e1 100644 --- a/src/refresh/gl/gl.h +++ b/src/refresh/gl/gl.h @@ -37,7 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc., * */ -#ifdef GL_VERSION_ES_CM_1_0 +#if USE_GLES #define QGL_INDEX_TYPE GLushort #define QGL_INDEX_ENUM GL_UNSIGNED_SHORT #else diff --git a/src/refresh/gl/qgl.h b/src/refresh/gl/qgl.h index 58a41b441..b975a02fa 100644 --- a/src/refresh/gl/qgl.h +++ b/src/refresh/gl/qgl.h @@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #if USE_SDL #include #else +#ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN 1 + #include +#endif #include #include #endif diff --git a/src/refresh/gl/surf.c b/src/refresh/gl/surf.c index 034b0a7a0..a5b02c515 100644 --- a/src/refresh/gl/surf.c +++ b/src/refresh/gl/surf.c @@ -732,6 +732,12 @@ static qboolean create_surface_vbo(size_t size) if (!qglGenBuffers) { return qfalse; } + +#if USE_GLES + if (size > 65536 * VERTEX_SIZE * sizeof(vec_t)) { + return qfalse; + } +#endif QGL_ClearErrors(); diff --git a/src/refresh/gl/texture.c b/src/refresh/gl/texture.c index d2b12a508..7cc3090d3 100644 --- a/src/refresh/gl/texture.c +++ b/src/refresh/gl/texture.c @@ -46,6 +46,7 @@ static cvar_t *gl_anisotropy; static cvar_t *gl_saturation; static cvar_t *gl_gamma; static cvar_t *gl_invert; +static cvar_t *gl_partshape; cvar_t *gl_intensity; @@ -801,25 +802,42 @@ static void GL_InitParticleTexture(void) byte *dst; float x, y, f; int i, j; - - dst = pixels; - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j++) { - x = j - 16 / 2 + 0.5f; - y = i - 16 / 2 + 0.5f; - f = sqrt(x * x + y * y); - f = 1.0f - f / (16 / 2 - 0.5f); - dst[0] = 255; - dst[1] = 255; - dst[2] = 255; - dst[3] = 255 * clamp(f, 0, 1); - dst += 4; + int shape = Cvar_ClampInteger(gl_partshape, 0, 2); + int flags = IF_TRANSPARENT; + + if (shape == 0 || shape == 2) { + dst = pixels; + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + x = j - 16 / 2 + 0.5f; + y = i - 16 / 2 + 0.5f; + f = sqrt(x * x + y * y); + f = 1.0f - f / ((16 - shape) / 2 - 0.5f); + f *= 1 << shape; + dst[0] = 255; + dst[1] = 255; + dst[2] = 255; + dst[3] = 255 * clamp(f, 0, 1 - shape * 0.2f); + dst += 4; + } + } + } else { + flags |= IF_NEAREST; + memset(pixels, 0, sizeof(pixels)); + for (i = 3; i <= 12; i++) { + for (j = 3; j <= 12; j++) { + dst = pixels + (i * 16 + j) * 4; + dst[0] = 255; + dst[1] = 255; + dst[2] = 255; + dst[3] = 255 * 0.6f; + } } } GL_ForceTexture(0, TEXNUM_PARTICLE); - GL_Upload32(pixels, 16, 16, 0, IT_SPRITE, IF_NONE); - GL_SetFilterAndRepeat(IT_SPRITE, IF_NONE); + GL_Upload32(pixels, 16, 16, 0, IT_SPRITE, flags); + GL_SetFilterAndRepeat(IT_SPRITE, flags); } static void GL_InitWhiteImage(void) @@ -862,6 +880,11 @@ static void GL_InitBeamTexture(void) GL_SetFilterAndRepeat(IT_SPRITE, IF_NONE); } +static void gl_partshape_changed(cvar_t *self) +{ + GL_InitParticleTexture(); +} + /* =============== GL_InitImages @@ -892,6 +915,8 @@ void GL_InitImages(void) gl_intensity = Cvar_Get("intensity", "2", 0); gl_invert = Cvar_Get("gl_invert", "0", CVAR_FILES); gl_gamma = Cvar_Get("vid_gamma", "0.8", CVAR_ARCHIVE); + gl_partshape = Cvar_Get("gl_partshape", "0", 0); + gl_partshape->changed = gl_partshape_changed; if (r_config.flags & QVF_GAMMARAMP) { gl_gamma->changed = gl_gamma_changed; @@ -968,6 +993,7 @@ void GL_ShutdownImages(void) gl_texturemode->generator = NULL; gl_anisotropy->changed = NULL; gl_gamma->changed = NULL; + gl_partshape->changed = NULL; // delete auto textures qglDeleteTextures(NUM_TEXNUMS, gl_static.texnums);