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.39.tar.gz
[xscreensaver]
/
hacks
/
glx
/
dymaxionmap.c
diff --git
a/hacks/glx/dymaxionmap.c
b/hacks/glx/dymaxionmap.c
index 60fb94f60bcfef835785bf01361b54f11c09ffc5..425e4c2d299825990eb3202ad62d4f61598fedb2 100644
(file)
--- a/
hacks/glx/dymaxionmap.c
+++ b/
hacks/glx/dymaxionmap.c
@@
-1,5
+1,5
@@
/* dymaxionmap --- Buckminster Fuller's unwrapped icosahedral globe.
/* dymaxionmap --- Buckminster Fuller's unwrapped icosahedral globe.
- * Copyright (c) 2016 Jamie Zawinski.
+ * Copyright (c) 2016
-2018
Jamie Zawinski.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
@@
-21,7
+21,6
@@
"*showFPS: False \n" \
"*wireframe: False \n" \
"*labelFont: " LABEL_FONT "\n"
"*showFPS: False \n" \
"*wireframe: False \n" \
"*labelFont: " LABEL_FONT "\n"
-# define refresh_planet 0
# define release_planet 0
# include "xlockmore.h" /* from the xscreensaver distribution */
#else /* !STANDALONE */
# define release_planet 0
# include "xlockmore.h" /* from the xscreensaver distribution */
#else /* !STANDALONE */
@@
-90,7
+89,7
@@
ENTRYPOINT ModeSpecOpt planet_opts = {countof(opts), opts, countof(vars), vars,
#ifdef USE_MODULES
ModStruct planet_description =
{"planet", "init_planet", "draw_planet", NULL,
#ifdef USE_MODULES
ModStruct planet_description =
{"planet", "init_planet", "draw_planet", NULL,
- "draw_planet", "init_planet",
NULL
, &planet_opts,
+ "draw_planet", "init_planet",
"free_planet"
, &planet_opts,
1000, 1, 2, 1, 4, 1.0, "",
"Buckminster Fuller's unwrapped icosahedral globe", 0, NULL};
#endif
1000, 1, 2, 1, 4, 1.0, "",
"Buckminster Fuller's unwrapped icosahedral globe", 0, NULL};
#endif
@@
-100,10
+99,10
@@
ModStruct planet_description =
ISO C89 compilers are required to support" when including
the following XPM file... */
# endif
ISO C89 compilers are required to support" when including
the following XPM file... */
# endif
-#include "
../images/dymaxionmap.xpm
"
-#include "
../images/ground.xpm
"
+#include "
images/gen/dymaxionmap_png.h
"
+#include "
images/gen/ground_png.h
"
-#include "x
pm-ximage
.h"
+#include "x
image-loader
.h"
#include "rotator.h"
#include "gltrackball.h"
#include "rotator.h"
#include "gltrackball.h"
@@
-129,10
+128,11
@@
static planetstruct *planets = NULL;
/* Set up and enable texturing on our object */
static void
/* Set up and enable texturing on our object */
static void
-setup_xpm_texture (ModeInfo *mi, char **xpm_data)
+setup_png_texture (ModeInfo *mi, const unsigned char *png_data,
+ unsigned long data_size)
{
{
- XImage *image =
xpm
_to_ximage (MI_DISPLAY (mi), MI_VISUAL (mi),
-
MI_COLORMAP (mi), xpm_data
);
+ XImage *image =
image_data
_to_ximage (MI_DISPLAY (mi), MI_VISUAL (mi),
+
png_data, data_size
);
char buf[1024];
clear_gl_error();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
char buf[1024];
clear_gl_error();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@
-141,10
+141,7
@@
setup_xpm_texture (ModeInfo *mi, char **xpm_data)
*/
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
image->width, image->height, 0,
*/
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
image->width, image->height, 0,
- GL_RGBA,
- /* GL_UNSIGNED_BYTE, */
- GL_UNSIGNED_INT_8_8_8_8_REV,
- image->data);
+ GL_RGBA, GL_UNSIGNED_BYTE, image->data);
sprintf (buf, "builtin texture (%dx%d)", image->width, image->height);
check_gl_error(buf);
}
sprintf (buf, "builtin texture (%dx%d)", image->width, image->height);
check_gl_error(buf);
}
@@
-157,8
+154,7
@@
setup_file_texture (ModeInfo *mi, char *filename)
Visual *visual = mi->xgwa.visual;
char buf[1024];
Visual *visual = mi->xgwa.visual;
char buf[1024];
- Colormap cmap = mi->xgwa.colormap;
- XImage *image = xpm_file_to_ximage (dpy, visual, cmap, filename);
+ XImage *image = file_to_ximage (dpy, visual, filename);
if (!image) return False;
clear_gl_error();
if (!image) return False;
clear_gl_error();
@@
-166,10
+162,7
@@
setup_file_texture (ModeInfo *mi, char *filename)
glPixelStorei(GL_UNPACK_ROW_LENGTH, image->width);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
image->width, image->height, 0,
glPixelStorei(GL_UNPACK_ROW_LENGTH, image->width);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
image->width, image->height, 0,
- GL_RGBA,
- /* GL_UNSIGNED_BYTE, */
- GL_UNSIGNED_INT_8_8_8_8_REV,
- image->data);
+ GL_RGBA, GL_UNSIGNED_BYTE, image->data);
sprintf (buf, "texture: %.100s (%dx%d)",
filename, image->width, image->height);
check_gl_error(buf);
sprintf (buf, "texture: %.100s (%dx%d)",
filename, image->width, image->height);
check_gl_error(buf);
@@
-197,7
+190,7
@@
setup_texture(ModeInfo * mi)
!strcmp(which_image, "BUILTIN"))
{
BUILTIN:
!strcmp(which_image, "BUILTIN"))
{
BUILTIN:
- setup_
xpm_texture (mi, dymaxionmap_xpm
);
+ setup_
png_texture (mi, dymaxionmap_png, sizeof(dymaxionmap_png)
);
}
else
{
}
else
{
@@
-215,7
+208,7
@@
setup_texture(ModeInfo * mi)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- setup_
xpm_texture (mi, ground
);
+ setup_
png_texture (mi, ground_png, sizeof(ground_png)
);
check_gl_error("texture initialization");
check_gl_error("texture initialization");
@@
-238,12
+231,18
@@
init_stars (ModeInfo *mi)
int max_size = 3;
GLfloat inc = 0.5;
int steps = max_size / inc;
int max_size = 3;
GLfloat inc = 0.5;
int steps = max_size / inc;
+ GLfloat scale = 1;
+
+ if (MI_WIDTH(mi) > 2560) { /* Retina displays */
+ scale *= 2;
+ nstars /= 2;
+ }
gp->starlist = glGenLists(1);
glNewList(gp->starlist, GL_COMPILE);
for (j = 1; j <= steps; j++)
{
gp->starlist = glGenLists(1);
glNewList(gp->starlist, GL_COMPILE);
for (j = 1; j <= steps; j++)
{
- glPointSize(inc * j);
+ glPointSize(inc * j
* scale
);
glBegin (GL_POINTS);
for (i = 0; i < nstars / steps; i++)
{
glBegin (GL_POINTS);
for (i = 0; i < nstars / steps; i++)
{
@@
-281,7
+280,7
@@
reshape_planet (ModeInfo *mi, int width, int height)
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glFrustum(-1.0, 1.0, -h, h, 5.0,
1
00.0);
+ glFrustum(-1.0, 1.0, -h, h, 5.0,
2
00.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -40);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -40);
@@
-770,9
+769,6
@@
planet_handle_event (ModeInfo *mi, XEvent *event)
}
}
-static void free_planet (ModeInfo * mi);
-
-
ENTRYPOINT void
init_planet (ModeInfo * mi)
{
ENTRYPOINT void
init_planet (ModeInfo * mi)
{
@@
-780,7
+776,7
@@
init_planet (ModeInfo * mi)
int screen = MI_SCREEN(mi);
Bool wire = MI_IS_WIREFRAME(mi);
int screen = MI_SCREEN(mi);
Bool wire = MI_IS_WIREFRAME(mi);
- MI_INIT (mi, planets
, free_planet
);
+ MI_INIT (mi, planets);
gp = &planets[screen];
if ((gp->glx_context = init_GL(mi)) != NULL) {
gp = &planets[screen];
if ((gp->glx_context = init_GL(mi)) != NULL) {
@@
-1005,7
+1001,7
@@
draw_planet (ModeInfo * mi)
}
}
-
static
void
+
ENTRYPOINT
void
free_planet (ModeInfo * mi)
{
planetstruct *gp = &planets[MI_SCREEN(mi)];
free_planet (ModeInfo * mi)
{
planetstruct *gp = &planets[MI_SCREEN(mi)];