Skip to content

Commit

Permalink
demos/atb-agg: support any integer scale factor
Browse files Browse the repository at this point in the history
as suggested by @bagobor
  • Loading branch information
yairchu committed Dec 22, 2016
1 parent 2e89c35 commit b781d97
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions demos/atb-agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,18 @@ void TW_CALL get_tertiary( void *value, void *data )
// ------------------------------------------------------------------- init ---
void init( GLFWwindow* window )
{
bool is_scaled;
int scale_factor;
{
int pixWidth, pixHeight, winWidth, winHeight;
glfwGetFramebufferSize( window, &pixWidth, &pixHeight );
glfwGetWindowSize( window, &winWidth, &winHeight );
is_scaled = pixWidth > winWidth || pixHeight > winHeight;
scale_factor = (pixWidth / (double) winWidth) + 0.5;
}
{
char buf[256];
sprintf(buf, "GLOBAL fontscaling=%d", scale_factor);
TwDefine(buf);
}
if (is_scaled)
TwDefine("GLOBAL fontscaling=2");

TwInit( TW_OPENGL, NULL );

Expand All @@ -448,18 +451,20 @@ void init( GLFWwindow* window )
TwDefine("GLOBAL "
"help = 'This example shows how to tune all font parameters.' ");
TwDefine("TweakBar "
"size = '280 400' "
"position = '500 20' "
"color = '127 127 127' "
"alpha = 240 "
"label = 'Parameters' "
"resizable = True "
"fontresizable = True "
"iconifiable = True ");
if (is_scaled)
TwDefine("TweakBar "
"size = '560 800' "
"position = '1000 40' ");
{
char buf[256];
sprintf(
buf, "TweakBar size = '%d %d' position = '%d %d'",
280*scale_factor, 400*scale_factor,
500*scale_factor, 20*scale_factor);
TwDefine(buf);
}

{
TwEnumVal familyEV[NUM_FONTS] = {
Expand Down

0 comments on commit b781d97

Please sign in to comment.