Flickering border artifacts when using "al_set_clipping_rectangle"
David Couzelis

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:

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:


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

Did you forget the attachment?

David Couzelis


Here are the attachments. :D


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.

Edgar Reynaldo

I can't say what you're doing for sure, but it sounds like you're leaving video memory uninitialized, with undefined contents. Are you clearing the screen?

David Couzelis
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:

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...

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

Bumping this thread so it doesn't get lost.

Can you provide a minimal working (failing) example that does this?

Thread #617185. Printed from Allegro.cc