We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5483 - SDL_RenderDrawRect not rectangular
Summary: SDL_RenderDrawRect not rectangular
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.15
Hardware: x86_64 Linux
: P2 blocker
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.16
Depends on:
Blocks:
 
Reported: 2021-01-19 11:06 UTC by David Connolly
Modified: 2021-01-25 09:47 UTC (History)
0 users

See Also:


Attachments
Display of SDL_RenderDrawRect (4.36 KB, image/png)
2021-01-19 11:06 UTC, David Connolly
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Connolly 2021-01-19 11:06:36 UTC
Created attachment 4679 [details]
Display of SDL_RenderDrawRect

Using SDL_RenderDrawRect does not produce a perfect rectangle anymore.

The bottom line seems to be out by one pixel. 

See attached screenshot.

--------------------------

//Using SDL and standard IO
#include <SDL2/SDL.h>
#include <stdio.h>

//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int main( int argc, char* args[] )
{
    //The window we'll be rendering to
    SDL_Window* window = NULL;
    
    SDL_Renderer* renderer = NULL;
	
    //Initialize SDL
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
    }
    else
    {
        //Create window
        window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
        if( window == NULL )
        {
            printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
        }
        else
        {
	    renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED );
	    if( renderer == NULL )
	    {
		printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
	    }

	    SDL_Rect outlineRect = { SCREEN_WIDTH / 6, SCREEN_HEIGHT / 6, SCREEN_WIDTH * 2 / 3, SCREEN_HEIGHT * 2 / 3 };
            SDL_SetRenderDrawColor( renderer, 0x00, 0xFF, 0x00, 0xFF );        
            SDL_RenderDrawRect( renderer, &outlineRect );
	    
	    SDL_Rect outlineRect2 = { SCREEN_WIDTH / 4, SCREEN_HEIGHT / 4, SCREEN_WIDTH * 2 / 4, SCREEN_HEIGHT * 2 / 4 };
            SDL_SetRenderDrawColor( renderer, 0xFF, 0xFF, 0x00, 0xFF );        
            SDL_RenderDrawRect( renderer, &outlineRect2 );
	    
	    SDL_Rect outlineRect3 = { SCREEN_WIDTH / 3, SCREEN_HEIGHT / 3, SCREEN_WIDTH / 3, SCREEN_HEIGHT / 3 };
            SDL_SetRenderDrawColor( renderer, 0xFF, 0xFF, 0xFF, 0xFF );        
            SDL_RenderDrawRect( renderer, &outlineRect3 );
	    	    
	    SDL_RenderPresent( renderer );
		
            //Wait two seconds
            SDL_Delay( 5000 );
        }
    }	
    //Destroy window
    SDL_DestroyWindow( window );

    //Quit SDL subsystems
    SDL_Quit();

    return 0;
}
Comment 1 David Connolly 2021-01-19 11:08:10 UTC
This is from latest HG 2.0.15
Comment 2 David Connolly 2021-01-25 09:47:00 UTC
Seems to be caused by http://hg.libsdl.org/SDL/rev/ba7112eeb065