Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_RenderClear not clearing entire render target #1128

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

SDL_RenderClear not clearing entire render target #1128

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.0
Reported for operating system, platform: Windows 7, x86_64

Comments on the original bug report:

On 2013-10-18 21:28:10 +0000, Kevin Wells wrote:

Created attachment 1374
DxDiag with relevant system information

Overview:
SDL_RenderClear is only clearing part of a texture when it is the render target and a different size than the screen.

Steps to Reproduce:

  1. This only occurs with the render driver set to direct3d, so: SDL_SetHint(SDL_HINT_RENDER_DRIVER,"direct3d")
    Also, my window was 1280x720.

  2. Create a texture for a render target with a resolution of 1024x1024:
    texture=SDL_CreateTexture(main_window.renderer,SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_TARGET,1024,1024);
    SDL_SetTextureBlendMode(texture,SDL_BLENDMODE_BLEND);

  3. Target the texture for rendering: SDL_SetRenderTarget(main_window.renderer,texture);

  4. Set the draw color to whatever you want (problem occurs with both 0,0,0,0 and 0,0,0,255 among others) and then clear the render target:
    SDL_SetRenderDrawColor(main_window.renderer,0,0,0,0);
    SDL_RenderClear(main_window.renderer);

Actual Results:
Only about the top 3/4s of the texture gets cleared on calling SDL_RenderClear. The bottom 1/4 or so does not clear.

Expected Results:
Entire render target should be cleared.

Build Date and Hardware:
Stable 2.0.0 on Windows 7 Professional 64-bit (see attached DxDiag for details)

Additional Information:
The size of the window is 1280x720. The size of the texture is 1024x1024. If you create the texture with a size of 1280x720 instead, SDL_RenderClear clears the entire texture.

Using 'SDL_RenderFillRect(main_window.renderer,NULL)' instead of SDL_RenderClear DOES fill the entire texture with color.

I tried a variety of tweaks (playing with different SDL_HINT_'s, texture and renderer settings, etc.) and could not find any way to prevent the problem from happening until I tried 'SDL_SetHint(SDL_HINT_RENDER_DRIVER,"opengl")' which pointed me to the direct3d render driver being the (a part of the?) culprit.

On 2013-10-18 21:31:07 +0000, Kevin Wells wrote:

See the URL for a video showing the bug in action.

The game is a 2D top-down affair, and the animated texture I'm making is falling raindrops. The game world is divided into "chunks" of 1024x1024 pixels, and weather occurs at this resolution, so my 1024x1024 rain texture is rendered over any chunk in which it is raining. As you can see, the bottom section of the texture quickly fills with raindrop color and is never cleared.

On 2013-10-19 08:30:47 +0000, Sam Lantinga wrote:

Okay, I'm not on a windows machine, so I can't test it, but I think this will fix the issue:
http://hg.libsdl.org/SDL/rev/2f2f0b3b4702

Can you try it out and see?

Thanks!

On 2013-10-19 21:21:39 +0000, Kevin Wells wrote:

I would love to, but I don't know how to build SDL from source on Windows. I've been using the pre-built dev binaries built with MinGW. Does anyone build those periodically, do you know? If not, I will try to figure it out.

On 2013-10-21 09:43:54 +0000, Sam Lantinga wrote:

How about this?
http://www.libsdl.org/tmp/release/SDL2-devel-2.0.1-mingw.tar.gz

On 2013-10-22 03:56:07 +0000, Kevin Wells wrote:

Thanks! Yes, that seems to have fixed the problem. The full texture is now being cleared as expected using the direct3d render driver.

On 2013-10-22 04:11:03 +0000, Sam Lantinga wrote:

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant