Exemple #1
0
ENTRYPOINT void
reshape_glschool(ModeInfo *mi, int width, int height)
{
	Bool					wire = MI_IS_WIREFRAME(mi);
	double					aspect = (double)width/(double)height;
	glschool_configuration	*sc = &scs[MI_SCREEN(mi)];

	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);
		glDeleteLists(sc->bboxList, 1);
		createBBoxList(&SCHOOL_BBOX(sc->school), &sc->bboxList, wire);
	}
	reshape(width, height);
}
ENTRYPOINT void
init_glschool(ModeInfo *mi)
{
	int						width = MI_WIDTH(mi);
	int						height = MI_HEIGHT(mi);
	Bool					wire = MI_IS_WIREFRAME(mi);
	glschool_configuration	*sc;

	if (!scs) {
		scs = (glschool_configuration *)calloc(MI_NUM_SCREENS(mi), sizeof(glschool_configuration));
		if (!scs) {
			perror("init_glschool: ");
			exit(1);
		}
	}
	sc = &scs[MI_SCREEN(mi)];

	sc->drawGoal = DoDrawGoal;
	sc->drawBBox = DoDrawBBox;

	sc->nColors = 360;
	sc->context = init_GL(mi);
	sc->colors = (XColor *)calloc(sc->nColors, sizeof(XColor));
	make_color_ramp(0, 0, 0,
					0.0, 1.0, 1.0,
					359.0, 1.0, 1.0,
					sc->colors, &sc->nColors,
					False, 0, False);

	sc->school = glschool_initSchool(NFish, AccLimit, MaxVel, MinVel, DistExp, Momentum,
							MinRadius, AvoidFact, MatchFact, CenterFact, TargetFact,
							DistComp);
	if (sc->school == (School *)0) {
		fprintf(stderr, "couldn't initialize TheSchool, exiting\n");
		exit(1);
	}

	reshape_glschool(mi, width, height);

	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);
}