projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver]
/
hacks
/
glx
/
geodesicgears.c
diff --git
a/hacks/glx/geodesicgears.c
b/hacks/glx/geodesicgears.c
index 83127c42178f072511e645d9a4aec2148f01ad02..ecc7f26c05ec8e9e25154920c9952b262019c63a 100644
(file)
--- a/
hacks/glx/geodesicgears.c
+++ b/
hacks/glx/geodesicgears.c
@@
-1,4
+1,4
@@
-/* geodesicgears, Copyright (c) 2014 Jamie Zawinski <jwz@jwz.org>
+/* geodesicgears, Copyright (c) 2014
-2015
Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@
-17,9
+17,10
@@
"*wireframe: False \n" \
"*showFPS: False \n" \
"*texFontCacheSize: 100 \n" \
"*wireframe: False \n" \
"*showFPS: False \n" \
"*texFontCacheSize: 100 \n" \
+ "*suppressRotationAnimation: True\n" \
"*font: -*-helvetica-medium-r-normal-*-*-160-*-*-*-*-*-*\n" \
"*font: -*-helvetica-medium-r-normal-*-*-160-*-*-*-*-*-*\n" \
-# define re
fresh
_geodesic 0
+# define re
lease
_geodesic 0
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
@@
-1314,9
+1315,19
@@
make_182 (ModeInfo *mi, const GLfloat *args)
ENTRYPOINT void
reshape_geodesic (ModeInfo *mi, int width, int height)
{
ENTRYPOINT void
reshape_geodesic (ModeInfo *mi, int width, int height)
{
+ geodesic_configuration *bp = &bps[MI_SCREEN(mi)];
GLfloat h = (GLfloat) height / (GLfloat) width;
GLfloat h = (GLfloat) height / (GLfloat) width;
+ int y = 0;
+
+ if (width > height * 5) { /* tiny window: show middle */
+ height = width * 9/16;
+ y = -height/2;
+ h = height / (GLfloat) width;
+ }
- glViewport (0, 0, (GLint) width, (GLint) height);
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));
+
+ glViewport (0, y, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@
-1328,6
+1339,14
@@
reshape_geodesic (ModeInfo *mi, int width, int height)
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
+# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */
+ {
+ int o = (int) current_device_rotation();
+ if (o != 0 && o != 180 && o != -180)
+ glScalef (1/h, 1/h, 1/h);
+ }
+# endif
+
glClear(GL_COLOR_BUFFER_BIT);
}
glClear(GL_COLOR_BUFFER_BIT);
}
@@
-1396,14
+1415,7
@@
init_geodesic (ModeInfo *mi)
geodesic_configuration *bp;
int wire = MI_IS_WIREFRAME(mi);
geodesic_configuration *bp;
int wire = MI_IS_WIREFRAME(mi);
- if (!bps) {
- bps = (geodesic_configuration *)
- calloc (MI_NUM_SCREENS(mi), sizeof (geodesic_configuration));
- if (!bps) {
- fprintf(stderr, "%s: out of memory\n", progname);
- exit(1);
- }
- }
+ MI_INIT (mi, bps);
bp = &bps[MI_SCREEN(mi)];
bp = &bps[MI_SCREEN(mi)];
@@
-1700,6
+1712,7
@@
draw_geodesic (ModeInfo *mi)
int w, h, j;
char buf[100];
int w, h, j;
char buf[100];
+ XCharStruct e;
/* If an even number of teeth, offset by 1/2 tooth width. */
if (s->direction > 0 /* && !(g->nteeth & 1) */)
/* If an even number of teeth, offset by 1/2 tooth width. */
if (s->direction > 0 /* && !(g->nteeth & 1) */)
@@
-1721,8
+1734,10
@@
draw_geodesic (ModeInfo *mi)
glPushMatrix();
glScalef(0.005, 0.005, 0.005);
sprintf (buf, "%d", i);
glPushMatrix();
glScalef(0.005, 0.005, 0.005);
sprintf (buf, "%d", i);
- w = texture_string_width (bp->font, buf, &h);
- glTranslatef (-w/2, -h*2/3, 0);
+ texture_string_metrics (bp->font, buf, &e, 0, 0);
+ w = e.width;
+ h = e.ascent + e.descent;
+ glTranslatef (-w/2, -h/2, 0);
print_texture_string (bp->font, buf);
glPopMatrix();
print_texture_string (bp->font, buf);
glPopMatrix();
@@
-1738,8
+1753,10
@@
draw_geodesic (ModeInfo *mi)
glTranslatef (r * cos(th), r * sin(th), -g->z + 0.01);
glScalef(ss, ss, ss);
sprintf (buf, "%d", j + 1);
glTranslatef (r * cos(th), r * sin(th), -g->z + 0.01);
glScalef(ss, ss, ss);
sprintf (buf, "%d", j + 1);
- w = texture_string_width (bp->font, buf, &h);
- glTranslatef (-w/2, -h*2/3, 0);
+ texture_string_metrics (bp->font, buf, &e, 0, 0);
+ w = e.width;
+ h = e.ascent + e.descent;
+ glTranslatef (-w/2, -h/2, 0);
print_texture_string (bp->font, buf);
glPopMatrix();
}
print_texture_string (bp->font, buf);
glPopMatrix();
}
@@
-1768,9
+1785,12
@@
draw_geodesic (ModeInfo *mi)
}
ENTRYPOINT void
}
ENTRYPOINT void
-
releas
e_geodesic (ModeInfo *mi)
+
fre
e_geodesic (ModeInfo *mi)
{
geodesic_configuration *bp = &bps[MI_SCREEN(mi)];
{
geodesic_configuration *bp = &bps[MI_SCREEN(mi)];
+ if (!bp->glx_context)
+ return;
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));
free_texture_font (bp->font);
free (bp->colors);
free_sphere_gears (mi);
free_texture_font (bp->font);
free (bp->colors);
free_sphere_gears (mi);