Skip to content

Commit

Permalink
mandelbrot: get it working at 2x resolution via blitter #145
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Mar 25, 2020
1 parent 73f9cc3 commit aabdf9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/demo/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ mandelbrot(int y, int x, int dy, int dx){
static int
mcell(uint32_t* c, int y, int x, int dy, int dx){
int iter = mandelbrot(y, x, dy, dx);
*c = ((128 - iter / 2) << 24u) + ((256 - iter) << 16u) + ((128 - iter / 2) << 8u);
*c = ((256 - iter) << 24u) + ((256 - iter) << 16u) + ((256 - iter) << 8u);
return 0;
}

static uint32_t*
offset(uint32_t* rgba, int y, int x, int dx){
fprintf(stderr, "writing to %p\n", rgba + y * dx + x);
return rgba + y * dx + x;
}

Expand All @@ -42,6 +41,7 @@ int normal_demo(struct notcurses* nc){
if(!rgba){
return -1;
}
memset(rgba, 0, sizeof(*rgba) * dy * dx);
int y;
if(dy / VSCALE % 2){
y = dy / VSCALE + 1;
Expand All @@ -60,12 +60,11 @@ int normal_demo(struct notcurses* nc){
return -1;
}
}
if(ncblit_rgba(n, y, 0, dx, rgba, dy / 2 - y, 0, y * 2, dx) < 0){
if(ncblit_rgba(n, 0, 0, dx * sizeof(*rgba), rgba, 0, 0, dy, dx) < 0){
return -1;
}
DEMO_RENDER(nc);
}
sleep(1);
free(rgba);
return 0;
}
2 changes: 1 addition & 1 deletion src/lib/libav.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ tria_blit(ncplane* nc, int placey, int placex, int linesize, const void* data,
for(x = placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
const unsigned char* rgbbase_down = dat + (linesize * (visy + 1)) + (visx * bpp / CHAR_BIT);
fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]);
//fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]);
cell* c = ncplane_cell_ref_yx(nc, y, x);
// use the default for the background, as that's the only way it's
// effective in that case anyway
Expand Down

0 comments on commit aabdf9b

Please sign in to comment.