fading visuals
blending does not converge to bg color
This commit is contained in:
parent
5c9ab0240b
commit
d7c7d773ab
2 changed files with 32 additions and 10 deletions
42
main.cpp
42
main.cpp
|
@ -103,23 +103,23 @@ int main() try {
|
|||
|
||||
// no clue who owns this
|
||||
auto* texture = SDL_CreateTexture(
|
||||
renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, width,
|
||||
renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, width,
|
||||
height
|
||||
);
|
||||
sdl_check(SDL_SetRenderTarget(renderer, texture));
|
||||
sdl_check(SDL_SetRenderDrawColor(renderer, 0xdb, 0xd7, 0xc0, SDL_ALPHA_OPAQUE));
|
||||
sdl_check(
|
||||
SDL_SetRenderDrawColor(renderer, 0xff, 0xff, 0xff, SDL_ALPHA_OPAQUE)
|
||||
);
|
||||
sdl_check(SDL_RenderClear(renderer));
|
||||
sdl_check(SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND));
|
||||
sdl_check(SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 2));
|
||||
|
||||
SDL_Point pos{.x = width / 2, .y = height / 2};
|
||||
SDL_Point pos{.x = width / 2, .y = height / 2};
|
||||
constexpr SDL_Point directions[] = {
|
||||
{.x = -1, .y = 0}, {.x = 1, .y = 0}, {.x = 0, .y = -1}, {.x = 0, .y = 1}
|
||||
};
|
||||
|
||||
std::mt19937_64 rne(std::random_device{}());
|
||||
std::uniform_int_distribution dist(0, 3);
|
||||
constexpr auto batchsize = 1000;
|
||||
constexpr auto batchsize = 10000;
|
||||
|
||||
const auto start_time = clock::now();
|
||||
auto next_poll_events_time = start_time;
|
||||
|
@ -149,13 +149,35 @@ int main() try {
|
|||
pos = newpoint;
|
||||
point_batch[step] = newpoint;
|
||||
}
|
||||
sdl_check(SDL_SetRenderTarget(renderer, texture));
|
||||
sdl_check(SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND));
|
||||
sdl_check(SDL_RenderDrawPoints(renderer, point_batch.data(), point_batch.size()));
|
||||
|
||||
///// Render image
|
||||
sdl_check(SDL_SetRenderTarget(renderer, texture));
|
||||
sdl_check(SDL_SetRenderDrawBlendMode(
|
||||
renderer,
|
||||
SDL_ComposeCustomBlendMode(
|
||||
SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ZERO,
|
||||
SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD
|
||||
)
|
||||
));
|
||||
sdl_check(
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE)
|
||||
);
|
||||
sdl_check(SDL_RenderDrawPoints(
|
||||
renderer, point_batch.data(), point_batch.size()
|
||||
));
|
||||
sdl_check(SDL_SetRenderDrawColor(renderer, 0xff, 0xff, 0xff, 32));
|
||||
sdl_check(SDL_RenderFillRect(renderer, nullptr));
|
||||
// SDL_RenderCopy(renderer, fade_texture, nullptr, nullptr);
|
||||
|
||||
///// Render screen
|
||||
sdl_check(SDL_SetRenderTarget(renderer, nullptr));
|
||||
sdl_check(
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE)
|
||||
);
|
||||
SDL_RenderClear(renderer);
|
||||
sdl_check(SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE));
|
||||
sdl_check(SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE));
|
||||
// sdl_check(SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE));
|
||||
sdl_check(SDL_RenderCopy(renderer, texture, nullptr, nullptr));
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 42 KiB |
Loading…
Reference in a new issue