lib: only debug_warn in UNREACHABLE in paranoia builds - avoids lots of warnings in debug mode
cursor: fix definition of ALLOW_SYS_CURSOR and use DDS instead of PNG ogl_tex: add ogl_tex_transform_to for convenience tex: fix issue with transform code (might not flip image if it was DDS) win: decompress cursor texture if it was DDS renderer: use DDS instead of PNG for alpha maps This was SVN commit r3148.
This commit is contained in:
parent
c2b3157b8d
commit
d5d6e4052e
@ -313,9 +313,12 @@ enum LibError
|
|||||||
|
|
||||||
// indicates a piece of code cannot be reached (e.g. because all
|
// indicates a piece of code cannot be reached (e.g. because all
|
||||||
// control paths before it end up returning). this is mostly for
|
// control paths before it end up returning). this is mostly for
|
||||||
// human benefit, but it may also help optimization and warns in debug mode.
|
// human benefit, but it may also help optimization and generates
|
||||||
|
// warnings if reached in paranoia builds.
|
||||||
#if MSC_VERSION
|
#if MSC_VERSION
|
||||||
# ifndef NDEBUG
|
// .. note: we only enable this in paranoia builds because it
|
||||||
|
// causes "unreachable code" warnings (exactly what we want to avoid).
|
||||||
|
# if CONFIG_PARANOIA
|
||||||
# define UNREACHABLE debug_warn("hit supposedly unreachable code");
|
# define UNREACHABLE debug_warn("hit supposedly unreachable code");
|
||||||
# else
|
# else
|
||||||
# define UNREACHABLE __assume(0)
|
# define UNREACHABLE __assume(0)
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
// cursors (Windows = more responsive, OpenGL = more consistent with what
|
// cursors (Windows = more responsive, OpenGL = more consistent with what
|
||||||
// the game sees)
|
// the game sees)
|
||||||
#if OS_WIN
|
#if OS_WIN
|
||||||
#define ALLOW_SYS_CURSOR 1
|
# define ALLOW_SYS_CURSOR 1
|
||||||
|
#else
|
||||||
|
# define ALLOW_SYS_CURSOR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lib/ogl.h"
|
#include "lib/ogl.h"
|
||||||
@ -121,7 +123,7 @@ static int Cursor_reload(Cursor* c, const char* name, Handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load actual cursor
|
// load actual cursor
|
||||||
snprintf(filename, ARRAY_SIZE(filename), "art/textures/cursors/%s.png", name);
|
snprintf(filename, ARRAY_SIZE(filename), "art/textures/cursors/%s.dds", name);
|
||||||
// .. system cursor (2d, hardware accelerated)
|
// .. system cursor (2d, hardware accelerated)
|
||||||
#if ALLOW_SYS_CURSOR
|
#if ALLOW_SYS_CURSOR
|
||||||
WARN_ERR(sys_cursor_load(filename, hotspotx, hotspoty, &c->sys_cursor));
|
WARN_ERR(sys_cursor_load(filename, hotspotx, hotspoty, &c->sys_cursor));
|
||||||
|
@ -957,3 +957,13 @@ int ogl_tex_transform(Handle ht, uint transforms)
|
|||||||
int ret = tex_transform(&ot->t, transforms);
|
int ret = tex_transform(&ot->t, transforms);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// change the pixel format to that specified by <new_flags>.
|
||||||
|
// (note: this is equivalent to ogl_tex_transform(ht, ht_flags^new_flags).
|
||||||
|
int ogl_tex_transform_to(Handle ht, uint new_flags)
|
||||||
|
{
|
||||||
|
H_DEREF(ht, OglTex, ot);
|
||||||
|
int ret = tex_transform_to(&ot->t, new_flags);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -313,4 +313,8 @@ extern int ogl_tex_bind(Handle ht, uint unit = 0);
|
|||||||
// must be called before uploading (raises a warning if called afterwards).
|
// must be called before uploading (raises a warning if called afterwards).
|
||||||
extern int ogl_tex_transform(Handle ht, uint flags);
|
extern int ogl_tex_transform(Handle ht, uint flags);
|
||||||
|
|
||||||
|
// change the pixel format to that specified by <new_flags>.
|
||||||
|
// (note: this is equivalent to ogl_tex_transform(ht, ht_flags^new_flags).
|
||||||
|
extern int ogl_tex_transform_to(Handle ht, uint new_flags);
|
||||||
|
|
||||||
#endif // #ifndef OGL_TEX_H__
|
#endif // #ifndef OGL_TEX_H__
|
||||||
|
@ -532,19 +532,21 @@ TIMER_ACCRUE(tc_transform);
|
|||||||
CHECK_TEX(t);
|
CHECK_TEX(t);
|
||||||
|
|
||||||
const uint target_flags = t->flags ^ transforms;
|
const uint target_flags = t->flags ^ transforms;
|
||||||
|
uint remaining_transforms;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
remaining_transforms = target_flags ^ t->flags;
|
||||||
// we're finished (all required transforms have been done)
|
// we're finished (all required transforms have been done)
|
||||||
if(t->flags == target_flags)
|
if(remaining_transforms == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int ret = tex_codec_transform(t, transforms);
|
int ret = tex_codec_transform(t, remaining_transforms);
|
||||||
if(ret != 0)
|
if(ret != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// last chance
|
// last chance
|
||||||
CHECK_ERR(plain_transform(t, transforms));
|
CHECK_ERR(plain_transform(t, remaining_transforms));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,8 +561,9 @@ int sys_cursor_load(const char* filename,
|
|||||||
RETURN_ERR(tex_load(filename, &t));
|
RETURN_ERR(tex_load(filename, &t));
|
||||||
uint w = t.w, h = t.h;
|
uint w = t.w, h = t.h;
|
||||||
|
|
||||||
// convert to BGRA (required by CreateBitmap).
|
// convert to format required by CreateBitmap.
|
||||||
RETURN_ERR(tex_transform_to(&t, t.flags|TEX_BGR));
|
const uint flags = (t.flags | TEX_BGR) & ~TEX_DXT;
|
||||||
|
RETURN_ERR(tex_transform_to(&t, flags));
|
||||||
void* tex_bgra = tex_get_data(&t);
|
void* tex_bgra = tex_get_data(&t);
|
||||||
|
|
||||||
// MSDN says selecting this HBITMAP into a DC is slower since we use
|
// MSDN says selecting this HBITMAP into a DC is slower since we use
|
||||||
|
@ -1453,20 +1453,20 @@ int CRenderer::LoadAlphaMaps()
|
|||||||
PathPackage pp;
|
PathPackage pp;
|
||||||
(void)pp_set_dir(&pp, "art/textures/terrain/alphamaps/special");
|
(void)pp_set_dir(&pp, "art/textures/terrain/alphamaps/special");
|
||||||
const char* fnames[NumAlphaMaps] = {
|
const char* fnames[NumAlphaMaps] = {
|
||||||
"blendcircle.png",
|
"blendcircle.dds",
|
||||||
"blendlshape.png",
|
"blendlshape.dds",
|
||||||
"blendedge.png",
|
"blendedge.dds",
|
||||||
"blendedgecorner.png",
|
"blendedgecorner.dds",
|
||||||
"blendedgetwocorners.png",
|
"blendedgetwocorners.dds",
|
||||||
"blendfourcorners.png",
|
"blendfourcorners.dds",
|
||||||
"blendtwooppositecorners.png",
|
"blendtwooppositecorners.dds",
|
||||||
"blendlshapecorner.png",
|
"blendlshapecorner.dds",
|
||||||
"blendtwocorners.png",
|
"blendtwocorners.dds",
|
||||||
"blendcorner.png",
|
"blendcorner.dds",
|
||||||
"blendtwoedges.png",
|
"blendtwoedges.dds",
|
||||||
"blendthreecorners.png",
|
"blendthreecorners.dds",
|
||||||
"blendushape.png",
|
"blendushape.dds",
|
||||||
"blendbad.png"
|
"blendbad.dds"
|
||||||
};
|
};
|
||||||
uint base = 0; // texture width/height (see below)
|
uint base = 0; // texture width/height (see below)
|
||||||
// for convenience, we require all alpha maps to be of the same BPP
|
// for convenience, we require all alpha maps to be of the same BPP
|
||||||
@ -1480,6 +1480,13 @@ int CRenderer::LoadAlphaMaps()
|
|||||||
textures[i] = ogl_tex_load(pp.path, RES_NO_CACHE);
|
textures[i] = ogl_tex_load(pp.path, RES_NO_CACHE);
|
||||||
RETURN_ERR(textures[i]);
|
RETURN_ERR(textures[i]);
|
||||||
|
|
||||||
|
// quick hack: we require plain RGB(A) format, so convert to that.
|
||||||
|
// ideally the texture would be in uncompressed form; then this wouldn't
|
||||||
|
// be necessary.
|
||||||
|
uint flags;
|
||||||
|
ogl_tex_get_format(textures[i], &flags, 0);
|
||||||
|
ogl_tex_transform_to(textures[i], flags & ~TEX_DXT);
|
||||||
|
|
||||||
// get its size and make sure they are all equal.
|
// get its size and make sure they are all equal.
|
||||||
// (the packing algo assumes this)
|
// (the packing algo assumes this)
|
||||||
uint this_width = 0, this_bpp = 0; // fail-safe
|
uint this_width = 0, this_bpp = 0; // fail-safe
|
||||||
|
Loading…
Reference in New Issue
Block a user