Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Flickering border artifacts when using "al_set_clipping_rectangle"

This thread is locked; no one can reply to it. rss feed Print
Flickering border artifacts when using "al_set_clipping_rectangle"
David Couzelis
Member #10,079
August 2008
avatar

I have my video game display coded so that "ALLEGRO_FULLSCREEN_WINDOW" mode will do the largest integer scale possible, then use "al_set_clipping_rectangle" to preserve the aspect ratio.

I expect the "borders" of the clipping rectangle to be black, but instead, they flicker with what looks like screen artifacts. (See attachments)

Here is an excerpt from my display code:

#SelectExpand
1al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW); 2 3/* Initialize the one and only global display for the game */ 4display = al_create_display(width * scale, height * scale); 5 6al_clear_to_color(al_map_rgb(0, 0, 0)); 7 8/* Scale and center the display as big as possible on this screen */ 9set_display_transform(scale, offset_x, offset_y, fullscreen); 10 11/* Crop the drawing area, to not accidentally draw in the black borders */ 12al_set_clipping_rectangle(offset_x, offset_y, display_width * scale, display_height * scale);

Full code here:

https://github.com/drcouzelis/colorwandcastle/blob/master/src/display.c

Is there something I can do to prevent the seizure-inducing flickering around the display area?

My computer:
Arch Linux (current)
Radeon HD 5450, with open source "radeon" driver

Chris Katko
Member #1,881
January 2002
avatar

Did you forget the attachment?

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

David Couzelis
Member #10,079
August 2008
avatar

Haha

Here are the attachments. :D

Elias
Member #358
May 2000

Can you post the source code of set_display_transform?

Also note that the parameters to al_create_display are ignored when you use ALLEGRO_FULLSCREEN_WINDOW.

--
"Either help out or stop whining" - Evert

Edgar Reynaldo
Member #8,592
May 2007
avatar

David Couzelis
Member #10,079
August 2008
avatar

Elias said:

Can you post the source code of set_display_transform?

The full code is here: https://github.com/drcouzelis/colorwandcastle/blob/master/src/display.c

Here it is again, for convenience:

#SelectExpand
1static void set_display_transform(int scale, float offset_x, float offset_y, bool fullscreen) 2{ 3 ALLEGRO_TRANSFORM trans; 4 5 /* Confirm that the display has been created */ 6 assert(al_get_target_bitmap()); 7 8 /** 9 * Scale the coordinates to match the actual size of the display. 10 * It will be performed on the current target bitmap. 11 */ 12 al_identity_transform(&trans); 13 al_scale_transform(&trans, scale, scale); 14 if (fullscreen) { 15 al_translate_transform(&trans, offset_x, offset_y); 16 } 17 al_use_transform(&trans); 18}

Are you clearing the screen?

I think so...

#SelectExpand
1al_clear_to_color(al_map_rgb(0, 0, 0)); 2draw(data); /* DRAW */ 3al_flip_display(); 4redraw = false;

Full source: https://github.com/drcouzelis/colorwandcastle/blob/master/src/run.c

Edgar Reynaldo
Member #8,592
May 2007
avatar

Go to: