Mac M1平台SDL2渲染三角形出现像素化异常求助
M1 Mac上SDL2渲染三角形出现像素化及多余像素问题
在M1芯片的Mac设备上尝试使用SDL2渲染三角形时,生成的三角形像素化严重,且存在多余像素。
渲染效果:
我的代码:
int main(int argc, char *argv[]) { // returns zero on success else non-zero if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { printf("error initializing SDL: %s\n", SDL_GetError()); } SDL_Window* win = SDL_CreateWindow("GAME", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 900, 900, SDL_WINDOW_ALLOW_HIGHDPI); if(!win) { std::cout << "Failed to create window\n"; return -1; } int *w_t = new int (); int *h_t = new int (); SDL_GetWindowSize(win,w_t,h_t); std::cout<<"width:"<<*w_t<<"height:"<<*h_t; SDL_Renderer* brush = SDL_CreateRenderer(win, -1, 0); SDL_SetRenderDrawColor(brush, 255, 0, 0, 0); SDL_Point a = {0,500}; SDL_Point b = {800,500}; SDL_Point c = {250,250}; bool quit = false; SDL_Event e; while (!quit) { while (SDL_PollEvent(&e)) { if (e.type == SDL_QUIT) { quit = true; } } SDL_RenderDrawLine(brush, a.x, a.y, b.x, b.y); SDL_RenderDrawLine(brush, a.x, a.y, c.x, c.y); SDL_RenderDrawLine(brush, b.x, b.y, c.x, c.y); SDL_RenderPresent(brush); } return 0; }
环境信息:
- 操作系统:macOS Monterey
- 集成开发环境:Xcode
- 编译器:Clang
内容的提问来源于stack exchange,提问作者Raider_Knight
相关产品推荐
相关产品推荐

