diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c
index 2574bc011663919c5038b4b95c9d77a187c26ad6..b1a685ff4ccf3a440fdb6fe00d5d4bdd03a7d4bf 100644
--- a/src/hardware/hw_cache.c
+++ b/src/hardware/hw_cache.c
@@ -727,8 +727,8 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
 #ifndef NO_PNG_LUMPS
 	// lump is a png so convert it
 	size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum);
-	if ((patch != NULL) && R_IsLumpPNG((UINT8 *)patch, len))
-		patch = R_PNGToPatch((UINT8 *)patch, len, NULL, true);
+	if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len))
+		patch = R_PNGToPatch((const UINT8 *)patch, len, NULL, true);
 #endif
 
 	// don't do it twice (like a cache)
diff --git a/src/r_data.c b/src/r_data.c
index 172a61da5863b9e76b71d7fc5c373f87b9543e39..be27fecad95c9dd3a957a260b2e5119cce569abb 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -2588,7 +2588,7 @@ void R_PatchToFlat(patch_t *patch, UINT8 *flat)
 }
 
 #ifndef NO_PNG_LUMPS
-boolean R_IsLumpPNG(UINT8 *d, size_t s)
+boolean R_IsLumpPNG(const UINT8 *d, size_t s)
 {
 	if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/
 		return false;
@@ -2599,8 +2599,12 @@ boolean R_IsLumpPNG(UINT8 *d, size_t s)
 }
 
 #ifdef HAVE_PNG
+
+#if PNG_LIBPNG_VER_DLLNUM < 14
+typedef PNG_CONST png_byte *png_const_bytep;
+#endif
 typedef struct {
-	png_bytep buffer;
+	png_const_bytep buffer;
 	png_uint_32 bufsize;
 	png_uint_32 current_pos;
 } png_io_t;
@@ -2626,6 +2630,7 @@ static png_chunk_t chunk;
 
 static int PNG_ChunkReader(png_structp png_ptr, png_unknown_chunkp chonk)
 {
+	(void)png_ptr;
 	if (!memcmp(chonk->name, chunkname, 4))
 	{
 		memcpy(chunk.name, chonk->name, 4);
@@ -2648,7 +2653,7 @@ static void PNG_warn(png_structp PNG, png_const_charp pngtext)
 	CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext);
 }
 
-static png_bytep *PNG_Read(UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
+static png_bytep *PNG_Read(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
 {
 	png_structp png_ptr;
 	png_infop png_info_ptr;
@@ -2697,7 +2702,7 @@ static png_bytep *PNG_Read(UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, I
 #endif
 
 	// set our own read_function
-	png_io.buffer = (png_bytep)png;
+	png_io.buffer = (png_const_bytep)png;
 	png_io.bufsize = size;
 	png_io.current_pos = 0;
 	png_set_read_fn(png_ptr, &png_io, PNG_IOReader);
@@ -2767,7 +2772,7 @@ static png_bytep *PNG_Read(UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, I
 }
 
 // Convert a PNG to a raw image.
-static UINT8 *PNG_RawConvert(UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
+static UINT8 *PNG_RawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
 {
 	UINT8 *flat;
 	png_uint_32 x, y;
@@ -2803,7 +2808,7 @@ UINT8 *R_PNGToFlat(levelflat_t *levelflat, UINT8 *png, size_t size)
 
 // Convert a PNG to a patch.
 static unsigned char imgbuf[1<<26];
-patch_t *R_PNGToPatch(UINT8 *png, size_t size, size_t *destsize, boolean transparency)
+patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency)
 {
 	UINT16 width, height;
 	INT16 topoffset = 0, leftoffset = 0;
diff --git a/src/r_data.h b/src/r_data.h
index 38b7ba0ce4cd97b21ab412b29829a7a58a33ad03..ea48985dc53a123a0df2b5bc40eefe4fa10c01bd 100644
--- a/src/r_data.h
+++ b/src/r_data.h
@@ -165,10 +165,10 @@ void R_PatchToFlat(patch_t *patch, UINT8 *flat);
 void R_TextureToFlat(size_t tex, UINT8 *flat);
 
 #ifndef NO_PNG_LUMPS
-boolean R_IsLumpPNG(UINT8 *d, size_t s);
+boolean R_IsLumpPNG(const UINT8 *d, size_t s);
 
 UINT8 *R_PNGToFlat(levelflat_t *levelflat, UINT8 *png, size_t size);
-patch_t *R_PNGToPatch(UINT8 *png, size_t size, size_t *destsize, boolean transparency);
+patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency);
 boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size);
 #endif