From 76fc3c1da7dd8c08f133e4e6e270b94cda1b518f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Dec 2024 15:17:59 +0100 Subject: [PATCH] smoll optimization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dont recalc this everytime just do tha lööp thinge seems to work fine --- src/hardware/r_opengl/r_opengl.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index bd9668397..941c74db1 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1598,6 +1598,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) INT32 w = pTexInfo->width, h = pTexInfo->height; INT32 i, j; + INT32 idx; const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; const GLvoid *ptex = NULL; @@ -1626,12 +1627,10 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) const int chromakeyed = (pTexInfo->flags & TF_CHROMAKEYED); - for (j = 0; j < h; j++) + for (idx = 0, j = 0; j < h; j++) { - for (i = 0; i < w; i++) + for (i = 0; i < w; i++, idx++) { - int idx = (w*j+i); - if ((*pImgData == HWR_PATCHES_CHROMAKEY_COLORINDEX) && chromakeyed) { tex[idx].s.red = 0; @@ -1666,12 +1665,10 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) ptex = tex = textureBuffer; texformat = GL_LUMINANCE_ALPHA; - for (j = 0; j < h; j++) + for (idx = 0, j = 0; j < h; j++) { - for (i = 0; i < w; i++) + for (i = 0; i < w; i++, idx++) { - int idx = (w*j+i); - tex[idx].s.red = *pImgData; tex[idx].s.green = *pImgData; tex[idx].s.blue = *pImgData; @@ -1686,12 +1683,10 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) ptex = tex = textureBuffer; texformat = GL_ALPHA; - for (j = 0; j < h; j++) + for (idx = 0, j = 0; j < h; j++) { - for (i = 0; i < w; i++) + for (i = 0; i < w; i++, idx++) { - int idx = (w*j+i); - tex[idx].s.red = 255; // 255 because the fade mask is modulated with the screen texture, so alpha affects it while the colours don't tex[idx].s.green = 255; tex[idx].s.blue = 255;