The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_RenderCopy weird bug
samleo


Joined: 04 Mar 2014
Posts: 37
Location: Brazil
This function have a weird bug. My code is totally normal, without any error, because the same code runs on SDL1.2 and don't shows any weird bug. This bug only occurs on SDL2 when I do the follow:
-resize the game window to any size
-maximize the game window
Here the image:


Changing the render scale quality to nearest the bug seems reduce, but not ends.

If you would like to see the bug download my game http://sourceforge.net/projects/dangeroustux/, compile and run it. Please compile with:
to Linux:
make DangerousTux.SDL2
to windows
just run make -f Makefile.mingw from cmd or compile with the cmake
Re: SDL_RenderCopy weird bug
AlexRou


Joined: 31 Jan 2014
Posts: 57
Yeah it looks like a scaling bug, you can either use OpenGL directly and make your own renderer or you can try rendering to a fixed size texture then show that and see if it scales right.

samleo wrote:
This function have a weird bug. My code is totally normal, without any error, because the same code runs on SDL1.2 and don't shows any weird bug. This bug only occurs on SDL2 when I do the follow:
-resize the game window to any size
-maximize the game window
Here the image:


Changing the render scale quality to nearest the bug seems reduce, but not ends.

If you would like to see the bug download my game http://sourceforge.net/projects/dangeroustux/, compile and run it. Please compile with:
to Linux:
make DangerousTux.SDL2
to windows
just run make -f Makefile.mingw from cmd or compile with the cmake
mr_tawan


Joined: 13 Jan 2014
Posts: 161
Have you tried remove the following code ? :

Code:

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
AlexRou


Joined: 31 Jan 2014
Posts: 57
On my end that does nothing

mr_tawan wrote:
Have you tried remove the following code ? :

Code:

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
Re: SDL_RenderCopy weird bug
samleo


Joined: 04 Mar 2014
Posts: 37
Location: Brazil
mr_tawan wrote:
Have you tried remove the following code ? :

Code:

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");


Yes, I tried. But the bug persist, just a little visible.


AlexRou wrote:
Yeah it looks like a scaling bug, you can either use OpenGL directly and make your own renderer or you can try rendering to a fixed size texture then show that and see if it scales right.


And how I do that? Sorry, I'm new to SDL2.
Re: SDL_RenderCopy weird bug
AlexRou


Joined: 31 Jan 2014
Posts: 57
First create a texture

https://wiki.libsdl.org/SDL_CreateTexture?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then set the render target to the texture

https://wiki.libsdl.org/SDL_SetRenderTarget?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then you draw stuff as normal, set the target to NULL then draw the texture you created.

NOTE: Untested

If you want to make your own renderer you gota go learn OpenGL, here is some starting codes

Code:
#include <SDL2/SDL.h>
#include <GL/gl.h>

int main( int argc, char* args[] )
{
   if( SDL_Init( SDL_INIT_EVERYTHING ) != 0 )
   {
      //error
   }

   SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 2 );
   SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
   SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
   SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
   SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
   SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 8 );
   SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );

   SDL_Window* window = SDL_CreateWindow( "Test Window",
                                          SDL_WINDOWPOS_CENTERED,
                                          SDL_WINDOWPOS_CENTERED,
                                          800, 600,
                                          SDL_WINDOW_OPENGL
                                        );

   SDL_GLContext GLContext = SDL_GL_CreateContext( window );
   glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );

   glViewport( 0, 0, 800, 600 );
   /* change to the projection matrix and set our viewing volume. */
   glMatrixMode( GL_PROJECTION );
   glLoadIdentity();

   glOrtho( 0, 800, 600, 0, -1, 1 );

   /* Make sure we're chaning the model view and not the projection */
   glMatrixMode( GL_MODELVIEW );

   /* Reset The View */
   glLoadIdentity();
   glPushMatrix();

   SDL_Event* event = new SDL_Event;
   bool quit = false;

   while( !quit )
   {
      while( !SDL_PollEvent( event ) )
      {
            if( event->type == SDL_QUIT )
                quit = true;
      }

      glMatrixMode( GL_MODELVIEW );
      glPopMatrix();
      glPushMatrix();

      glBegin( GL_TRIANGLE_STRIP );

      glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
      glVertex3f( -100, -100, 0.0f );
      glVertex3f( 100, -100, 0.0f );
      glVertex3f( -100, 100, 0.0f );
      glVertex3f( 100, 100, 0.0f );

      glEnd();

      SDL_GL_SwapWindow( window );
      glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
   }

    SDL_Quit();

   return 0;
}


samleo wrote:
mr_tawan wrote:
Have you tried remove the following code ? :

Code:

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");


Yes, I tried. But the bug persist, just a little visible.


AlexRou wrote:
Yeah it looks like a scaling bug, you can either use OpenGL directly and make your own renderer or you can try rendering to a fixed size texture then show that and see if it scales right.


And how I do that? Sorry, I'm new to SDL2.
Code:
Code:
Code:
SDL_RenderCopy weird bug
Leonardo


Joined: 11 Feb 2010
Posts: 46
If your tilemap is not going to change a lot, you could create a surface, blit all your tiles and then create a texture from it:

    SDL_Surface * tileset; /* your tileset  as a surface */
    SDL_Surface * target; /* the target surface to blit tiles */
    SDL_Texture * result; /* the resulting texture */
    target = SDL_CreateRGBSurface(0, tilemap_width_in_pixels, tilemap_height_in_pixels, 32, tileset->format->Rmask, tileset->format->Gmask, tileset->format->Bmask, tileset->format->Amask);  


    /*
     * blit all your tiles from the tileset using SDL_BlitSurface
     */


    /* create a single texture from that surface */
    result = SDL_CreateTextureFromSurface(renderer, target);

    SDL_FreeSurface(target);




You do that once for each map on initialization and use SDL_RenderCopy to render a single texture each frame, which is much faster. Don't do this if your map changes too much.





2014-06-14 10:52 GMT-03:00 AlexRou:
Quote:
First create a texture

https://wiki.libsdl.org/SDL_CreateTexture?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then set the render target to the texture

https://wiki.libsdl.org/SDL_SetRenderTarget?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then you draw stuff as normal, set the target to NULL then draw the texture you created.

NOTE: Untested

If you want to make your own renderer you gota go learn OpenGL, here is some starting codes




Code:

#include
#include

int main( int argc, char* args[] )
{
   if( SDL_Init( SDL_INIT_EVERYTHING ) != 0 )
   {
      //error
   }

   SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 2 );
   SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
   SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
   SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
   SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
   SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 8 );
   SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );

   SDL_Window* window = SDL_CreateWindow( "Test Window",
                                          SDL_WINDOWPOS_CENTERED,
                                          SDL_WINDOWPOS_CENTERED,
                                          800, 600,
                                          SDL_WINDOW_OPENGL
                                        );

   SDL_GLContext GLContext = SDL_GL_CreateContext( window );
   glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );

   glViewport( 0, 0, 800, 600 );
   /* change to the projection matrix and set our viewing volume. */
   glMatrixMode( GL_PROJECTION );
   glLoadIdentity();

   glOrtho( 0, 800, 600, 0, -1, 1 );

   /* Make sure we're chaning the model view and not the projection */
   glMatrixMode( GL_MODELVIEW );

   /* Reset The View */
   glLoadIdentity();
   glPushMatrix();

   SDL_Event* event = new SDL_Event;
   bool quit = false;

   while( !quit )
   {
      while( !SDL_PollEvent( event ) )
      {
            if( event->type == SDL_QUIT )
                quit = true;
      }

      glMatrixMode( GL_MODELVIEW );
      glPopMatrix();
      glPushMatrix();

      glBegin( GL_TRIANGLE_STRIP );

      glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
      glVertex3f( -100, -100, 0.0f );
      glVertex3f( 100, -100, 0.0f );
      glVertex3f( -100, 100, 0.0f );
      glVertex3f( 100, 100, 0.0f );

      glEnd();

      SDL_GL_SwapWindow( window );
      glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
   }

    SDL_Quit();

   return 0;
}








samleo wrote:




mr_tawan wrote:

Have you tried remove the following code ? :




Code:


SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");








Yes, I tried. But the bug persist, just a little visible.





AlexRou wrote:

Yeah it looks like a scaling bug, you can either use OpenGL directly and make your own renderer or you can try rendering to a fixed size texture then show that and see if it scales right.





And how I do that? Sorry, I'm new to SDL2.





Code:







Code:







Code:







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

mr_tawan


Joined: 13 Jan 2014
Posts: 161
Hi @samleo

I don't know if you have already sort this out or not. Today I've tried compiling your code and it looks pretty good on my end.



Glxinfo :
Code:
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.2.1
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
AlexRou


Joined: 31 Jan 2014
Posts: 57
It only happens when the screen size changed

mr_tawan wrote:
Hi @samleo

I don't know if you have already sort this out or not. Today I've tried compiling your code and it looks pretty good on my end.



Glxinfo :
Code:
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.2.1
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
SDL_RenderCopy weird bug
Juan Manuel Borges Caño
Guest

If any bug on SDL basic 2D drawing is just adviced to use your own GL renderer, hence don't expect we give a thing, I'd consider just start moving ... GL, EGL, AL and libinput anyway. as in what value adds... Console Framebuffer, SVGAlib, ... :-)
SDL_RenderCopy weird bug
Juan Manuel Borges Caño
Guest

Oh, and there is that thing about reload your assets on window resize, most fast advice being don't allow in live window resizing, cause gl context gets resetted, don't ask me why or what.
SDL_RenderCopy weird bug
Leonardo


Joined: 11 Feb 2010
Posts: 46
2014-06-15 6:50 GMT-03:00 Juan Manuel Borges Caño:
Quote:

If any bug on SDL basic 2D drawing is just adviced to use your own GL renderer, hence don't expect we give a thing, I'd consider just start moving ... GL, EGL, AL and libinput anyway. as in what value adds... Console Framebuffer, SVGAlib, ... :-)


I beg to differ, as any bug on SDL drawing should be fixed, not ignored. I *do* give a thing for problems that people are facing as can be the same problems I might have in the future. There's a large portion of good software written upon SDL. Maybe its renderer its not as good as your own, but thats no reason to leave it, it is reason to improve it.
 
Quote:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: SDL_RenderCopy weird bug
samleo


Joined: 04 Mar 2014
Posts: 37
Location: Brazil
AlexRou wrote:
First create a texture

https://wiki.libsdl.org/SDL_CreateTexture?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then set the render target to the texture

https://wiki.libsdl.org/SDL_SetRenderTarget?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then you draw stuff as normal, set the target to NULL then draw the texture you created.

NOTE: Untested

If you want to make your own renderer you gota go learn OpenGL, here is some starting codes


Ok I tried the first solution and not work, the bug persist. The second I going not to try because I don't know programming on OpenGL.

The tileset changes constantly, because it have animated tiles, and I don't can render to a Surface.

I would like that bug was solved, so PLEASE someone fix this.
SDL_RenderCopy weird bug
Leonardo


Joined: 11 Feb 2010
Posts: 46
2014-06-15 11:16 GMT-03:00 samleo:
Quote:



AlexRou wrote:

First create a texture

https://wiki.libsdl.org/SDL_CreateTexture?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then set the render target to the texture

https://wiki.libsdl.org/SDL_SetRenderTarget?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then you draw stuff as normal, set the target to NULL then draw the texture you created.

NOTE: Untested

If you want to make your own renderer you gota go learn OpenGL, here is some starting codes





Ok I tried the first solution and not work, the bug persist. The second I going not to try because I don't know programming on OpenGL.

The tileset changes constantly, because it have animated tiles, and I don't can render to a Surface.

I would like that bug was solved, so PLEASE someone fix this.





Its not how things happen in open source software. You might want to learn the skills necessary to fix this yourself. This bugs does not affects me. You might also want to report this bug in https://bugzilla.libsdl.org, you'll have more chances of finding people interested in fixing bugs there. Could you provide a smaller example demonstrating and isolating the bug? That would make it easier to analyze and to produce a fix.


Also, if you have only some tiles changing, you can draw static ones in the surface and animated ones on top of it. Rendering every tile every frame is already a very bad idea and very cpu and gpu intensive, added to the fact that you are scaling every single tile in each rendercopy.


Why do you allow window resizing? I know only one or two games that allow window resizing on the fly, and only one that is tile-based and their solution was to show more or less tiles depending on the aspect ratio, not scale them.
 
Quote:


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_RenderCopy weird bug
Leonardo


Joined: 11 Feb 2010
Posts: 46
This is topic is not new apparently. See this thread https://forums.libsdl.org/viewtopic.php?p=39136&sid=02da27cc1daab72dbdd92d1d77afeebb for a larger discussion on the subject of tile seams.

Also you might want to try SDL_gpu which, according to that thread, can do what you want: https://code.google.com/p/sdl-gpu/




2014-06-15 11:31 GMT-03:00 Leonardo Guilherme:
Quote:



2014-06-15 11:16 GMT-03:00 samleo:
Quote:



AlexRou wrote:

First create a texture

https://wiki.libsdl.org/SDL_CreateTexture?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then set the render target to the texture

https://wiki.libsdl.org/SDL_SetRenderTarget?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then you draw stuff as normal, set the target to NULL then draw the texture you created.

NOTE: Untested

If you want to make your own renderer you gota go learn OpenGL, here is some starting codes





Ok I tried the first solution and not work, the bug persist. The second I going not to try because I don't know programming on OpenGL.

The tileset changes constantly, because it have animated tiles, and I don't can render to a Surface.

I would like that bug was solved, so PLEASE someone fix this.







Its not how things happen in open source software. You might want to learn the skills necessary to fix this yourself. This bugs does not affects me. You might also want to report this bug in https://bugzilla.libsdl.org, you'll have more chances of finding people interested in fixing bugs there. Could you provide a smaller example demonstrating and isolating the bug? That would make it easier to analyze and to produce a fix.


Also, if you have only some tiles changing, you can draw static ones in the surface and animated ones on top of it. Rendering every tile every frame is already a very bad idea and very cpu and gpu intensive, added to the fact that you are scaling every single tile in each rendercopy.


Why do you allow window resizing? I know only one or two games that allow window resizing on the fly, and only one that is tile-based and their solution was to show more or less tiles depending on the aspect ratio, not scale them.
 
Quote:


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






Re: SDL_RenderCopy weird bug
samleo


Joined: 04 Mar 2014
Posts: 37
Location: Brazil
Leonardo wrote:
2014-06-15 11:16 GMT-03:00 samleo:
Quote:



AlexRou wrote:

First create a texture

https://wiki.libsdl.org/SDL_CreateTexture?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then set the render target to the texture

https://wiki.libsdl.org/SDL_SetRenderTarget?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

Then you draw stuff as normal, set the target to NULL then draw the texture you created.

NOTE: Untested

If you want to make your own renderer you gota go learn OpenGL, here is some starting codes





Ok I tried the first solution and not work, the bug persist. The second I going not to try because I don't know programming on OpenGL.

The tileset changes constantly, because it have animated tiles, and I don't can render to a Surface.

I would like that bug was solved, so PLEASE someone fix this.





Its not how things happen in open source software. You might want to learn the skills necessary to fix this yourself. This bugs does not affects me. You might also want to report this bug in https://bugzilla.libsdl.org, you'll have more chances of finding people interested in fixing bugs there. Could you provide a smaller example demonstrating and isolating the bug? That would make it easier to analyze and to produce a fix.


Also, if you have only some tiles changing, you can draw static ones in the surface and animated ones on top of it. Rendering every tile every frame is already a very bad idea and very cpu and gpu intensive, added to the fact that you are scaling every single tile in each rendercopy.


Why do you allow window resizing? I know only one or two games that allow window resizing on the fly, and only one that is tile-based and their solution was to show more or less tiles depending on the aspect ratio, not scale them.
 
Quote:


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



Ok, I'll use the bugzilla. The first thing that I tried was fix the bug by myself, but it's very difficult to me because I don't know basic of the SDL2 code.
Well, no resizing it's a good idea, at least it's the minimum to do.

Thanks to all for reply
Re: SDL_RenderCopy weird bug
samleo


Joined: 04 Mar 2014
Posts: 37
Location: Brazil
Leonardo wrote:
This is topic is not new apparently. See this thread https://forums.libsdl.org/viewtopic.php?p=39136&sid=02da27cc1daab72dbdd92d1d77afeebb for a larger discussion on the subject of tile seams.

Also you might want to try SDL_gpu which, according to that thread, can do what you want: https://code.google.com/p/sdl-gpu/



Ok, it seems good. On that thread it's like my problem but without solution yet. I guess that I'll use the SDL1.2 on entire game versions, just for windows was SDL2, or use SDL2 with no resizable window.
mr_tawan


Joined: 13 Jan 2014
Posts: 161
Well, I think it's not really a bug, but it is the way hw-accelerated works.

When using 3d hw to render things, the gpu sample the texel data from texture to render. If there's any scaling needed, especially when the target object is larger than the actual area of texture used, gpu needs to resample the texture data. The problem is the texture is resampled as a whole, so it takes the nearby texel into consideration. In contrast, most 2d sprite engine crop the image before doing resampling, thus the there is not nebouring pixel being used.

I've looked at your sprite image, the sprite being issues are place adjectly without any gaps in-between. This caused the resampling algorithm takes the nearby sprite's texel value into its pipeline, caused a jarring pixel rendered. I'd recommend putting 1-pixel gap between every sprite you're using.

Another way is to render into a texture with fixed size, then render that texture into the screen. That should take care of any resampling problem.
mr_tawan


Joined: 13 Jan 2014
Posts: 161
I have been thinking about SDL_RenderSetLogicalSize() for a while. May be its proper behavior is to do the post-processing (render everything in logical size space, then scale it to match the real window size), rather than to scale each object when it's rendered on the screen. This should solve artifacts problem in the case that no scaling involed with each object (I mean, every object is rendered at it size in logical size space).

Scaling at the render time also cause the edge of the object contains artifact even if there a gaps between objects, except that the gap contain exact copy of the edge of the object. That would makes 2 gaps between object, or 1 pixel-border on every object in other words.

Ps. I'm not really sure if I have expressed clearly enough or not. Admitted that English is not my first language, sorry about that.
samleo


Joined: 04 Mar 2014
Posts: 37
Location: Brazil
mr_tawan wrote:
Well, I think it's not really a bug, but it is the way hw-accelerated works.

Another way is to render into a texture with fixed size, then render that texture into the screen. That should take care of any resampling problem.


Sorry to AlexRou, the code with the first solution works well.
mr_tawan, does it's normal lose quality on resizing the window? The bug, for that I see, was something related to get the source from image, so this is too related to scaling?

Sorry for all, I write just few lines because my English it's not so good I'm brazilian huehuehue
SDL_RenderCopy weird bug
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Yeah, this is a fundamental problem with the current implementation of SDL_RenderSetLogicalSize(), as it doesn't handle scaling very well (e.g. seams, lines the wrong width, etc.)

We're seriously considering reimplementing it in terms of a render to texture implementation, which takes more memory but solves all of these issues.



On Sun, Jun 15, 2014 at 11:31 AM, mr_tawan wrote:
Quote:
I have been thinking about SDL_RenderSetLogicalSize() for a while. May be its proper behavior is to do the post-processing (render everything in logical size space, then scale it to match the real window size), rather than to scale each object when it's rendered on the screen. This should solve artifacts problem in the case that no scaling involed with each object (I mean, every object is rendered at it size in logical size space).

Scaling at the render time also cause the edge of the object contains artifact even if there a gaps between objects, except that the gap contain exact copy of the edge of the object. That would makes 2 gaps between object, or 1 pixel-border on every object in other words.

Ps. I'm not really sure if I have expressed clearly enough or not. Admitted that English is not my first language, sorry about that.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: SDL_RenderCopy weird bug
mr_tawan


Joined: 13 Jan 2014
Posts: 161
Actually I'm pretty interested in this topic. I went on checking out the code to see what can I do. Although it might not be so hard to implement the functionality (which involved with using a render target and performing screen-space coordinate transformation on mouse input) at the application level, it does look complicated to implement at the library and/or API level.

Just my 2 cents. :-)

Sam Lantinga wrote:
Yeah, this is a fundamental problem with the current implementation of SDL_RenderSetLogicalSize(), as it doesn't handle scaling very well (e.g. seams, lines the wrong width, etc.)

We're seriously considering reimplementing it in terms of a render to texture implementation, which takes more memory but solves all of these issues.



On Sun, Jun 15, 2014 at 11:31 AM, mr_tawan wrote:
Quote:
I have been thinking about SDL_RenderSetLogicalSize() for a while. May be its proper behavior is to do the post-processing (render everything in logical size space, then scale it to match the real window size), rather than to scale each object when it's rendered on the screen. This should solve artifacts problem in the case that no scaling involed with each object (I mean, every object is rendered at it size in logical size space).

Scaling at the render time also cause the edge of the object contains artifact even if there a gaps between objects, except that the gap contain exact copy of the edge of the object. That would makes 2 gaps between object, or 1 pixel-border on every object in other words.

Ps. I'm not really sure if I have expressed clearly enough or not. Admitted that English is not my first language, sorry about that.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Very Happy
Re: SDL_RenderCopy weird bug
tjpalmer


Joined: 02 Mar 2015
Posts: 8
Hello! First post here.

I have a single 320x200 texture that I draw scaled with SDL_RenderCopy, and I still get pixel artifacts within the scaled image. Look between the middle rows of these bricks:



Is this to be expected? And what's the best workaround?

Currently, I'm imagining either (1) render a higher-pixel texture manually or (2) learn deep GL voodoo (including pixel shaders). I'm pretty sure the first would work, but it would get more CPU intensive. I know very little GL, so that's a steep learning curve, and I'd presumably still have lots of ropes to learn.

Thanks much for any advice. I posted in this topic, because it seems related, although I'm not rendering multiple tiles here, just one 320x200 texture with tile-looking things inside it.