@@ 488,7 488,8 @@ export_icn(Uint32 *src, int width, int height, char *filename)
if(color) {
int col = x & 7, row = y & 7;
int byte = (x & ~7) + (y & ~7) * width / 8 + row;
- icnbuf[byte] |= 1 << (7 - col);
+ if(byte < SZ)
+ icnbuf[byte] |= 1 << (7 - col);
}
}
}
@@ 502,17 503,14 @@ export_icn(Uint32 *src, int width, int height, char *filename)
static void
export_bmp(char *filename)
{
- SDL_Surface *surface = SDL_GetWindowSurface(gWindow);
- SDL_RenderReadPixels(gRenderer,
- NULL,
- SDL_PIXELFORMAT_ARGB8888,
- surface->pixels,
- surface->pitch);
- if(SDL_SaveBMP(surface, filename))
- fprintf(stderr, "Failed: %s\n", SDL_GetError());
- else
- fprintf(stderr, "Export: %s\n", filename);
+ int w, h;
+ SDL_Surface *surface;
+ SDL_GetRendererOutputSize(gRenderer, &w, &h);
+ surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 24, SDL_PIXELFORMAT_RGB24);
+ SDL_RenderReadPixels(gRenderer, NULL, SDL_PIXELFORMAT_RGB24, surface->pixels, surface->pitch);
+ SDL_SaveBMP(surface, filename);
SDL_FreeSurface(surface);
+ fprintf(stderr, "Saved %s\n", filename);
}
static void
@@ 812,6 810,28 @@ createumbrella(Scene *s)
return umbrella;
}
+void
+build_scene(Scene *s)
+{
+ Point3d a = Pt3d(10, 0, 0);
+ Point3d b = Pt3d(-10, 0, 0);
+ Point3d c = Pt3d(15, 5, 0);
+ Point3d d = Pt3d(15, 5, 0);
+ Mesh *ramp = addmesh(s);
+ Mesh *lift = addmesh(s);
+ addline(
+ addline(ramp, a, c, 1), a, b, 1);
+ extrude(
+ extrude(ramp, 0, 15, 0, 1), 0, 0, -10, 1);
+
+ addline(
+ addline(lift, a, b, 2), d, c, 2);
+
+ extrude(lift, 0, -10, 10, 3);
+ createbox(s, 20, 20, 20, 1);
+ createbox(s, 40, 20, 10, 1);
+}
+
int
main(void)
{
@@ 820,7 840,7 @@ main(void)
cam = Cm3d(180, 0, 0, 30);
if(!init())
return error("Init", "Failure");
- createumbrella(&scn);
+ build_scene(&scn);
redraw(pixels);
while(1) {
int tick = SDL_GetTicks();