opengl - Texture rotated by SDL2 is anti-aliased incorrectly -
I'm trying to mix many textures with anti-aliasing enabled, it works fine if not textured Rotate, but when I rotate a texture, produces a "border" on the edge of anti-aliasing texture. Below are examples.
Original textures, 100x100px image in the middle of 50x50px. Png "alt =" original texture ">
I am rendering this text twice: as it rotates 45 degrees, it produces the following result:
Note the range of gray rotation textures in my opinion, the texture at the bottom is lower Level should be mixed with texture because they contain pixels of the same color, if anti-aliasing is incomplete, the texture is up without any limit Miserically mix, but obviously I want to do anti-aliasing for the rotating texture.
Is there a way to achieve both: anti-aliens texture and seamless mix?
I am rendering with SDL2 and OpenGL below is a program to display this example below.
#include & lt; Assert.h & gt; # Include & lt; SDL2 / SDL.h & gt; # Include & lt; SDL2 / SDL_image.h & gt; Zero Render El_renderr * renderer, Sdielacaktekshns * Tech) {Sdielsisetrenderdroprr (renderer, 0, 0, 0, 0x FF); SDL_RenderClear (renderer); SDL_motion dst_rect = {0, 0, 100, 100}; SDL_RenderCopyEx (renderer, texts, 0, and dst_rect, 0, 0, SDL_FLIP_NONE); SDL_RenderCopyEx (renderer, texts, 0, and dst_rect, 45, 0, SDL_FLIP_NONE); SDL_RenderPresent (renderer); } Int main () {SDL_Window * window; SDL_Renderer * Renderer; SDL_Init (SDL_INIT_VIDEO); SDL_CreateWindowAndRenderer (100, 100, SDL_WINDOW_OPENGL, and window, and renderer); / * Comment the following line for mixed pictures / SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, "Best"); SDL_Texture * tex = IMG_LoadTestructure (Renderer, "./sample.png"); Emphasis (tech! = 0); SDL_SetTextureBlendMode (Tech, SDL_BLENDMODE_BLEND); Renderer (Renderer, Tech); SDL_Event event = {0}; While (1) {if (SDL_PollEvent (and event) == 0) {SDL_Delay (100); to continue; } If (event.type == SDL_QUIT) {SDL_Quit (); break; }} Return 0; } Edit: I have come to know that if I rotate texture from 45 degree inside the SDL_rendercpx it will add a semi-transparent border of a different color, please see the picture below.
Note that rotated How the color changes around the edges
The work solution I got is to fill the transparent part of the image with almost transparent pixels. Picture:
"transparent" The color in that image is 0x0187ceeb (ARGB). It then produces composite image as expected:
< / P>
Some details of this solution are described here:
Comments
Post a Comment