X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fglschool.c;h=eb522a031b2b0b7e9f256c2b1a1e5001d25974f6;hb=6f5482d73adb0165c0130bb47d852644ab0c4869;hp=ecaa6aadbdac9ffe42f8b688ee063c2efd325818;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/glx/glschool.c b/hacks/glx/glschool.c index ecaa6aad..eb522a03 100644 --- a/hacks/glx/glschool.c +++ b/hacks/glx/glschool.c @@ -23,6 +23,23 @@ #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) +#define DEF_NFISH "100" +#define DEF_FOG "False" +#define DEF_DRAWBBOX "True" +#define DEF_DRAWGOAL "False" +#define DEF_GOALCHGF "50" +#define DEF_MAXVEL "7.0" +#define DEF_MINVEL "1.0" +#define DEF_ACCLIMIT "8.0" +#define DEF_DISTEXP "2.2" +#define DEF_AVOIDFACT "1.5" +#define DEF_MATCHFACT "0.15" +#define DEF_CENTERFACT "0.1" +#define DEF_TARGETFACT "80" +#define DEF_MINRADIUS "30.0" +#define DEF_MOMENTUM "0.9" +#define DEF_DISTCOMP "10.0" + static int NFish; static Bool DoFog; static Bool DoDrawBBox; @@ -63,22 +80,22 @@ static XrmOptionDescRec opts[] = { }; static argtype vars[] = { - {&NFish, "nfish", "NFish", "100", t_Int}, - {&DoFog, "fog", "DoFog", "False", t_Bool}, - {&DoDrawBBox, "drawbbox", "DoDrawBBox", "True", t_Bool}, - {&DoDrawGoal, "drawgoal", "DoDrawGoal", "False", t_Bool}, - {&GoalChgFreq, "goalchgf", "GoalChgFreq", "50", t_Int}, - {&MaxVel, "maxvel", "MaxVel", "7.0", t_Float}, - {&MinVel, "minvel", "MinVel", "1.0", t_Float}, - {&AccLimit, "acclimit", "AccLimit", "8.0", t_Float}, - {&DistExp, "distexp", "DistExp", "2.2", t_Float}, - {&AvoidFact, "avoidfact", "AvoidFact", "1.5", t_Float}, - {&MatchFact, "matchfact", "MatchFact", "0.15", t_Float}, - {&CenterFact, "centerfact", "CenterFact", "0.1", t_Float}, - {&TargetFact, "targetfact", "TargetFact", "80", t_Float}, - {&MinRadius, "minradius", "MinRadius", "30.0", t_Float}, - {&Momentum, "momentum", "Momentum", "0.9", t_Float}, - {&DistComp, "distcomp", "DistComp", "10.0", t_Float}, + {&NFish, "nfish", "NFish", DEF_NFISH, t_Int}, + {&DoFog, "fog", "DoFog", DEF_FOG, t_Bool}, + {&DoDrawBBox, "drawbbox", "DoDrawBBox", DEF_DRAWBBOX, t_Bool}, + {&DoDrawGoal, "drawgoal", "DoDrawGoal", DEF_DRAWGOAL, t_Bool}, + {&GoalChgFreq, "goalchgf", "GoalChgFreq", DEF_GOALCHGF, t_Int}, + {&MaxVel, "maxvel", "MaxVel", DEF_MAXVEL, t_Float}, + {&MinVel, "minvel", "MinVel", DEF_MINVEL, t_Float}, + {&AccLimit, "acclimit", "AccLimit", DEF_ACCLIMIT, t_Float}, + {&DistExp, "distexp", "DistExp", DEF_DISTEXP, t_Float}, + {&AvoidFact, "avoidfact", "AvoidFact", DEF_AVOIDFACT, t_Float}, + {&MatchFact, "matchfact", "MatchFact", DEF_MATCHFACT, t_Float}, + {&CenterFact, "centerfact", "CenterFact", DEF_CENTERFACT, t_Float}, + {&TargetFact, "targetfact", "TargetFact", DEF_TARGETFACT, t_Float}, + {&MinRadius, "minradius", "MinRadius", DEF_MINRADIUS, t_Float}, + {&Momentum, "momentum", "Momentum", DEF_MOMENTUM, t_Float}, + {&DistComp, "distcomp", "DistComp", DEF_DISTCOMP, t_Float}, }; ENTRYPOINT ModeSpecOpt glschool_opts = {countof(opts), opts, countof(vars), vars, NULL}; @@ -92,6 +109,7 @@ typedef struct { GLuint bboxList; GLuint goalList; GLuint fishList; + int fish_polys, box_polys; XColor *colors; School *school; GLXContext *context; @@ -108,11 +126,12 @@ reshape_glschool(ModeInfo *mi, int width, int height) glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sc->context)); if (sc->school != (School *)0) { - setBBox(sc->school, -aspect*160, aspect*160, -130, 130, -450, -50.0); + glschool_setBBox(sc->school, -aspect*160, aspect*160, -130, 130, -450, -50.0); glDeleteLists(sc->bboxList, 1); - createBBoxList(&SCHOOL_BBOX(sc->school), &sc->bboxList, wire); + glschool_createBBoxList(&SCHOOL_BBOX(sc->school), + &sc->bboxList, wire); } - reshape(width, height); + glschool_reshape(width, height); } ENTRYPOINT void @@ -144,7 +163,7 @@ init_glschool(ModeInfo *mi) sc->colors, &sc->nColors, False, 0, False); - sc->school = initSchool(NFish, AccLimit, MaxVel, MinVel, DistExp, Momentum, + sc->school = glschool_initSchool(NFish, AccLimit, MaxVel, MinVel, DistExp, Momentum, MinRadius, AvoidFact, MatchFact, CenterFact, TargetFact, DistComp); if (sc->school == (School *)0) { @@ -154,10 +173,12 @@ init_glschool(ModeInfo *mi) reshape_glschool(mi, width, height); - initGLEnv(DoFog); - initFishes(sc->school); - createDrawLists(&SCHOOL_BBOX(sc->school), &sc->bboxList, &sc->goalList, &sc->fishList, wire); - computeAccelerations(sc->school); + glschool_initGLEnv(DoFog); + glschool_initFishes(sc->school); + glschool_createDrawLists(&SCHOOL_BBOX(sc->school), + &sc->bboxList, &sc->goalList, &sc->fishList, + &sc->fish_polys, &sc->box_polys, wire); + glschool_computeAccelerations(sc->school); } ENTRYPOINT void @@ -174,16 +195,22 @@ draw_glschool(ModeInfo *mi) glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sc->context)); + mi->polygon_count = 0; + if ((sc->goalCounter % GoalChgFreq) == 0) - newGoal(sc->school); + glschool_newGoal(sc->school); sc->goalCounter++; sc->rotCounter++; sc->rotCounter = (sc->rotCounter%360); - applyMovements(sc->school); - drawSchool(sc->colors, sc->school, sc->bboxList, sc->goalList, sc->fishList, sc->rotCounter, sc->drawGoal, sc->drawBBox); - computeAccelerations(sc->school); + glschool_applyMovements(sc->school); + glschool_drawSchool(sc->colors, sc->school, sc->bboxList, + sc->goalList, sc->fishList, sc->rotCounter, + sc->drawGoal, sc->drawBBox, + sc->fish_polys, sc->box_polys, + &mi->polygon_count); + glschool_computeAccelerations(sc->school); if (mi->fps_p) do_fps(mi);