Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vs49688 committed Sep 28, 2024
1 parent c676f6c commit 722378d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
15 changes: 15 additions & 0 deletions examples/brdemo/brdemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,33 @@ static br_pixelmap *BR_CALLBACK MapFindFailedLoadDeCLUT(const char *name)
if(pm->type == BR_PMT_INDEX_8 && pm->map == NULL)
pm->map = palette;

#if 0
if((pm2 = BrPixelmapDeCLUT(pm)) != NULL) {
if(pm->map != palette)
BrResFree(pm->map);

BrResFree(pm);
pm = pm2;
}
#endif

if(pm->identifier != NULL)
BrResFree(pm->identifier);

pm->identifier = BrResStrDup(pm, name);

if(pm->map != NULL && pm->map != palette) {
/*
* If there's a non-default palette, give it a (hopefully) unique name
* so it can be added to the registry.
*/
if(pm->map->identifier != NULL)
BrResFree(pm->map->identifier);

pm->map->identifier = BrResSprintf(pm->map, "%s(palette)", pm->identifier);
BrTableAdd(pm->map);
}

BrMapAdd(pm);
}

Expand Down
Binary file added examples/dat/xxxxx.pix
Binary file not shown.
49 changes: 46 additions & 3 deletions examples/softcube/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ int main(int argc, char **argv)
goto create_fail;
}

//br_pixelmap *std_pal;
//std_pal = BrPixelmapLoad("/home/zane/Documents/Coding/CrocDE-BRender/examples/tutorials/dat/std.pal");

{
#if defined(SOFTCUBE_16BIT)
BrLogInfo("APP", "Running at 16-bpp");
colour_buffer = BrPixelmapMatchTyped(screen, BR_PMMATCH_OFFSCREEN, BR_PMT_RGB_565);;
colour_buffer = BrPixelmapMatchTyped(screen, BR_PMMATCH_OFFSCREEN, BR_PMT_INDEX_8);;
clear_colour = BR_COLOUR_565(66, 66, 66);

#else
Expand Down Expand Up @@ -138,6 +141,46 @@ int main(int argc, char **argv)
BrMapUpdate(cube->material->colour_map, BR_MAPU_ALL);
BrMaterialUpdate(cube->material, BR_MATU_ALL);



br_pixelmap *pal = BrPixelmapAllocate(BR_PMT_RGBX_888, 1, 256, NULL, BR_PMAF_NORMAL);
BrQuantBegin();
{
br_pixelmap *pm = cube->material->colour_map->map;
for(int y = -pm->origin_y; y < -pm->origin_y + pm->height; y++) {
for(int x = -pm->origin_x; x < -pm->origin_x + pm->width; x++) {
br_uint_32 col = BrPixelmapPixelGet(pm, x, y);

br_uint_8 rgb[3] = {
BR_RED(col),
BR_GRN(col),
BR_BLU(col),
};
BrQuantAddColours(rgb, 1);
}
}
br_uint_8 rgb[3] = {
128,
128,
128,
};
BrQuantAddColours(rgb, 1);

br_uint_8 rgb2[3] = {
0,
0,
0,
};
BrQuantAddColours(rgb2, 1);
}
BrQuantMakePalette(0, 256, pal);
BrQuantPrepareMapping(0, 256, pal);
BrQuantEnd();

BrPixelmapPaletteSet(colour_buffer, pal);



BrMatrix34RotateY(&cube->t.t.mat, BR_ANGLE_DEG(30));

light = BrActorAdd(world, BrActorAllocate(BR_ACTOR_LIGHT, NULL));
Expand All @@ -146,7 +189,7 @@ int main(int argc, char **argv)
ticks_last = SDL_GetTicks64();

BrMatrix34Identity(&cube->t.t.mat);
BrMatrix34PostTranslate(&cube->t.t.mat, 4, 0, 0);
BrMatrix34PostTranslate(&cube->t.t.mat, 2, 0, 0);
for(SDL_Event evt;;) {
float dt;

Expand All @@ -164,7 +207,7 @@ int main(int argc, char **argv)
BrMatrix34PostRotateY(&cube->t.t.mat, BR_ANGLE_DEG(BR_SCALAR(50) * BR_SCALAR(dt)));

BrRendererFrameBegin();
BrPixelmapFill(colour_buffer, clear_colour);
BrPixelmapFill(colour_buffer, 10);
BrPixelmapFill(depth_buffer, 0xFFFFFFFF);
BrZbSceneRender(world, camera, colour_buffer, depth_buffer);
BrRendererFrameEnd();
Expand Down

0 comments on commit 722378d

Please sign in to comment.