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
/
blocktube.c
diff --git
a/hacks/glx/blocktube.c
b/hacks/glx/blocktube.c
index 51f2f3db758fd2fdc3472cfb5cb089eca43c76cd..3ff5cdb3d37139269178c4bde0c3f2aa1a124dbe 100644
(file)
--- a/
hacks/glx/blocktube.c
+++ b/
hacks/glx/blocktube.c
@@
-18,8
+18,8
@@
"*showFPS: False \n" \
"*suppressRotationAnimation: True\n" \
"*showFPS: False \n" \
"*suppressRotationAnimation: True\n" \
-# define re
fresh
_blocktube 0
-# define blocktube_handle_event
0
+# define re
lease
_blocktube 0
+# define blocktube_handle_event
xlockmore_no_events
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
@@
-109,8
+109,8
@@
ENTRYPOINT ModeSpecOpt blocktube_opts = {countof(opts), opts, countof(vars), var
#ifdef USE_MODULES
ModStruct blocktube_description =
#ifdef USE_MODULES
ModStruct blocktube_description =
- {"blocktube", "init_blocktube", "draw_blocktube",
"release_blocktube"
,
- "draw_blocktube", "init_blocktube",
(char *)NULL
, &blocktube_opts,
+ {"blocktube", "init_blocktube", "draw_blocktube",
(char *)NULL
,
+ "draw_blocktube", "init_blocktube",
"free_blocktube"
, &blocktube_opts,
40000, 30, 1, 1, 64, 1.0, "",
"A shifting tunnel of reflective blocks", 0, NULL};
#endif /* USE_MODULES */
40000, 30, 1, 1, 64, 1.0, "",
"A shifting tunnel of reflective blocks", 0, NULL};
#endif /* USE_MODULES */
@@
-212,14
+212,7
@@
ENTRYPOINT void init_blocktube (ModeInfo *mi)
blocktube_configuration *lp;
int wire = MI_IS_WIREFRAME(mi);
blocktube_configuration *lp;
int wire = MI_IS_WIREFRAME(mi);
- if (!lps) {
- lps = (blocktube_configuration *)
- calloc (MI_NUM_SCREENS(mi), sizeof (blocktube_configuration));
- if (!lps) {
- fprintf(stderr, "%s: out of memory\n", progname);
- exit(1);
- }
- }
+ MI_INIT(mi, lps);
lp = &lps[MI_SCREEN(mi)];
lp->glx_context = init_GL(mi);
lp = &lps[MI_SCREEN(mi)];
lp->glx_context = init_GL(mi);
@@
-294,30
+287,36
@@
ENTRYPOINT void init_blocktube (ModeInfo *mi)
glFlush();
}
glFlush();
}
-ENTRYPOINT void
releas
e_blocktube (ModeInfo *mi)
+ENTRYPOINT void
fre
e_blocktube (ModeInfo *mi)
{
{
- if (lps) {
- int screen;
- for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
- blocktube_configuration *lp = &lps[screen];
+ blocktube_configuration *lp = &lps[MI_SCREEN(mi)];
# if defined ( I_HAVE_XPM )
# if defined ( I_HAVE_XPM )
- if (lp->envTexture)
- glDeleteTextures(1, &lp->envTexture);
- if (lp->texti)
- XDestroyImage(lp->texti);
-# endif
- }
- free (lps);
- lps = 0;
+ if (lp->glx_context) {
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(lp->glx_context));
+
+ if (lp->envTexture)
+ glDeleteTextures(1, &lp->envTexture);
+ if (lp->texti)
+ XDestroyImage(lp->texti);
}
}
- FreeAllGL(mi);
+# endif
}
ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height)
{
}
ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height)
{
+ blocktube_configuration *lp = &lps[MI_SCREEN(mi)];
GLfloat h = (GLfloat) height / (GLfloat) width;
GLfloat h = (GLfloat) height / (GLfloat) width;
+ int y = 0;
+
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(lp->glx_context));
+
+ if (width > height * 5) { /* tiny window: show middle */
+ height = width;
+ y = -height/2;
+ h = height / (GLfloat) width;
+ }
- glViewport(0,
0
, (GLint) width, (GLint) height);
+ glViewport(0,
y
, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 1/h, 1.0, 100.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 1/h, 1.0, 100.0);