diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 4df24bd16..16b6b3735 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -55,10 +55,10 @@ static INT32 format2bpp(GLTextureFormat_t format) // It is now split from it for my sanity! (and the sanity of others) // -- Monster Iestyn (13/02/19) static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap, - INT32 pblockheight, INT32 blockmodulo, - fixed_t yfracstep, fixed_t scale_y, - texpatch_t *originPatch, INT32 patchheight, - INT32 bpp, RGBA_t *palette) + INT32 pblockheight, INT32 blockmodulo, + fixed_t yfracstep, fixed_t scale_y, + texpatch_t *originPatch, INT32 patchheight, + INT32 bpp, RGBA_t *palette) { fixed_t yfrac, position, count; UINT8 *dest; @@ -74,9 +74,6 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm (void)patchheight; // This parameter is unused - if (!mipmap || mipmap == NULL) - return; - if (originPatch) // originPatch can be NULL here, unlike in the software version originy = originPatch->originy; @@ -112,10 +109,10 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm count--; texel = source[yfrac>>FRACBITS]; - alpha = 0xff; + alpha = 0xFF; - //Hurdler: not perfect, but better than holes - if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX && (mipmap->flags & TF_CHROMAKEYED)) + // Make pixel transparent if chroma keyed + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) alpha = 0x00; //Hurdler: 25/04/2000: now support colormap in hardware mode @@ -127,7 +124,8 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm // Alam: SRB2 uses Mingw, HUGS switch (bpp) { - case 2 : texelu16 = (UINT16)((alpha<<8) | texel); + case 2 : // uhhhhhhhh.......... + texelu16 = (UINT16)((alpha<<8) | texel); memcpy(dest, &texelu16, sizeof(UINT16)); break; case 3 : colortemp = palette[texel]; @@ -145,6 +143,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm dest += blockmodulo; yfrac += yfracstep; } + patchcol = (const column_t *)((const UINT8 *)patchcol + patchcol->length + 4); } } @@ -186,6 +185,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, if (bpp < 1 || bpp > 4) I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); + // NOTE: should this actually be pblockwidth*bpp? blockmodulo = pblockwidth*bpp; // Draw each column to the block cache @@ -264,6 +264,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, if (bpp < 1 || bpp > 4) I_Error("HWR_DrawTexturePatchInCache: no drawer defined for this bpp (%d)\n",bpp); + // NOTE: should this actually be pblockwidth*bpp? blockmodulo = pblockwidth*bpp; // Draw each column to the block cache @@ -337,8 +338,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe else gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; - gltex->mipmap.width = SHORT(texture->width); - gltex->mipmap.height = SHORT(texture->height); + gltex->mipmap.width = (UINT16)(texture->width); + gltex->mipmap.height = (UINT16)(texture->height); if (skyspecial) gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ... @@ -363,14 +364,17 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe RGBA_t col; col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX]; + for (j = 0; j < blockheight; j++) { for (i = 0; i < blockwidth; i++) { - block[4*(j*blockwidth+i)+0] = col.s.red; - block[4*(j*blockwidth+i)+1] = col.s.green; - block[4*(j*blockwidth+i)+2] = col.s.blue; - block[4*(j*blockwidth+i)+3] = 0xff; + int idx = (j*blockwidth+i); + + block[4*idx+0] = col.s.red; + block[4*idx+1] = col.s.green; + block[4*idx+2] = col.s.blue; + block[4*idx+3] = 0xff; } } } @@ -379,15 +383,12 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); - HWR_DrawTexturePatchInCache(&gltex->mipmap, - blockwidth, blockheight, - texture, patch, - realpatch); + HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( - if (format2bpp(gltex->mipmap.format)==4) + if (format2bpp(gltex->mipmap.format) == 4) { for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp { @@ -438,6 +439,7 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, bo if (makebitmap) { MakeBlock(glMipmap); + HWR_DrawPatchInCache(glMipmap, glMipmap->width, glMipmap->height, glPatch->width, glPatch->height, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8e30f237f..ba9ccbc50 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -141,6 +141,8 @@ static void HWR_TogglePaletteRendering(void); // ========================================================================== // Commands and console variables // ========================================================================== +static void HWR_RegisterCommands(void); +static void COM_HWR_glinfo(void); // // Onchanges @@ -5584,11 +5586,63 @@ void HWR_Startup(void) HWR_TogglePaletteRendering(); if (msaa) - GL_SetSpecialState(HWD_SET_MSAA, a2c ? 2 : 1); + HWD.pfnSetSpecialState(HWD_SET_MSAA, a2c ? 2 : 1); + + HWR_RegisterCommands(); } startupdone = true; } +/** + * Register renderer commands. + */ +static void HWR_RegisterCommands(void) +{ + COM_AddCommand("gr_glinfo", COM_HWR_glinfo); +} + +static void COM_HWR_glinfo(void) +{ + if (vid.glstate != VID_GL_LIBRARY_LOADED) + { + CONS_Printf("Currently not using the OpenGL renderer.\n"); + return; + } + + int list_extensions = 0; + size_t argc = COM_Argc(); + const char *argv; + for (size_t i = 1; i < argc; i++) + { + argv = COM_Argv(i); + + if (strcmp(argv, "--list-extensions") == 0 || strcmp(argv, "-l") == 0) + { + list_extensions = 1; + } + else + { + CONS_Printf("Unrecognized argument: %s\n", argv); + return; + } + + } + + CONS_Printf("\x88OpenGL %s\x80\n", gl_version); + CONS_Printf("Renderer: %s\n", gl_renderer); + CONS_Printf("Vendor: %s\n", gl_vendor); + + CONS_Printf("%u GL extensions present.\n", gl_num_extensions); + if (list_extensions) + { + CONS_Printf("%s\n", gl_extensions); + } + else + { + CONS_Printf("Use --list-extensions to view the list of extensions.\n"); + } +} + // -------------------------------------------------------------------------- // Free resources allocated by the hardware renderer // -------------------------------------------------------------------------- diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 077bdbbbe..72bb34e61 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -114,6 +114,8 @@ static FTransform md2_transform; const GLubyte *gl_version = NULL; const GLubyte *gl_renderer = NULL; const GLubyte *gl_extensions = NULL; +const GLubyte *gl_vendor = NULL; +GLuint gl_num_extensions; // Loaded OpenGL version int majorGL = 0, minorGL = 0; diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index dfa754f1e..dfbae7f6d 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -121,6 +121,8 @@ extern boolean supportFBO; extern const GLubyte *gl_version; extern const GLubyte *gl_renderer; extern const GLubyte *gl_extensions; +extern const GLubyte *gl_vendor; +extern GLuint gl_num_extensions; extern int majorGL, minorGL; diff --git a/src/p_mobj.c b/src/p_mobj.c index 7bef4d727..b7c86cbd5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10201,19 +10201,26 @@ void P_SpawnPrecipitation(void) if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart return; + fixed_t density = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + + if (cv_lessprecip.value) + density *= 2; // just spawn half the precip + // Use the blockmap to narrow down our placing patterns for (i = 0; i < bmapwidth*bmapheight; ++i) { basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; - for (j = 0; j < FRACUNIT; j += cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT) + // If mobjscale < FRACUNIT, each blockmap cell covers + // more area so spawn more precipitation in that area. + for (j = 0; j < FRACUNIT; j += density) { INT32 floorz; INT32 ceilingz; - x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); - y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); + x = basex + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3); + y = basey + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3); precipsector = R_IsPointInSubsector(x, y); diff --git a/src/p_spec.c b/src/p_spec.c index 2ab2c20df..2472c5dbf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1807,27 +1807,23 @@ void P_SwitchWeather(INT32 weathernum) precipmobj = (precipmobj_t *)think; + mobjtype_t type = 0; + INT32 z = 0; + + if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. + { + precipmobj->precipflags |= PCF_INVISIBLE; + continue; + } + if (swap == PRECIP_RAIN) // Snow To Rain { - precipmobj->type = MT_RAIN; // proper set the type - precipmobj->info = &mobjinfo[MT_RAIN]; - precipmobj->flags = mobjinfo[MT_RAIN].flags; - st = &states[mobjinfo[MT_RAIN].spawnstate]; - precipmobj->state = st; - precipmobj->tics = st->tics; - precipmobj->sprite = st->sprite; - precipmobj->frame = st->frame; - precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_RAIN].speed, mapobjectscale) : mobjinfo[MT_RAIN].speed; - - precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to + type = MT_RAIN; } else if (swap == PRECIP_SNOW) // Rain To Snow { - INT32 z; + type = MT_SNOWFLAKE; - precipmobj->type = MT_SNOWFLAKE; // proper set the type - precipmobj->info = &mobjinfo[MT_SNOWFLAKE]; - precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags; z = M_RandomByte(); if (z < 64) @@ -1836,92 +1832,69 @@ void P_SwitchWeather(INT32 weathernum) z = 1; else z = 0; - - st = &states[mobjinfo[MT_SNOWFLAKE].spawnstate+z]; - precipmobj->state = st; - precipmobj->tics = st->tics; - precipmobj->sprite = st->sprite; - precipmobj->frame = st->frame; - precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_SNOWFLAKE].speed, mapobjectscale) : mobjinfo[MT_SNOWFLAKE].speed; - - precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to - } - else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. - { - precipmobj->precipflags |= PCF_INVISIBLE; } + + precipmobj->type = type; // proper set the type + precipmobj->info = &mobjinfo[type]; + precipmobj->flags = mobjinfo[type].flags; + + st = &states[mobjinfo[type].spawnstate+z]; + + precipmobj->state = st; + precipmobj->tics = st->tics; + precipmobj->sprite = st->sprite; + precipmobj->frame = st->frame; + precipmobj->momz = (cv_mobjscaleprecip.value ? FixedMul(mobjinfo[type].speed, mapobjectscale) : mobjinfo[type].speed); + + precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to } } + boolean dontspawn = false; + switch (weathernum) { case PRECIP_SNOW: // snow curWeather = PRECIP_SNOW; - - if (!swap) - P_SpawnPrecipitation(); - break; case PRECIP_RAIN: // rain { - boolean dontspawn = false; - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) dontspawn = true; curWeather = PRECIP_RAIN; - - if (!dontspawn && !swap) - P_SpawnPrecipitation(); - break; } case PRECIP_STORM: // storm { - boolean dontspawn = false; - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) dontspawn = true; curWeather = PRECIP_STORM; - - if (!dontspawn && !swap) - P_SpawnPrecipitation(); - break; } case PRECIP_STORM_NOSTRIKES: // storm w/o lightning { - boolean dontspawn = false; - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) dontspawn = true; curWeather = PRECIP_STORM_NOSTRIKES; - - if (!dontspawn && !swap) - P_SpawnPrecipitation(); - break; } case PRECIP_STORM_NORAIN: // storm w/o rain curWeather = PRECIP_STORM_NORAIN; - - if (!swap) - P_SpawnPrecipitation(); - break; case PRECIP_BLANK: curWeather = PRECIP_BLANK; - - if (!swap) - P_SpawnPrecipitation(); - break; default: + dontspawn = true; curWeather = PRECIP_NONE; break; } + + if (!dontspawn && !swap) + P_SpawnPrecipitation(); } /** Gets an object. diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 006ad87fb..ba6ab3d04 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -150,6 +150,8 @@ boolean OglSdlSurface(INT32 w, INT32 h) gl_version = pglGetString(GL_VERSION); gl_renderer = pglGetString(GL_RENDERER); gl_extensions = pglGetString(GL_EXTENSIONS); + pglGetIntegerv(GL_NUM_EXTENSIONS, (GLint*)&gl_num_extensions); + gl_vendor = pglGetString(GL_VENDOR); GL_DBG_Printf("OpenGL %s\n", gl_version); GL_DBG_Printf("GPU: %s\n", gl_renderer);