When I try to draw a rectangle, the bottom line always is one pixel up on the right side:
The problem also persists when I change the size and position.
Below I have a minimal working solution that should reproduce the problem, if it's not my computer going crazy:
#include "SDL.h"
#include <iostream>
int main(int args, char **argv) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
printf("error initializing SDL: %s\n", SDL_GetError());
}
SDL_Window *window = SDL_CreateWindow("Testing", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, 0);
Uint32 renderFlags = SDL_RENDERER_ACCELERATED;
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, renderFlags);
if (renderer == nullptr) {
std::cout << "Error initializing _renderer: " << SDL_GetError() << std::endl;
}
int close = 0;
SDL_Event event;
while (!close) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
close = 1;
break;
}
}
SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
SDL_Rect rect = {100, 100, 100, 100};
SDL_RenderDrawRect(renderer, &rect);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderPresent(renderer);
SDL_Delay(1000 / 240);
}
SDL_Quit();
return 0;
}
I am using Fedora 36 Linux and the Gnome 42 desktop.
I also tried starting it with x11 instead of wayland with SDL_VIDEODRIVER=x11
, but that doesn't change anything.
What could be the problem here?
It seems like I solved the problem by changing from the Flatpak version of CLion to the native one installed from the JetBrains toolbox.
The problem only occurs when I run the compiled executable from inside CLion, so I think it's a CLion problem. I reported the problem to JetBrains here.