Hi, thank you SDL team for adding the SDL_RenderGeometry() function,
I didn’t manage to change the render quality, it’s like the hint SDL_HINT_RENDER_SCALE_QUALITY as no effect.
And, yes, I put it before loading the surface and create the texture.
Hi, thank you SDL team for adding the SDL_RenderGeometry() function,
I didn’t manage to change the render quality, it’s like the hint SDL_HINT_RENDER_SCALE_QUALITY as no effect.
And, yes, I put it before loading the surface and create the texture.
You mean jagged lines vs antialiasing? On my system I’m getting smooth diagonal lines. it seems to depend on the hardware and renderer. I can influence the outcome by changing the NVIDIA Control Panel settings. I’m surprised more people aren’t having smooth lines out of the box.
I probably make a mistake somewhere in my code, cause I just create a sample to demonstrate the bug, and… there is no bug.
#include <SDL2/SDL.h>
#define W 0xffffffff
#define B 0x000000ff
int main(int argc,char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *w=SDL_CreateWindow("test",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,400,200,SDL_WINDOW_RESIZABLE);
SDL_Renderer *r=SDL_CreateRenderer(w,-1,SDL_RENDERER_ACCELERATED);
SDL_RenderSetIntegerScale(r,SDL_TRUE);
SDL_RenderSetLogicalSize(r,400,200);
SDL_SetRenderDrawColor(r,127,0,63,255);
// create a checkboard texture
SDL_Texture *t=SDL_CreateTexture(r,SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_STATIC,8,8);
Uint32 pixels[8*8] = {
W, B, W, B, W, B, W, B,
B, W, B, W, B, W, B, W,
W, B, W, B, W, B, W, B,
B, W, B, W, B, W, B, W,
W, B, W, B, W, B, W, B,
B, W, B, W, B, W, B, W,
W, B, W, B, W, B, W, B,
B, W, B, W, B, W, B, W
};
SDL_Rect c={0,0,8,8};
SDL_UpdateTexture(t,&c,static_cast<void*>(&pixels[0]),8*sizeof(Uint32));
// for the left rectangle
SDL_Rect d={25,25,150,150};
// for the right rectangle: setup vertices and indices
SDL_Vertex v[4] = {
{ {225,25}, {255,255,255,255}, {0,0} },
{ {225+150,25}, {255,255,255,255}, {1,0} },
{ {225+150,25+150}, {255,255,255,255}, {1,1} },
{ {225,25+150}, {255,255,255,255}, {0,1} }
};
int i[6]={3,0,1,1,2,3};
SDL_Event e;
bool o=true;
while(o)
{
while(SDL_PollEvent(&e)) switch(e.type)
{
case SDL_QUIT: o=false; break;
}
SDL_RenderClear(r);
// render using copy
SDL_RenderCopy(r,t,&c,&d);
// render using geometry
SDL_RenderGeometry(r,t,&v[0],4,&i[0],6);
SDL_RenderPresent(r);
}
SDL_DestroyRenderer(r);
SDL_DestroyWindow(w);
SDL_Quit();
}