blended visuals
blending somehow never reaches draw color
This commit is contained in:
parent
767607ede1
commit
1a3fccfe2d
1 changed files with 7 additions and 16 deletions
23
main.cpp
23
main.cpp
|
@ -53,16 +53,6 @@ auto operator+(SDL_Point a, SDL_Point b) {
|
|||
return SDL_Point{.x = a.x + b.x, .y = a.y + b.y};
|
||||
}
|
||||
|
||||
auto operator<=>(const SDL_Point& a, const SDL_Point& b) {
|
||||
auto y_comp = a.x <=> b.x;
|
||||
if (y_comp != std::strong_ordering::equal) { return y_comp; }
|
||||
return a.y <=> b.y;
|
||||
}
|
||||
|
||||
auto operator==(const SDL_Point& a, const SDL_Point& b) {
|
||||
return a.x == b.x && a.y == b.y;
|
||||
}
|
||||
|
||||
// constexpr int width = 1000;
|
||||
// constexpr int height = 1000;
|
||||
constexpr int width = 3440;
|
||||
|
@ -119,7 +109,8 @@ int main() try {
|
|||
sdl_check(SDL_SetRenderTarget(renderer, texture));
|
||||
sdl_check(SDL_SetRenderDrawColor(renderer, 0xdb, 0xd7, 0xc0, SDL_ALPHA_OPAQUE));
|
||||
sdl_check(SDL_RenderClear(renderer));
|
||||
sdl_check(SDL_SetRenderDrawColor(renderer, 0x0d, 0x0f, 0x14, SDL_ALPHA_OPAQUE));
|
||||
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};
|
||||
constexpr SDL_Point directions[] = {
|
||||
|
@ -128,10 +119,7 @@ int main() try {
|
|||
|
||||
std::mt19937_64 rne(std::random_device{}());
|
||||
std::uniform_int_distribution dist(0, 3);
|
||||
// aarrggbb??
|
||||
constexpr Uint32 bg_color = 0xffdbd7c0;
|
||||
constexpr Uint32 walk_color = 0xff0d0f14;
|
||||
constexpr auto batchsize = 100;
|
||||
constexpr auto batchsize = 1000;
|
||||
|
||||
const auto start_time = clock::now();
|
||||
auto next_poll_events_time = start_time;
|
||||
|
@ -151,7 +139,6 @@ int main() try {
|
|||
);
|
||||
}
|
||||
|
||||
sdl_check(SDL_SetRenderTarget(renderer, texture));
|
||||
std::array<SDL_Point, batchsize> point_batch;
|
||||
for (auto step = 0z; step < batchsize; ++step) {
|
||||
SDL_Point newpoint;
|
||||
|
@ -162,9 +149,13 @@ 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()));
|
||||
|
||||
sdl_check(SDL_SetRenderTarget(renderer, nullptr));
|
||||
sdl_check(SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE));
|
||||
sdl_check(SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE));
|
||||
sdl_check(SDL_RenderCopy(renderer, texture, nullptr, nullptr));
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue