projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
http://slackware.bholcomb.com/slackware/slackware-11.0/source/xap/xscreensaver/xscree...
[xscreensaver]
/
hacks
/
glx
/
superquadrics.c
diff --git
a/hacks/glx/superquadrics.c
b/hacks/glx/superquadrics.c
index 022392c114e64bb7bd43e861b878aa7babb06f64..68dacee47dc8d396225da5a48d27520a8a11682f 100644
(file)
--- a/
hacks/glx/superquadrics.c
+++ b/
hacks/glx/superquadrics.c
@@
-70,23
+70,13
@@
static const char sccsid[] = "@(#)superquadrics.c 4.07 97/11/24 xlockmore";
* Ed Mackey
*/
* Ed Mackey
*/
-/*-
- * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock.
- * otherwise caddr_t is not defined correctly
- */
-
-#include <X11/Intrinsic.h>
-
#ifdef STANDALONE
#ifdef STANDALONE
-# define PROGCLASS "Superquadrics"
-# define HACK_INIT init_superquadrics
-# define HACK_DRAW draw_superquadrics
-# define superquadrics_opts xlockmore_opts
# define DEFAULTS "*delay: 40000 \n" \
"*count: 25 \n" \
"*cycles: 40 \n" \
"*showFPS: False \n" \
"*wireframe: False \n"
# define DEFAULTS "*delay: 40000 \n" \
"*count: 25 \n" \
"*cycles: 40 \n" \
"*showFPS: False \n" \
"*wireframe: False \n"
+# define superquadrics_handle_event 0
# include "xlockmore.h" /* from the xscreensaver distribution */
#else /* !STANDALONE */
# include "xlock.h" /* from the xlockmore distribution */
# include "xlockmore.h" /* from the xscreensaver distribution */
#else /* !STANDALONE */
# include "xlock.h" /* from the xlockmore distribution */
@@
-107,7
+97,7
@@
static float spinspeed;
static XrmOptionDescRec opts[] =
{
static XrmOptionDescRec opts[] =
{
- {"-spinspeed", ".superquadrics.spinspeed", XrmoptionSepArg,
(caddr_t) NULL
}
+ {"-spinspeed", ".superquadrics.spinspeed", XrmoptionSepArg,
0
}
};
static argtype vars[] =
{
};
static argtype vars[] =
{
@@
-118,7
+108,7
@@
static OptionStruct desc[] =
{"-spinspeed num", "speed of rotation, in degrees per frame"}
};
{"-spinspeed num", "speed of rotation, in degrees per frame"}
};
-ModeSpecOpt superquadrics_opts =
+
ENTRYPOINT
ModeSpecOpt superquadrics_opts =
{sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
#ifdef USE_MODULES
{sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
#ifdef USE_MODULES
@@
-130,8
+120,6
@@
ModStruct superquadrics_description =
#endif
#endif
-#include <GL/glu.h>
-
#define MaxRes 50
#define MinRes 5
#define MaxRes 50
#define MinRes 5
@@
-157,6
+145,10
@@
typedef struct {
double xExponent, yExponent, Mode;
int resolution;
state now, later;
double xExponent, yExponent, Mode;
int resolution;
state now, later;
+
+ int pats[4][4];
+ int cullmode;
+
} superquadricsstruct;
static superquadricsstruct *superquadrics = NULL;
} superquadricsstruct;
static superquadricsstruct *superquadrics = NULL;
@@
-228,14
+220,6
@@
Cosine(double x, double e)
static void
MakeUpStuff(int allstuff, superquadricsstruct * sp)
{
static void
MakeUpStuff(int allstuff, superquadricsstruct * sp)
{
- static int pats[4][4] =
- {
- {0, 0, 0, 0},
- {0, 1, 0, 1},
- {0, 0, 1, 1},
- {0, 1, 1, 0}
- };
-
int dostuff;
int t, pat;
GLfloat r, g, b, r2, g2, b2;
int dostuff;
int t, pat;
GLfloat r, g, b, r2, g2, b2;
@@
-289,9
+273,9
@@
MakeUpStuff(int allstuff, superquadricsstruct * sp)
pat = myrand(4);
for (t = 0; t < 4; ++t) {
pat = myrand(4);
for (t = 0; t < 4; ++t) {
- sp->later.r[t] = pats[pat][t] ? r : r2;
- sp->later.g[t] = pats[pat][t] ? g : g2;
- sp->later.b[t] = pats[pat][t] ? b : b2;
+ sp->later.r[t] =
sp->
pats[pat][t] ? r : r2;
+ sp->later.g[t] =
sp->
pats[pat][t] ? g : g2;
+ sp->later.b[t] =
sp->
pats[pat][t] ? b : b2;
}
}
if (dostuff & 8) {
}
}
if (dostuff & 8) {
@@
-460,28
+444,27
@@
DoneScale(superquadricsstruct * sp)
static void
SetCull(int init, superquadricsstruct * sp)
{
static void
SetCull(int init, superquadricsstruct * sp)
{
- static int cullmode;
-
if (init) {
if (init) {
- cullmode = 0;
+ glDisable(GL_CULL_FACE);
+ sp->cullmode = 0;
return;
}
if (sp->Mode < 1.0001) {
return;
}
if (sp->Mode < 1.0001) {
- if (cullmode != 1) {
+ if (
sp->
cullmode != 1) {
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
- cullmode = 1;
+
sp->
cullmode = 1;
}
} else if (sp->Mode > 2.9999) {
}
} else if (sp->Mode > 2.9999) {
- if (cullmode != 2) {
+ if (
sp->
cullmode != 2) {
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
- cullmode = 2;
+
sp->
cullmode = 2;
}
} else {
}
} else {
- if (cullmode) {
+ if (
sp->
cullmode) {
glDisable(GL_CULL_FACE);
glDisable(GL_CULL_FACE);
- cullmode = 0;
+
sp->
cullmode = 0;
}
}
}
}
}
}
@@
-567,7
+550,7
@@
DisplaySuperquadrics(superquadricsstruct * sp)
if (sp->viewcount < 1) {
sp->viewcount = sp->viewwait;
if (sp->viewcount < 1) {
sp->viewcount = sp->viewwait;
- ReshapeSuperquadrics(-1, -1);
+/* ReshapeSuperquadrics(-1, -1);*/
}
glPushMatrix();
glTranslatef(0.0, 0.0, -((GLfloat) (sp->dist) / 16.0) - (sp->Mode * 3.0 - 1.0)); /* viewing transform */
}
glPushMatrix();
glTranslatef(0.0, 0.0, -((GLfloat) (sp->dist) / 16.0) - (sp->Mode * 3.0 - 1.0)); /* viewing transform */
@@
-595,16
+578,9
@@
NextSuperquadricDisplay(superquadricsstruct * sp)
static void
ReshapeSuperquadrics(int w, int h)
{
static void
ReshapeSuperquadrics(int w, int h)
{
- static int last_w = 0, last_h = 0;
+#if 0
int maxsize, cursize;
int maxsize, cursize;
- if (w < 0) {
- w = last_w;
- h = last_h;
- } else {
- last_w = w;
- last_h = h;
- }
maxsize = (w < h) ? w : h;
if (maxsize <= MINSIZE) {
cursize = maxsize;
maxsize = (w < h) ? w : h;
if (maxsize <= MINSIZE) {
cursize = maxsize;
@@
-617,9
+593,13
@@
ReshapeSuperquadrics(int w, int h)
} else {
glViewport(0, 0, w, h);
}
} else {
glViewport(0, 0, w, h);
}
+#else
+ glViewport(0, 0, w, h);
+#endif
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gluPerspective(
30
.0, (GLfloat) w / (GLfloat) h, 0.1, 200.0);
+ gluPerspective(
15
.0, (GLfloat) w / (GLfloat) h, 0.1, 200.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
@@
-640,8
+620,12
@@
InitSuperquadrics(int wfmode, int snorm, int res, int count, float speed, superq
int t;
int t;
- for (t = 0; t < 4; ++t)
+ for (t = 0; t < 4; ++t) {
+ sp->curmat[t][0] = 0.0;
+ sp->curmat[t][1] = 0.0;
+ sp->curmat[t][2] = 0.0;
sp->curmat[t][3] = 1.0;
sp->curmat[t][3] = 1.0;
+ }
sp->rotx = 35.0;
sp->roty = 0.0;
sp->rotx = 35.0;
sp->roty = 0.0;
@@
-654,6
+638,7
@@
InitSuperquadrics(int wfmode, int snorm, int res, int count, float speed, superq
sp->maxwait = sp->maxcount >> 1;
SetCull(1, sp);
sp->maxwait = sp->maxcount >> 1;
SetCull(1, sp);
+ sp->mono = 0;
sp->spinspeed = speed;
sp->viewcount = sp->viewwait = (sp->maxcount < 2) ? 1 : (sp->maxcount << 3);
sp->spinspeed = speed;
sp->viewcount = sp->viewwait = (sp->maxcount < 2) ? 1 : (sp->maxcount << 3);
@@
-671,6
+656,9
@@
InitSuperquadrics(int wfmode, int snorm, int res, int count, float speed, superq
if (snorm)
sp->shownorms = 1;
if (snorm)
sp->shownorms = 1;
+ glClearColor(0.0,0.0,0.0,1.0);
+ glClearDepth(1.0);
+
if (sp->wireframe) {
glShadeModel(GL_FLAT);
glDisable(GL_LIGHTING);
if (sp->wireframe) {
glShadeModel(GL_FLAT);
glDisable(GL_LIGHTING);
@@
-707,7
+695,7
@@
InitSuperquadrics(int wfmode, int snorm, int res, int count, float speed, superq
/* End of superquadrics main functions */
/* End of superquadrics main functions */
-void
+
ENTRYPOINT
void
init_superquadrics(ModeInfo * mi)
{
Display *display = MI_DISPLAY(mi);
init_superquadrics(ModeInfo * mi)
{
Display *display = MI_DISPLAY(mi);
@@
-724,6
+712,19
@@
init_superquadrics(ModeInfo * mi)
sp = &superquadrics[screen];
sp->mono = (MI_IS_MONO(mi) ? 1 : 0);
sp = &superquadrics[screen];
sp->mono = (MI_IS_MONO(mi) ? 1 : 0);
+ sp->pats[1][1] = 1;
+ sp->pats[1][3] = 1;
+ sp->pats[2][2] = 1;
+ sp->pats[2][3] = 1;
+ sp->pats[3][1] = 1;
+ sp->pats[3][2] = 1;
+
+/* {0, 0, 0, 0},
+ {0, 1, 0, 1},
+ {0, 0, 1, 1},
+ {0, 1, 1, 0}
+ */
+
if ((sp->glx_context = init_GL(mi)) != NULL) {
InitSuperquadrics(MI_IS_WIREFRAME(mi), 0,
if ((sp->glx_context = init_GL(mi)) != NULL) {
InitSuperquadrics(MI_IS_WIREFRAME(mi), 0,
@@
-738,7
+739,7
@@
init_superquadrics(ModeInfo * mi)
}
}
}
}
-void
+
ENTRYPOINT
void
draw_superquadrics(ModeInfo * mi)
{
superquadricsstruct *sp = &superquadrics[MI_SCREEN(mi)];
draw_superquadrics(ModeInfo * mi)
{
superquadricsstruct *sp = &superquadrics[MI_SCREEN(mi)];
@@
-757,13
+758,19
@@
draw_superquadrics(ModeInfo * mi)
glXSwapBuffers(display, window);
}
glXSwapBuffers(display, window);
}
-void
+
ENTRYPOINT
void
refresh_superquadrics(ModeInfo * mi)
{
/* Nothing happens here */
}
refresh_superquadrics(ModeInfo * mi)
{
/* Nothing happens here */
}
-void
+ENTRYPOINT void
+reshape_superquadrics(ModeInfo * mi, int width, int height)
+{
+ ReshapeSuperquadrics(MI_WIDTH(mi), MI_HEIGHT(mi));
+}
+
+ENTRYPOINT void
release_superquadrics(ModeInfo * mi)
{
if (superquadrics != NULL) {
release_superquadrics(ModeInfo * mi)
{
if (superquadrics != NULL) {
@@
-777,3
+784,5
@@
release_superquadrics(ModeInfo * mi)
#endif
/* End of superquadrics.c */
#endif
/* End of superquadrics.c */
+
+XSCREENSAVER_MODULE ("Superquadrics", superquadrics)