Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Apr 23, 2018
1 parent 1068eff commit 80d56ed
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 21 deletions.
36 changes: 18 additions & 18 deletions examples/08-update/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,22 @@ class ExampleUpdate : public entry::AppI
}

m_textureCube[0] = bgfx::createTextureCube(
textureside
, false
, 1
, bgfx::TextureFormat::BGRA8
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT
);

if (m_blitSupported)
{
m_textureCube[1] = bgfx::createTextureCube(
textureside
, false
, 1
, bgfx::TextureFormat::BGRA8
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT|BGFX_TEXTURE_BLIT_DST
);

if (m_blitSupported)
{
m_textureCube[1] = bgfx::createTextureCube(
textureside
, false
, 1
, bgfx::TextureFormat::BGRA8
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT|BGFX_TEXTURE_BLIT_DST
);
}

if (m_computeSupported)
Expand All @@ -274,13 +274,13 @@ class ExampleUpdate : public entry::AppI
}

m_texture2d = bgfx::createTexture2D(
texture2dSize
, texture2dSize
, false
, 1
, bgfx::TextureFormat::BGRA8
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT
);
texture2dSize
, texture2dSize
, false
, 1
, bgfx::TextureFormat::BGRA8
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT
);

m_texture2dData = (uint8_t*)malloc(texture2dSize*texture2dSize*4);

Expand Down
38 changes: 35 additions & 3 deletions tools/texturev/texturev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,7 @@ struct InterpolatorT

float getValue()
{

if (duration > 0.0)
if (isActive() )
{
const double freq = double(bx::getHPFrequency() );
int64_t now = bx::getHPCounter();
Expand All @@ -989,6 +988,15 @@ struct InterpolatorT

return to;
}

bool isActive() const
{
const double freq = double(bx::getHPFrequency() );
int64_t now = bx::getHPCounter();
float time = (float)(double(now - offset) / freq);
float lerp = bx::clamp(time, 0.0f, duration) / duration;
return lerp < 1.0f;
}
};

typedef InterpolatorT<bx::lerp, bx::easeInOutQuad> Interpolator;
Expand Down Expand Up @@ -1266,6 +1274,23 @@ int _main_(int _argc, char** _argv)
InterpolatorAngle angx(0.0f);
InterpolatorAngle angy(0.0f);

auto anyActive = [&]() -> bool
{
return false
|| menuFade.isActive()
|| mip.isActive()
|| layer.isActive()
|| ev.isActive()
|| zoom.isActive()
|| scale.isActive()
|| posx.isActive()
|| posy.isActive()
|| angle.isActive()
|| angx.isActive()
|| angy.isActive()
;
};

const char* filePath = _argc < 2 ? "" : _argv[1];

std::string path = filePath;
Expand Down Expand Up @@ -1461,7 +1486,7 @@ int _main_(int _argc, char** _argv)
mouseDelta = true;
}

int32_t zoomDelta = overArea ? 0.0f : mouseState.m_mz - mouseStatePrev.m_mz;
int32_t zoomDelta = overArea ? 0 : mouseState.m_mz - mouseStatePrev.m_mz;
if (zoomDelta != 0)
{
char exec[64];
Expand Down Expand Up @@ -1999,6 +2024,13 @@ int _main_(int _argc, char** _argv)
}

bgfx::frame();

// Slow down when nothing is animating...
if (!dragging
&& !anyActive() )
{
bx::sleep(100);
}
}
}

Expand Down

0 comments on commit 80d56ed

Please sign in to comment.