Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uneccessary fog bitmap #176

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions WorldSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const GameState SegmentWrap::zeroState =
{0,0,0},0,{0,0,0},{0,0,0},{0,0,0},0,0
};

ALLEGRO_BITMAP * fog = 0;

void WorldSegment::CorrectTileForSegmentOffset(int32_t& xin, int32_t& yin, int32_t& zin)
{
xin -= segState.Position.x;
Expand Down Expand Up @@ -242,24 +240,6 @@ void WorldSegment::DrawAllTiles()
}

auto& ssConfig = stonesenseState.ssConfig;
auto& ssState = stonesenseState.ssState;

if(ssConfig.config.fogenable) {
ALLEGRO_BITMAP* temp = al_get_target_bitmap();
if(!fog) {
fog = al_create_bitmap(ssState.ScreenW, ssState.ScreenH);
al_set_target_bitmap(fog);
al_clear_to_color(premultiply(ssConfig.config.fogcol));
al_set_target_bitmap(temp);
}
if(!((al_get_bitmap_width(fog) == ssState.ScreenW) && (al_get_bitmap_height(fog) == ssState.ScreenH))) {
al_destroy_bitmap(fog);
fog = al_create_bitmap(ssState.ScreenW, ssState.ScreenH);
al_set_target_bitmap(fog);
al_clear_to_color(premultiply(ssConfig.config.fogcol));
al_set_target_bitmap(temp);
}
}

if (ssConfig.config.show_osd) {
DrawCurrentLevelOutline(true);
Expand Down Expand Up @@ -291,7 +271,13 @@ void WorldSegment::DrawAllTiles()
}
switch(todraw[i].type) {
case Fog:
DrawBitmap(fog, todraw[i]);
al_draw_filled_rectangle(
todraw[i].dx,
todraw[i].dy,
todraw[i].dx + todraw[i].dw,
todraw[i].dy + todraw[i].dh,
premultiply(ssConfig.config.fogcol)
);
break;
case TintedScaledBitmap:
DrawBitmap(std::get<ALLEGRO_BITMAP*>(todraw[i].drawobject), todraw[i]);
Expand Down Expand Up @@ -334,7 +320,7 @@ void WorldSegment::AssembleAllTiles()
int32_t vszmax = segState.Size.z-1; // grabbing one tile +z more than we should for tile rules
for(int32_t vsz=0; vsz < vszmax; vsz++) {
//add the fog to the queue
if(stonesenseState.ssConfig.config.fogenable && fog) {
if(stonesenseState.ssConfig.config.fogenable) {
draw_event d = {
Fog,
std::monostate{},
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Template for new versions:

## Misc Improvements
- `stonesense`: improved the way altars look
- `stonesense`: fog no longer unnecessarily renders to a separate bitmap

## Removed

Expand Down