コード例 #1
0
ファイル: test6.c プロジェクト: kennib/openpyscad
static void renderchar(double x, double y, char *c[])
{
	int i;
	double maxx;
	double px, py;
	char *p;
	
	onion();

	py = PIXELHEIGHT * 7;
	px = 0; 

	xlate(x, y, 0);
	for (i = 0; c[i] != NULL; i++) {
		px = 0;
		for (p = c[i]; *p; p++) {
			xlate(px, py - (PIXELHEIGHT), 0);
				xlate(0, -PIXELHEIGHT / 2.0 + 1, 0);
					square(PIXELWIDTH * 0.25, 1, 1);
				endxlate();
				if (*p == '#')
					square(PIXELWIDTH * 0.5, PIXELHEIGHT * 0.6, 1);
			endxlate();
			px += PIXELWIDTH;
		}
		py -= PIXELHEIGHT;
	}
	endxlate();
	endonion();
} 
コード例 #2
0
ファイル: castle.c プロジェクト: kennib/openpyscad
void gothic_arch(double width, double height, double depth)
{
	double radius;
	double archheight;
	double cubeheight;

	if (height < width * 2.0)
		width = height / 2.0;

	radius = 5.0 * width / 4.0; 
	archheight = width;
	cubeheight = height - archheight;

	xlate(-depth / 2.0, 0, cubeheight);
	onion();
	intersection();
	xlate(0, 3.0 * width / 4.0, 0);
	rotate(90, 0, 1, 0);
	cylinder(depth, radius, radius);
	endrotate();
	endxlate();
	xlate(0, -3.0 * width / 4.0, 0);
	rotate(90, 0, 1, 0);
	cylinder(depth, radius, radius);
	endrotate();
	endxlate();
	endintersection();

	xlate(depth / 2.0, 0, -cubeheight / 2.0);
	cube(depth, width, cubeheight, 1);
	endxlate();
	endonion();
	endxlate();
}
コード例 #3
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void arched_opening(double height, double width, double depth)
{
	/* make the windows 10x too big, then scale 10x down.  This
	   prevents small windows from having bad artifcacts due
	   to openscad's weird curve rendering.  Judicious tweaking of
	   $fa, $fn, could probably accomplish the same thing, but
	   this seemed easier to me.
	 */
	height *= 10.0;
	width *= 10.0;
	depth *= 10.0;
	scale(0.1, 0.1, 0.1);


	xlate(-width / 2.0, -depth / 2.0, -height / 2.0);
	onion();
	cube(width, depth, height - width / 2.0, 0);
	xlate(width / 2.0, depth, height - width / 2.0);
	rotate(90, 1, 0, 0);
	cylinder(depth, width / 2.0, width / 2.0); 
	endrotate();
	endxlate();
	endonion();
	endxlate();
	endscale();
}
コード例 #4
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void wall(double x1, double y1, double x2, double y2, double thickness, double height)
{
	double angle;
	double dist;
	double clen, ch, c;

	height = perturb(height, 0.1);
	angle = atan2(y2 - y1, x2 - x1);
	printf("/* %lf, %lf, angle = %d */\n", (y2 - y1), (x2 - x1), (int) (angle * 180.0 / M_PI));
	dist = hypot(x2 - x1, y2 - y1);
	xlate(x1, y1, 0);
	rotate(angle * 180 / M_PI, 0, 0, 1);
	/*diff(); */
	cube(dist, thickness, height, 0);
	c = 0.0;
	ch = thickness;
	clen = thickness *1.5;
	while (c < dist) {
		xlate(c, 0, height - thickness);
		cube(clen, ch, ch * 2, 0);
		endxlate();
		c += clen + thickness;
	}
	/* enddiff(); */
	endrotate();
	endxlate();
}
コード例 #5
0
ファイル: castle.c プロジェクト: kennib/openpyscad
/* width is y axis, length is x axis */
static void english_house(double width, double length, double height, double peak)
{
	double wall_thickness = width * 0.1;

	if (wall_thickness < 5.0)
		wall_thickness = 5.0;

	diff();
	onion();
	gothic_hall(length * 1.05, width, height, 0, 1, wall_thickness, 0);
	xlate(-length / 2.05, 0, 0);
	english_house_end(width, height * 1.3, wall_thickness, peak, peak * 1.2); 
	endxlate();
	xlate(length / 2.05, 0, 0);
	english_house_end(width, height * 1.3, wall_thickness, peak, peak * 1.2); 
	endxlate();

	xlate(0, 0, height * 1.20);
	rotate(90, 0, 0, 1);
	gabled_roof(length, width, peak);
	endrotate();
	endxlate();
	endonion();
	xlate(0, 0, height * 0.5);
	gothic_arch_array(length, width * 2, height * 0.60 , length * 0.1, 4);
	endxlate();
	enddiff();
}
コード例 #6
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void recursive_keep(double x, double y, double width, double length, double height, int level)
{
	int i;

	if (irandomn(1000) < 300) {
		xlate(x, y, 0);
		keep_block(width, length, height);
		endxlate();
		xlate(0, 0, height);
		recursive_keep(x, y, width, length, perturb(height, 0.2), level);
		endxlate();
		return;
	}

	if (level == 0 || irandomn(1000) < 300) {
		xlate(x, y, 0);
			xkeep_topper(width, length, height, 1);
		endxlate();
		return;
	}

	i = irandomn(100);

	xlate(x, y, 0);
	keep_block(width, length, height);
	endxlate();
	xlate(0, 0, height);
	if ((level % 2) == 0) {
		double offset, nw1, nw2, x1, x2;
		offset = randomn(width * 0.2) - (0.1 * width);
		offset = 0.0;
		nw1 = (width / 2.0) + offset;
		nw2 = (width - nw1); 
		x1 = x - offset / 2.0 -0.25 * width;
		x2 = x + 0.25 * width  - offset / 2.0;
		printf("/* x/y = %lf,%lf, o=%lf nw1 = %lf, nw2 = %lf, x1 = %lf, x2 = %lf */\n",
			x, y, offset, nw1, nw2, x1, x2);
		recursive_keep(x1, y, nw1, length, perturb(height, 0.2), level - 1);
		recursive_keep(x2, y, nw2, length, perturb(height, 0.2), level - 1);
	} else {
		double offset, nl1, nl2, y1, y2;
		offset = randomn(length * 0.2) - (0.1 * length);
		offset = 0.0;
		nl1 = (length / 2.0) + offset;
		nl2 = (length - nl1);
		y1 = y - offset / 2.0 - 0.25 * length;
		y2 = y + 0.25 * length - offset / 2.0;
		printf("/* x/y = %lf,%lf, o=%lf nl1 = %lf, nl2 = %lf, y1 = %lf, y2 = %lf */\n",
			x, y, offset, nl1, nl2, y1, y2);
		recursive_keep(x, y1, width, nl1, perturb(height, 0.2), level - 1);
		recursive_keep(x, y2, width, nl2, perturb(height, 0.2), level - 1);
	}
	endxlate();
}
コード例 #7
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void buttress_array_pair(double width, double length, double height, double angle,
				double spacing, int count, double span_between_arrays)
{
	xlate(0, -span_between_arrays / 2.0, 0);
	buttress_array(width, length, height, angle, spacing, count);
	endxlate();
	rotate(180, 0, 0, 1);
	xlate(0, -span_between_arrays / 2.0, 0);
	buttress_array(width, length, height, angle, spacing, count);
	endxlate();
	endrotate();
}
コード例 #8
0
ファイル: test6.c プロジェクト: kennib/openpyscad
int main(int argc, char *argv[])
{
	xlate(0, 2.5 * PIXELHEIGHT, 0);
	renderstring(0, 0, STEVE);
	endxlate();
#if 0
	cube(1.4, 25.4, 25.4, 0);
	xlate(5.5 * 25.4, 0, 0);
		cube(1, 25.4, 25.4, 0);
	endxlate();
#endif
	return 0;
}
コード例 #9
0
ファイル: test5.c プロジェクト: kennib/openpyscad
void tower(double r, double h)
{
	int i;
	double h1, r1, angle, nx, ny, nz;

	onion();
		diff();
			cylinder(h, r, r * 0.85);
			cylinder(h, r * 0.85, r * 0.75);
		enddiff();

		xlate(0, 0, h * 0.95);
		diff();
			onion();
			cylinder(h * 0.15, r * 0.85, r * 1.25); 
			xlate(0, 0, h * 0.12); 
				diff();
					cylinder(h * 0.15, r * 1.25, r * 1.25); 
					cylinder(h * 0.15 + 1, r * 0.95, r * 0.95);
				enddiff();
			endxlate();
			endonion();
			xlate(0, 0, 0.25 * h);
				crenelation(h, r);
			endxlate();
		enddiff();
		endxlate();

		for (i = 0; i < 5; i++) {
			angle = (360.0 * rand()) / RAND_MAX * 3.1415927 / 180.0;
			nx = cos(angle) * r * 0.85;
			ny = sin(angle) * r * 0.85;
			nz = 0.25 * h + (percent(55.0) * h);
			r1 = percent(40.0) * r;
			h1 = percent(50.0) * h;

			if (r1 < 5)
				continue;
			if (h1 < 20)
				continue;
			xlate(nx, ny, nz);
				tower(r1, h1);
			endxlate();
		}
		xlate(0, 0, -h / 5.0);
			cylinder(h / 5.0, r * 0.1, r);
		endxlate();
	endonion();
}
コード例 #10
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void pointy_tower(double x, double y, double r, double h, int flying, double fa)
{
	double pointiness;
	pointiness = perturbup(1.4, 0.5);
	int extra_pointy;

	/* prevent > 45 degree overhangs to maintain 3d-printability */
	if (r > h * 0.20)
		flying = 0;

	extra_pointy = (r < h * 0.30 && irandomn(100) < 40);
	xlate(x, y, 0);
	/* xlate(0, 0, h * 0.8); */

	diff();
	onion();
	if (flying) {
		angular_cylinder(h * 0.75, 0.15 * r, 0.15 * r, fa);
		xlate(0, 0, h * 0.5);
		angular_cylinder(h * 0.25, 0.10 * r, r * 1.2, fa);
		xlate(0, 0, h * 0.25);
		angular_cylinder(1.6 * r, 1.2 * r, r * 1.2, fa);
		xlate(0, 0, r * 1.6);
		angular_cylinder(pointiness * r, 1.2 * r, 0, fa);
		if (extra_pointy)
			angular_cylinder(pointiness * 2 * r, 0.6 * r, 0, fa);
	} else {
		angular_cylinder(h, r, 0.80 * r, fa);
		xlate(0, 0, h - 0.6 * r);
		angular_cylinder(0.6 * r, 0.81 * r, r * 1.2, fa);
		xlate(0, 0, r * 0.6);
		angular_cylinder(0.6 * r, 1.2 * r, r * 1.2, fa);
		xlate(0, 0, r * 0.6);
		angular_cylinder(pointiness * r, 1.2 * r, 0, fa);
		if (extra_pointy)
			angular_cylinder(pointiness * 2 * r, 0.6 * r, 0, fa);
	}
	endxlate();
	endxlate();
	endxlate();
	endonion();
	if (!flying) {
		add_windows(r, h);
	}
	if (!flying)
		xlate(0, 0, h + 3);
	else
		xlate(0, 0, h * 0.85);
	crenelation(r * 1.2, r * 2);
	endxlate();
	enddiff();
	endxlate();
}
コード例 #11
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void crenelated_rectangle(double width, double length,
				double height, double crenheight, double wall_thickness)
{
	double spacing = wall_thickness * 2;

	diff();
	xlate(0, 0, height / 2.0);
	diff();
	cube(width, length, height, 1);
	cube(width - 2 * wall_thickness, length - 2 * wall_thickness, height + wall_thickness, 1);
	enddiff();
	endxlate();
	xlate(0, 0, height - crenheight * 0.95);
	crenelation_matrix(length, width, crenheight, wall_thickness);
	endxlate();
	enddiff();
}
コード例 #12
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void gothic_hall(double length, double width, double height,
	int larches, int warches, double border_thickness, int with_roof)
{
	diff();
	xlate(0, 0, (height * 1.05) / 2.0 + border_thickness);
	cube(length * 0.97, width * 0.97, height * 1.05 + border_thickness * 2.0, 1);
	endxlate();
	xlate(0, 0, 1.5 * border_thickness);
	gothic_matrix(length, width, height, larches, warches, border_thickness);
	endxlate();
	enddiff();
	if (with_roof) {
		xlate(0, 0, height * 1.05 + border_thickness * 2.0);
		fancy_roof(width, length, height * 2.0);
		endxlate();
	}
}
コード例 #13
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void keep(double width, double length)
{
	double fheight = hypot(width, length) * 0.7;

	keep_foundation(width, length, fheight);
	xlate(0, 0, fheight);
	keep_topper(width, length, fheight);
	endxlate();
}
コード例 #14
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void inverted_buttressed_foundation(double width, double length,
					double height, double buttress_angle,
					double buttress_interval)
{
	xlate(0, 0, height);
	rotate(180, 1, 0, 0);
	buttressed_foundation(width, length, height, buttress_angle, buttress_interval);
	endrotate();
	endxlate();
}
コード例 #15
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void english_house_end(double width, double wall_height, double wall_thickness,
			double peak_height, double chimney_height)
{
	rotate(90, 0, 0, 1);
	onion();
	xlate(0, 0, wall_height / 2.0);
	cube(width, wall_thickness, wall_height, 1);
	endxlate();

	xlate(0, 0, wall_height * 0.999);
	gabled_roof(wall_thickness, width, peak_height);
	endxlate();

	xlate(0, 0, (wall_height + chimney_height) / 2.0);
	cube(width * 0.20, wall_thickness, wall_height + chimney_height, 1);
	endxlate();
	endonion();
	endrotate();
}
コード例 #16
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void buttress(double width, double length, double height , double angle)
{
	xlate(0, 0, height / 2.0);
	intersection();
	cube(length * 2, width * 2, height, 1);
	rotate(angle, 0, 1, 0);
	cube(length, width, height * 2, 1);
	endrotate();
	endintersection();
	endxlate();
}
コード例 #17
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void keep_block(double width, double length, double height)
{
	xlate(0, 0, height / 2.0);
	diff();
	cube(width, length, height, 1);
	keep_block_windows(width, length, height);
	rotate(90, 0, 0, 1);
	keep_block_windows(length, width, height);
	endrotate();
	enddiff();
	endxlate();
}
コード例 #18
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void crenelation_array(double width, double length, double height, double thickness, int n)
{
	int i;
	double x;
	double spacing;

	spacing = (width - thickness * 2) / (double) n;

	printf("/* n = %d */\n", n);
	x = -(spacing * (n - 1)) / 2.0;

	xlate(0, 0, height / 2.0);
	for (i = 0; i < n; i++) {
		xlate(x, 0, 0);
		rotate(90, 0, 0, 1);
		cube(length * 1.1, thickness, height, 1);
		endrotate();
		endxlate();
		x += spacing;
	}
	endxlate();
}
コード例 #19
0
ファイル: castle.c プロジェクト: kennib/openpyscad
/* width is yaxis, length is xaxis, h=zaxis, angle 0 = vertical, degrees */
static void buttressed_foundation(double width, double length,
					double height, double buttress_angle,
					double buttress_interval)
{
	onion();
	xlate(0, 0, height / 2.0);
	cube(length, width, height, 1);
	endxlate();
	buttress_array_pair(length * 0.10, width * 0.2, height, buttress_angle,
				(length / 5.0) * 0.9, 5, width * 0.85);
	rotate(90, 0, 0, 1);
	buttress_array_pair(width * 0.05, length * 0.2, height, buttress_angle,
				(width / 5.0) * 0.9, 5, length * 0.85);
	endrotate();
	endonion();
}
コード例 #20
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void angular_tower(double x, double y, double r, double h, int flying, double fa)
{
	xlate(x, y, 0);

	/* prevent > 45 degree overhangs to maintain 3d-printability */
	if (r > h * 0.20)
		flying = 0;

	if (!flying)
		diff();
	onion();
	if (flying) {
		angular_cylinder(h * 0.75, r * 0.15, 0.15 * r, fa);
		xlate(0, 0, h * 0.50);
		angular_cylinder(h * 0.25, 0.10 * r, r * 1.2, fa);
		xlate(0, 0, h * 0.25);
		diff();
		angular_cylinder(1.6 * r, 1.2 * r, r * 1.2, fa);
		xlate(0, 0, 0.80 * r);
		angular_cylinder(1.00 * r, 1.0 * r, r * 1.0, fa);
		xlate(0, 0, 0.7 * r);
		crenelation(2.3 * r, r * 2.0);
		endxlate();
	} else {
		angular_cylinder(h, r, 0.80 * r, fa);
		xlate(0, 0, h - 0.6 * r);
		angular_cylinder(0.6 * r, 0.81 * r, r * 1.2, fa);
		xlate(0, 0, r * 0.6);
		diff();
		angular_cylinder(0.6 * r, 1.2 * r, r * 1.2, fa);
		angular_cylinder(0.75 * r, 1.0 * r, r * 1.0, fa);
		xlate(0, 0, 0.7 * r);
		crenelation(2.3 * r, r * 2.0);
	}
	endxlate();
	enddiff();
	endxlate();
	endxlate();
	endonion();
	if (!flying) {
		add_windows(r, h);
		enddiff();
	}
	endxlate();
}
コード例 #21
0
ファイル: test4.c プロジェクト: ShoujiKanenobu/opencscad
int main(int argc, char *argv[])
{
	int x, y;

	opencscad_init();
	memset(height, 0, sizeof(height));
	terrain(height, 0, 0, dim - 1, dim - 1);

	for (y = 0; y < dim; y++) {
		for (x = 0; x < dim; x++) {
			xlate(x, y, 0);
				cube(1.05, 1.05, (double) height[idx(x, y)], 0);
			endxlate();
		}
	}
	finalize();
}
コード例 #22
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void gabled_roof(double length, double width, double height)
{
	double side;

	side = (height * 2.0) / sqrt(2.0);

	scale(width / (height * 2.0), 1.0, 1.0);
	diff();
	rotate(45, 0, 1, 0);
	cube(side, length, side, 1);
	endrotate();
	xlate(0, 0, -side);  
	cube(side * 2, length * 2, side * 2, 1);
	endxlate();
	enddiff();
	endscale();
}
コード例 #23
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void buttress_array(double width, double length, double height, double angle,
				double spacing, int count)
{
	int i;
	double x;

	x = -(spacing / 2.0) * (count - 1);

	for (i = 0; i < count; i++) {
		xlate(x, 0, 0);
		rotate(90, 0, 0, 1);
		buttress(width, length, height, angle);
		endrotate();
		x += spacing;
		endxlate();
	}
}
コード例 #24
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void make_castle(void)
{
	scale(0.85, 0.85, 0.85);
	onion();
	scale(0.15, 0.15, 0.15);
	onion();
	keep_foundation(350, 200, 150);
	endonion();
	xlate(0, 0, 150);
	recursive_keep(0, 0, 200, 350, 50, 4);
	endxlate();
	endscale();
	enclosure(8, 65.0, 90.0 * HEIGHT_RADIUS);
	enclosure(6, 38.0, 140.0 * HEIGHT_RADIUS);
	endonion();
	endscale();
}
コード例 #25
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void add_windows(double tower_radius, double tower_height)
{
	int i, nwindows;
	double h;
	double angle;

	nwindows = irandomn(3);

	for (i = 0; i < nwindows; i++) {
		h = randomn(tower_height / 4.0) + tower_height * 0.5;
		angle = (double) randomn(360.0);
		xlate(0, 0, h);
		rotate(angle, 0, 0, 1);
		arched_opening(5, 2, tower_radius * 3);	
		endrotate();
		endxlate();
	}
}
コード例 #26
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void gothic_arch_array(double length, double width, double height,
				double border_thickness, int narches)
{
	int i;
	double l = length - border_thickness * 2.0;
	double wspan = (l + border_thickness) / narches;
	double wwidth = wspan - border_thickness;
	double x;

	x = -(length / 2.0) + border_thickness + (wwidth / 2.0);

	for (i = 0; i < narches; i++) {
		xlate(x, 0, 0);
		rotate(90, 0, 0, 1);
		gothic_arch(wwidth, height, width);
		endrotate();
		endxlate();
		x += wspan;
	}
}
コード例 #27
0
ファイル: test3.c プロジェクト: kennib/openpyscad
void castle(double h, double r)
{
	int i;
	double angle, tx, ty;

	diff();
		cylinder(h, r, r * 0.8);
		cylinder(h, 0.5 * r, 0.4 * r);
	enddiff();

	for (i = 0; i < 5; i++) {
		angle = (PI / 180 * 360.0 / 5.0 * i); 
		tx = r * cos(angle);
		ty = r * sin(angle);
		if ((r / 2.2) >= 3.0) {
			xlate(tx, ty, 0);
				castle(h * 1.3, r / 2.2);
			endxlate();
		}
	}
}
コード例 #28
0
ファイル: kobjects.c プロジェクト: 119-org/hi3518-osdrv
/*
 * This is called when text is sent to the synth via the synth_direct file.
 */
static ssize_t synth_direct_store(struct kobject *kobj,
	struct kobj_attribute *attr, const char *buf, size_t count)
{
	u_char tmp[256];
	int len;
	int bytes;
	const char *ptr = buf;

	if (!synth)
		return -EPERM;

	len = strlen(buf);
	while (len > 0) {
		bytes = min_t(size_t, len, 250);
		strncpy(tmp, ptr, bytes);
		tmp[bytes] = '\0';
		xlate(tmp);
		synth_printf("%s", tmp);
		ptr += bytes;
		len -= bytes;
	}
	return count;
}
コード例 #29
0
ファイル: castle.c プロジェクト: kennib/openpyscad
static void keep_block_windows(double width, double length, double height)
{
	int nwindows;
	int i;

	nwindows = 7;

	for (i = 0; i < nwindows; i++) {
		int dix, diz;
		double dz, dx, w, h;

		dix = irandomn(4) - 2;
		diz = irandomn(2) - 1 ;
		dx = dix * length / 4.0 + length / 8.0;
		dz = diz * height / 2.0 + height / 4.0; 
		// dx = randomn(length * 0.65) - 0.325 * length;
		// dz = randomn(height * 0.6) - 0.3 * height ;
		h = height * 0.2;
		w = height / 2.5;
		xlate(0, dx, dz);
		gothic_arch(w, h, width * 2);
		endxlate();
	}
}
コード例 #30
0
ファイル: emptywindow.c プロジェクト: RavuAlHemio/emptywindow
/**
 * The entry point of a Win32 application. Hi, Windows!
 */
int CALLBACK WinMain(
	HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR     lpCmdLine,
	int       nCmdShow
)
{
	HWND mainWin;
	WNDCLASSEXW winCl;
	ATOM winClAtom;
	BOOL bRet;
	MSG msg;
	wchar_t winTitleBuf[256];

	winCl.cbSize        = sizeof(winCl);
	winCl.style         = 0;
	winCl.lpfnWndProc   = MainWinProc;
	winCl.cbClsExtra    = 0;
	winCl.cbWndExtra    = 0;
	winCl.hInstance     = hInstance;
	winCl.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_APPICON));
	winCl.hCursor       = LoadCursorW(NULL, W_IDC_ARROW);
	winCl.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
	winCl.lpszMenuName  = NULL;
	winCl.lpszClassName = L"EmptyWindow";
	winCl.hIconSm       = NULL;

	winClAtom = RegisterClassExW(&winCl);
	if (winClAtom == (ATOM)0)
	{
		return 1;
	}

	xlate(IDS_WINDOWCAPTION, L"Empty Window", winTitleBuf, sizeof(winTitleBuf)/sizeof(winTitleBuf[0]));

	mainWin = CreateWindowExW(
		0,                            /* extended style */
		(LPCWSTR)(intptr_t)winClAtom, /* window class */
		winTitleBuf,                  /* window title */
		MY_WINDOW_STYLE,              /* window style */
		CW_USEDEFAULT,                /* x coord */
		0,                            /* y coord (ignored if x == CW_USEDEFAULT) */
		CW_USEDEFAULT,                /* width */
		0,                            /* height (ignored if width == CW_USEDEFAULT) */
		NULL,                         /* parent window (none here) */
		NULL,                         /* menu (none here) */
		hInstance,                    /* owning instance */
		NULL                          /* parameter passed to the create message */
	);

	if (mainWin == NULL)
	{
		return 2;
	}

	ShowWindow(mainWin, SW_SHOWDEFAULT);
	UpdateWindow(mainWin);

	/* msg loop */
	while ((bRet = GetMessageW(&msg, NULL, 0, 0)) != 0)
	{
		if (bRet == -1)
		{
			/* crud. */
			return 3;
		}
		else
		{
			TranslateMessage(&msg);
			DispatchMessageW(&msg);
		}
	}

	/* exit with what the quit message told us */
	return msg.wParam;
}