guirenderer: fix bug that was breaking the ScEd button in main menu. it was calling glEnable/glActiveTextureUnit before ogl_tex_bind, which is now also doing that.
self_test: added another note wtime: fix evil bug - was casting FILETIME* to u64*, which has different alignment guarantees. This was SVN commit r2662.
This commit is contained in:
parent
c0c08bd851
commit
c6215a1451
@ -267,8 +267,7 @@ public:
|
||||
|
||||
// Texture unit 0:
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
ogl_tex_bind(tex);
|
||||
ogl_tex_bind(tex, 0);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
@ -288,9 +287,7 @@ public:
|
||||
|
||||
// Texture unit 1:
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE1);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
ogl_tex_bind(tex);
|
||||
ogl_tex_bind(tex, 1);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace test { // (2)
|
||||
|
||||
static void test_log2()
|
||||
{
|
||||
TEST(ilog2(0) == -1);
|
||||
TEST(ilog2(0) == -1); // (3)
|
||||
// further test cases..
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ static void self_test()
|
||||
// further test groups..
|
||||
}
|
||||
|
||||
RUN_SELF_TEST; // (3)
|
||||
RUN_SELF_TEST; // (4)
|
||||
|
||||
} // namespace test
|
||||
#endif // #if SELF_TEST_ENABLED
|
||||
@ -88,7 +88,10 @@ RUN_SELF_TEST; // (3)
|
||||
(2) wrapping in a namespace is optional and must be removed for C programs.
|
||||
it avoids possible name collisions with the module being tested.
|
||||
|
||||
(3) automatically calls your self_test function at non-local static object
|
||||
(3) TEST *must* be used instead of debug_assert et al.! this is
|
||||
explained below.
|
||||
|
||||
(4) automatically calls your self_test function at non-local static object
|
||||
init time (i.e. before main is entered).
|
||||
|
||||
For further details, see below.
|
||||
|
@ -649,7 +649,16 @@ static int hrt_shutdown()
|
||||
//
|
||||
|
||||
// hectonanoseconds between Windows and POSIX epoch
|
||||
static const i64 posix_epoch_hns = 0x019DB1DED53E8000;
|
||||
static const u64 posix_epoch_hns = 0x019DB1DED53E8000;
|
||||
|
||||
// this function avoids the pitfall of casting FILETIME* to u64*,
|
||||
// which is not safe due to differing alignment guarantees!
|
||||
// on some platforms, that would result in an exception.
|
||||
static u64 u64_from_FILETIME(const FILETIME* ft)
|
||||
{
|
||||
return u64_from_u32(ft->dwHighDateTime, ft->dwLowDateTime);
|
||||
}
|
||||
|
||||
|
||||
// convert UTC FILETIME to seconds-since-1970 UTC:
|
||||
// we just have to subtract POSIX epoch and scale down to units of seconds.
|
||||
@ -658,8 +667,8 @@ static const i64 posix_epoch_hns = 0x019DB1DED53E8000;
|
||||
// so don't use that.
|
||||
time_t utc_filetime_to_time_t(FILETIME* ft)
|
||||
{
|
||||
i64 hns = *(i64*)ft;
|
||||
i64 s = (hns - posix_epoch_hns) / _1e7;
|
||||
u64 hns = u64_from_FILETIME(ft);
|
||||
u64 s = (hns - posix_epoch_hns) / _1e7;
|
||||
return (time_t)(s & 0xffffffff);
|
||||
}
|
||||
|
||||
@ -699,7 +708,7 @@ static i64 st_time_ns()
|
||||
{
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
i64 hns = *(i64*)&ft;
|
||||
u64 hns = u64_from_FILETIME(&ft);
|
||||
return (hns - posix_epoch_hns) * 100;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user