Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » textout bug?

This thread is locked; no one can reply to it. rss feed Print
textout bug?
axilmar
Member #1,204
April 2001

I have the following code:

set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);

BITMAP *page1 = create_video_bitmap(SCREEN_W, SCREEN_H);
line(page1, 0, 0, SCREEN_W, SCREEN_H, makecol(255, 255, 255));    
textout(page1, font, "text", SCREEN_W / 2, SCREEN_H / 2, makecol(255, 255, 255));

The line appears on the screen, as it should (because the first page is always the screen, according to this), but the text does not appear on the screen. If I replace 'page1' with 'screen' in the textout, the text is shown normally.

This is on WinXP SP2, Athlon 64, 1 GB ram, GF 6800 GT video card.

EDIT:

I tried the following code, but the moving circle does not appear on page1:

    BITMAP *page2 = create_video_bitmap(SCREEN_W, SCREEN_H);
    clear_bitmap(page2);
    
    int x = 0;
    while (!keypressed()) {
        circlefill(page2, x, SCREEN_H / 2, 64, makecol(255, 255, 255));
        for(int j = 0; j < SCREEN_H / 32; ++j) {
            for(int i = 0; i < SCREEN_W / 32; ++i) {
                blit(page2, page1, i * 32, j * 32, i * 32, j * 32, 32, 32);
            }
        }
        ++x;
    }

It seems there is an issue with video bitmaps in windowed mode; in full-screen mode it plays OK.

Elias
Member #358
May 2000

Did you call show_video_bitmap?

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

kazzmir
Member #1,786
December 2001
avatar

It worked fine for me in windowed mode on Linux. Nothing showed up in fullscreen mode though. Maybe the video bitmap only overlays the physical screen in Windows?

I get the same problem in Windows. I tried calling show_video_bitmap( page ) before and after the textout() line but it didnt help. The white line always shows up though. If line() works shouldnt textout()?

Elias
Member #358
May 2000

In linux, there should be no difference at all between fullscreen and windowed mode, it basically always stays in windowed mode, only VidModeExtension is used to change the monitor resolution (plus some hack to center the window to the visible part).

[Edit:] And blitting one video page to another is not supported I think, only using show_video_bitmap to show the other page.

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

axilmar
Member #1,204
April 2001

I did not use 'show_video_bitmap' because my intention is not page flipping but hardware accelerated buffering.

I do not think blitting from one page to another does not work...because if it did not, then it would not be possible to store the most frequently used bitmaps of a game in the vram.

Elias
Member #358
May 2000

Yes, but the first 2 or 3 screen sized video bitmaps are special cased, and instead of normal video bitmaps, a DirectX display chain is created from them. And blitting from one page of the chain to another causes problems sometimes. At least I remember something like that.

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

Matthew Leverton
Supreme Loser
January 1999
avatar

If you want to use video bitmaps, you really must first create one with dimensions of SCREEN_W/SCREEN_H and use show_video_bitmap() on it. Are you doing that?

Edit: Well, it looks like a bug to me. I'm not able to get text to show up on video bitmaps under a windowed mode (Windows XP), and surely that should be supported.

Here is an example:

1#include <allegro.h>
2 
3int main(void)
4{
5 BITMAP *page1, *page2;
6 allegro_init();
7 install_keyboard();
8 set_color_depth(32);
9 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
10 
11 page1 = create_video_bitmap(SCREEN_W, SCREEN_H);
12 page2 = create_video_bitmap(SCREEN_W, SCREEN_H);
13
14 clear(page1);
15 clear(page2);
16 
17// change this to page1, and it will not work
18 show_video_bitmap(page2);
19 
20 line(page1, 0, 0, SCREEN_W, SCREEN_H, makecol(255, 255, 255));
21 textout_centre_ex(page1, font, "text", SCREEN_W/2,SCREEN_H/2, makecol(255, 255, 255), -1);
22 show_video_bitmap(page1);
23 readkey();
24 
25 destroy_bitmap(page1);
26 destroy_bitmap(page2);
27
28 return 0;
29}
30END_OF_MAIN()

It appears that if using a windowed mode under Windows, the textout routines do nothing if the video bitmap is currently displayed. (Under full screen, it works as one would expect.) However, once you move the window with the mouse, the text magically appears. I don't know how the windowed driver works, but it seems like Windows is not being told to refresh the display.

Go to: