Search code examples
cbgi

setbkcolor() ineffective in Dev-C++ 4.9.9.2


I recently started using Dev C++ 4.9.9.2 to experiment with graphics program in C(thanks to this tutorial). But for some reason setbkcolor() does absolutely nothing. Here's the code...

#include <stdio.h>
#include <graphics.h>
#include <conio.h>

int main()
{
    initwindow(800,600);
    setbkcolor(GREEN);   //FAILED. also tried "setbkcolor(2);"
    while ( !kbhit() ){}
    return 0;
}

Here's the Output: black colored screen still

I am using Windows 7 Professional. Is this something to do with the Operating System?


Solution

  • The documentation says in the Windows notes part:

    Also, only future drawing will use the new background color (anything currently drawn in the old background color will stay in the old color). Calling setbkcolor(0) will change the background color to the current color at index [0] of the palette (rather than always changing the background to black).

    You have misunderstood the goal of the function.