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 Jan 3, 2017
1 parent e5a7fd0 commit 78965ec
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions demos/atb-agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* file `LICENSE` for more details.
*/
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

Expand Down Expand Up @@ -296,15 +295,18 @@ void TW_CALL get_lcd_filtering( 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 @@ -313,18 +315,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 78965ec

Please sign in to comment.