Color display error in fullscreen mode Win 7[SOLVED]

General FreeBASIC programming questions.
Post Reply
elsairon
Posts: 207
Joined: Jul 02, 2005 14:51

Color display error in fullscreen mode Win 7[SOLVED]

Post by elsairon »

I made this little program to dump a small selection of colors I'm planning to use for a game.

However I noticed that when I switch to fullscreen using alt+enter (win 7) some of the colors are displayed incorrectly even though the displayed rgb values remain correct.

Does this happen for anyone else, or am I looking at a faulty screen hardware?

Code: Select all

#pragma once
#define RGBA_R( c ) ( CUInt( c ) Shr 16 And 255 )
#define RGBA_G( c ) ( CUInt( c ) Shr  8 And 255 )
#define RGBA_B( c ) ( CUInt( c )        And 255 )
#define RGBA_A( c ) ( CUInt( c ) Shr 24         )

ENUM ColorNames
    LIGHT_RED = 012
    INTENSE_RED = 040
    RED = 004
    DARK_RED = 112
    BLACK_RED = 184

    LIGHT_BLUE = 009
    INTENSE_BLUE = 032
    BLUE = 001           
    DARK_BLUE = 104
    BLACK_BLUE = 176
    
    LIGHT_YELLOW = 068
    INTENSE_YELLOW = 044
    YELLOW = 014
    DARK_YELLOW = 116
    BLACK_YELLOW = 188
    
    LIGHT_CYAN = 011
    INTENSE_CYAN = 052
    CYAN = 003
    DARK_CYAN = 124
    BLACK_CYAN = 196
    
    LIGHT_MAGENTA = 013
    INTENSE_MAGENTA = 036
    MAGENTA = 005
    DARK_MAGENTA = 108
    BLACK_MAGENTA = 180
    
    LIGHT_BROWN = 066
    INTENSE_BROWN = 042
    BROWN = 006
    DARK_BROWN = 114
    BLACK_BROWN = 186
    
    LIGHT_GREEN = 010
    INTENSE_GREEN = 048
    GREEN = 002
    DARK_GREEN = 120
    BLACK_GREEN = 192
    
    BRIGHT_WHITE = 015
    WHITE =  007
    GREY =  008
    GRAY =  008
    DARK_GREY = 019
    DARK_GRAY = 019
    BLACK = 000
END ENUM

DIM AS INTEGER _COLORS( 1 to 40 ) = { _
    LIGHT_RED, INTENSE_RED, RED, DARK_RED, BLACK_RED, _
    LIGHT_BLUE, INTENSE_BLUE, BLUE, DARK_BLUE, BLACK_BLUE, _
    LIGHT_YELLOW, INTENSE_YELLOW, YELLOW, DARK_YELLOW, BLACK_YELLOW, _
    LIGHT_CYAN, INTENSE_CYAN, CYAN, DARK_CYAN, BLACK_CYAN, _
    LIGHT_MAGENTA, INTENSE_MAGENTA, MAGENTA, DARK_MAGENTA, BLACK_MAGENTA, _
    LIGHT_BROWN, INTENSE_BROWN, BROWN, DARK_BROWN, BLACK_BROWN, _    
    LIGHT_GREEN, INTENSE_GREEN, GREEN, DARK_GREEN, BLACK_GREEN, _
    BRIGHT_WHITE, WHITE, GREY, DARK_GREY, BLACK }

sub show_rgb( byval c as integer )
    
    dim as integer pr, pg, pb
    
    palette get c, pr, pg, pb
    
    Print Using "R:###"; pr;
    Print Using " G:###"; pg;
    Print Using " B:###"; pb
            
end sub


SCREEN 17
WIDTH 80, 25

dim as integer i, j, c, tc = 0, cline = 0
for i = 1 to 4
    for j = 1 to 5
        cline += 1
        tc += 1
        c = _colors( tc )
        color c
        
        locate cline, 1
        ? "# ";
        color BRIGHT_WHITE
        show_rgb( c )
    next j
next

cline = 0
for i = 5 to 8
    for j = 1 to 5
        cline += 1
        tc += 1
        c = _colors( tc )
        color c
        locate cline, 22
        ? "# ";
        color BRIGHT_WHITE
        show_rgb( c )
    next j
next

sleep

end

edit: Bug report 3462334 lists pcopy and screenset not working in fullscreen mode. I'm not sure if this is related, or should be listed separately.

edit: fix typo
Last edited by elsairon on Jun 09, 2012 20:10, edited 3 times in total.
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Colors change when switching to fullscreen using alt+ent

Post by Richard »

Yes, they change for me too. I think you are looking at a Win7 colour compatibility problem.
As you say the data is not changed, it restores correctly every time.
elsairon
Posts: 207
Joined: Jul 02, 2005 14:51

Re: Color display error in fullscreen mode

Post by elsairon »

Hmmm. Is this an error in the compiler, or is there a more robust way to define colors so they work in both normal and full screen modes?
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Color display error in fullscreen mode

Post by Richard »

Screenres 640, 400, 8
does the same

It appears to be a Palette problem. I think Win7 is misinterpreting the FB colour format being used.
If you use 32 bit colour mode rather than a byte indexed palette, then I think it should work OK.
elsairon
Posts: 207
Joined: Jul 02, 2005 14:51

Re: Color display error in fullscreen mode

Post by elsairon »

Thanks Richard, I'll give that a try.

edit: Using 32 bpp and defining the colors fixes the problem. Thanks again Richard.
Post Reply