Skip to content

Commit

Permalink
From e62f9af658fea7ce475cb23d1c5d06f9c15e45f2 Mon Sep 17 00:00:00 2001
Browse files Browse the repository at this point in the history
From: Andrey Nazarov <[email protected]>
Date: Sun, 10 Jun 2018 20:10:08 +0300
Subject: [PATCH 155/396] =?UTF-8?q?Add=20=E2=80=98gl=5Fpartshape=E2=80=99?=
 =?UTF-8?q?=20variable.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Based on changes suggested by Slipyx (see NVIDIA#143).
  • Loading branch information
Paril committed Dec 10, 2021
1 parent d83f6b2 commit 7f29608
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/refresh/gl/gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/refresh/gl/qgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#if USE_SDL
#include <SDL_opengl.h>
#else
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/glext.h>
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/refresh/gl/surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
56 changes: 41 additions & 15 deletions src/refresh/gl/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7f29608

Please sign in to comment.