Hello all:
Im working with the winbgim library, that I downloaded form the Update Packages tool. First I recompiled it in order to generate the static library (no problem with that), and could run a great quantity of examples and they run as expected.
But when I tried to use the setbkcolor() function it seems not to work, because the expected result is that all the screen color changes, an example of this is taken form the winbgim doc site: http://www.cs.colorado.edu/~main/bgi/doc/getbkcolor.html
Please note that I changed setcolor(EGA_BLUE) to BLUE to the function parameter in the original example, so when the for loop reaches 15 in bkcolor, the message is displayed in BLUE.
Daniel Benavides.
include <winbgim.h>
include <stdlib.h>
include <stdio.h>
include <conio.h>
int main(void)
{
/ _select driver and mode that supports multiple background colors/
int gdriver = EGA, gmode = EGAHI, errorcode;
int bkcol, maxcolor, x, y;
char msg[80];
/ initialize graphics and local variables /
initgraph(&gdriver, &gmode, "");
/ read result of initialization /
errorcode = graphresult();
if (errorcode != grOk) { / an error occurred /
printf("Graphicserror:%s\n",grapherrormsg(errorcode));printf("Pressanykeytohalt:");getch();exit(1);/* terminate with an error code */
}
/ maximum color index supported /
maxcolor = getmaxcolor();
/ for centering text messages /
settextjustify(CENTER_TEXT, CENTER_TEXT);
x = getmaxx() / 2;
y = getmaxy() / 2;
/ loop through the available colors /
for (bkcol=0; bkcol<=maxcolor; bkcol++) {
/* clear the screen */cleardevice();/* select a new background color */setbkcolor(bkcol);/* output a messsage */if(bkcol==WHITE)setcolor(BLUE);sprintf(msg,"Backgroundcolor:%d",bkcol);outtextxy(x,y,msg);getch();
}
/ clean up /
closegraph();
return 0;
}
My compile log, under a Console GDI project:
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\DANIEL\Escritorio\example\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\DANIEL\Escritorio\example\Makefile.win" all
g++.exe main.o -o "example.exe" -L"L:/Dev-Cpp/lib" -lbgi -lgdi32 -luser32
Execution terminated
Compilation successful
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, Im a little confused because in my PC (Win XP) I get a new message each time I hit a key, but the color still the same (black).
Im using Dev-C++ 4.9.9.2.
I dont know what could be the cause.
Appreciate your help.
Daniel Benavides
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry about no logging me in my last post.
I was wondering if could be the driver of my video card.
Even when I put "gdriver = DETECT;" I obtain the same result (no back color changes).
Thanks.
Daniel Benavides
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-01-05
The documentation for WinBGIm for initgraph() (http://www.cs.colorado.edu/%7Emain/cs1300/doc/bgi/initgraph.html) has a 'Windows Note':
'The winbgim version of initgraph uses its parameters only to determine the size of the window that will be created. For example, initgraph(CGA, CGAC3) will create a 320 x 200 window. As an alternative, the user may call initwindow(width, height) instead of initgraph.'
So the values you are passing have no effect they are there primarily to support legacy code applications from a time before re-sizable windows.
Have you tried using the RGB color model instead of BGI basic colours?
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all:
I was trying to get work the setbkcolor() function and found in the winbgim.cpp a little mistake.
Please take a look of this example, run it, and if you have downloaded the original Console GDI package from the Dev-C tool, the result should be that both functions below used, getbkcolor() and setbkcolor(), return the same, but its not the case.
Daniel Benavides
include <winbgim.h>
include <stdio.h>
include <conio.h>
include <iostream.h>
int main(void)
{
int bkcolor, x, y;
char msg[40];
int realcolor, maxcolor;
initwindow(400,400);
maxcolor=getmaxcolor();
x= 200; y=200;
/ loop through some available colors /
for (bkcolor=0; bkcolor<=maxcolor; bkcolor++) {
/* clear the screen */
cleardevice();
setbkcolor( bkcolor);
sprintf( msg, "Actually set color #: %d", bkcolor );
outtextxy(x, y, msg);
getch();
/* output a text messsage when back ground is Blue */
if (getbkcolor() == bkcolor ){
//setcolor(BLUE);
cout<<"\n The color match "<<bkcolor;
}
realcolor=getbkcolor();
sprintf( msg, "The got getbkcolor #: %d", realcolor );
outtextxy(x, y, msg);
getch();
}
/ clean up /
closegraph();
getch();
return 0;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem in winbgim.cpp source is in its function source:
void setbkcolor(int color)//
{... bkcolor ...}
The problem is here, the above function does not work, because in its body the parameter is not used.
Besides getbkcolor(), seems to dont work properly too, well, thats because the bkcolor global variable is overwritten by the function parameter, so its no changed really, and its not a good idea put bkcolor as parameter to match the body of the function.
You can try the changed code of the both corrected functions and see the difference with the original code of winbgim.cpp
void setbkcolor(int colors)//The problem is here
{
// Version 3.2: Color may now be a bgi color (0 to MAXCOLORS) or an RGB color.
Well I Got it from Dev C 4.9.9.2 update tool in
Menu - Tools -> Check For Updates/Packages
Devpack server: Dev-C++ Primary server
Group: Games & Graphics
Update: Console GDI
Yes of course is open source, this project is about that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
actually clifford meant that winbgim is open source.
note every devpak wraps open source, and certianly not as open source as winbgim.
do not make the assumption that just because you dled something in the form of a devpak that it is open source at all let alone gpl or some specific license.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The above code works well (the RE6 post), but with the below correction is better.
This starts in the line 851, of the winbgim.cpp, source that is installed in \DevCpp\include\
void setbkcolor(int colors)
{
// Version 3.2: Color may now be a bgi color (0 to MAXCOLORS) or an RGB color.
bkcolor=colors;
if (IS_BGI_COLOR(colors))
{
SetBkColor(hdc[0], PALETTEINDEX(BG+colors));
SetBkColor(hdc[1], PALETTEINDEX(BG+colors));
DeleteObject(hBackgroundBrush);
hBackgroundBrush = CreateSolidBrush(PALETTEINDEX(BG+colors));
int getbkcolor()
{
// or an RGB color.
return bkcolor;
}---------------
My (RE5) example (correcting the changed less and greater than symbols and quots), it works fine and it shows the property of the library:
"Also only future drawing will use the new background color (anything currently drawn in the old background color will stay in the old color)" of the winbgim documentation site: http://www.cs.colorado.edu/%7Emain/cs1300/doc/bgi/setbkcolor.html
This correction works with RGB colors too.
Hey thanks all; is very helpful the posts of Clifford and all of you that post and read this topic. Sorry, if I dont got it all of your comments.
Daniel Benavides
Bogota, Colombia.
Daniel Benavides
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But I agree with the lasts post, it should be the most recent in the Dev-C++ primary dev pack server.
Daniel Benavides
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-01-09
'Yes of course is open source, this project is about that. '
I am not sure why you are making that point. I was merely pointing out that because it is open source, not all copies of the source are the same, therefore you might find a working version elsewhere.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all:
Im working with the winbgim library, that I downloaded form the Update Packages tool. First I recompiled it in order to generate the static library (no problem with that), and could run a great quantity of examples and they run as expected.
But when I tried to use the setbkcolor() function it seems not to work, because the expected result is that all the screen color changes, an example of this is taken form the winbgim doc site:
http://www.cs.colorado.edu/~main/bgi/doc/getbkcolor.html
Please note that I changed setcolor(EGA_BLUE) to BLUE to the function parameter in the original example, so when the for loop reaches 15 in bkcolor, the message is displayed in BLUE.
Daniel Benavides.
include <winbgim.h>
include <stdlib.h>
include <stdio.h>
include <conio.h>
int main(void)
{
/ _select driver and mode that supports multiple background colors/
int gdriver = EGA, gmode = EGAHI, errorcode;
int bkcol, maxcolor, x, y;
char msg[80];
/ initialize graphics and local variables /
initgraph(&gdriver, &gmode, "");
/ read result of initialization /
errorcode = graphresult();
if (errorcode != grOk) { / an error occurred /
}
/ maximum color index supported /
maxcolor = getmaxcolor();
/ for centering text messages /
settextjustify(CENTER_TEXT, CENTER_TEXT);
x = getmaxx() / 2;
y = getmaxy() / 2;
/ loop through the available colors /
for (bkcol=0; bkcol<=maxcolor; bkcol++) {
}
/ clean up /
closegraph();
return 0;
}
My compile log, under a Console GDI project:
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\DANIEL\Escritorio\example\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\DANIEL\Escritorio\example\Makefile.win" all
g++.exe main.o -o "example.exe" -L"L:/Dev-Cpp/lib" -lbgi -lgdi32 -luser32
Execution terminated
Compilation successful
seems to work here. every time i hit a key the window color the text color and the background color of the text changes.
Well, Im a little confused because in my PC (Win XP) I get a new message each time I hit a key, but the color still the same (black).
Im using Dev-C++ 4.9.9.2.
I dont know what could be the cause.
Appreciate your help.
Daniel Benavides
Sorry about no logging me in my last post.
I was wondering if could be the driver of my video card.
Even when I put "gdriver = DETECT;" I obtain the same result (no back color changes).
Thanks.
Daniel Benavides
The documentation for WinBGIm for initgraph() (http://www.cs.colorado.edu/%7Emain/cs1300/doc/bgi/initgraph.html) has a 'Windows Note':
'The winbgim version of initgraph uses its parameters only to determine the size of the window that will be created. For example, initgraph(CGA, CGAC3) will create a 320 x 200 window. As an alternative, the user may call initwindow(width, height) instead of initgraph.'
So the values you are passing have no effect they are there primarily to support legacy code applications from a time before re-sizable windows.
Have you tried using the RGB color model instead of BGI basic colours?
Clifford
Hi all:
I was trying to get work the setbkcolor() function and found in the winbgim.cpp a little mistake.
Please take a look of this example, run it, and if you have downloaded the original Console GDI package from the Dev-C tool, the result should be that both functions below used, getbkcolor() and setbkcolor(), return the same, but its not the case.
Daniel Benavides
include <winbgim.h>
include <stdio.h>
include <conio.h>
include <iostream.h>
int main(void)
{
int bkcolor, x, y;
char msg[40];
int realcolor, maxcolor;
initwindow(400,400);
maxcolor=getmaxcolor();
x= 200; y=200;
/ loop through some available colors /
for (bkcolor=0; bkcolor<=maxcolor; bkcolor++) {
}
/ clean up /
closegraph();
getch();
return 0;
}
The problem in winbgim.cpp source is in its function source:
void setbkcolor(int color)//
{... bkcolor ...}
The problem is here, the above function does not work, because in its body the parameter is not used.
Besides getbkcolor(), seems to dont work properly too, well, thats because the bkcolor global variable is overwritten by the function parameter, so its no changed really, and its not a good idea put bkcolor as parameter to match the body of the function.
You can try the changed code of the both corrected functions and see the difference with the original code of winbgim.cpp
void setbkcolor(int colors)//The problem is here
{
// Version 3.2: Color may now be a bgi color (0 to MAXCOLORS) or an RGB color.
}
int getbkcolor()
{
// or an RGB color.
return bkcolor - 15;
}
The -15 value, is a correction to the value, you can see what happens if getbkcolor() is not changed and compiling the static library.
Daniel Benavides
the win32 version should support more than 16 colors of old bgim.
you had the old version somehow. the newest version works.
it should have 3.5 at the additions at the top of the source.
Wher did you get WinBGIm from - it is open source and there are several versions knocking around which may have 'fixes':
http://www.cs.colorado.edu/%7Emain/cs1300/doc/bgi/bgi.html
http://www.codecutter.net/tools/winbgim/
http://www14.brinkster.com/aditsu/console/
Clifford
Well I Got it from Dev C 4.9.9.2 update tool in
Menu - Tools -> Check For Updates/Packages
Devpack server: Dev-C++ Primary server
Group: Games & Graphics
Update: Console GDI
Yes of course is open source, this project is about that.
actually clifford meant that winbgim is open source.
note every devpak wraps open source, and certianly not as open source as winbgim.
do not make the assumption that just because you dled something in the form of a devpak that it is open source at all let alone gpl or some specific license.
The above code works well (the RE6 post), but with the below correction is better.
This starts in the line 851, of the winbgim.cpp, source that is installed in \DevCpp\include\
void setbkcolor(int colors)
{
// Version 3.2: Color may now be a bgi color (0 to MAXCOLORS) or an RGB color.
bkcolor=colors;
if (IS_BGI_COLOR(colors))
{
SetBkColor(hdc[0], PALETTEINDEX(BG+colors));
SetBkColor(hdc[1], PALETTEINDEX(BG+colors));
DeleteObject(hBackgroundBrush);
hBackgroundBrush = CreateSolidBrush(PALETTEINDEX(BG+colors));
}
int getbkcolor()
{
// or an RGB color.
return bkcolor;
}---------------
My (RE5) example (correcting the changed less and greater than symbols and quots), it works fine and it shows the property of the library:
"Also only future drawing will use the new background color (anything currently drawn in the old background color will stay in the old color)" of the winbgim documentation site:
http://www.cs.colorado.edu/%7Emain/cs1300/doc/bgi/setbkcolor.html
This correction works with RGB colors too.
Hey thanks all; is very helpful the posts of Clifford and all of you that post and read this topic. Sorry, if I dont got it all of your comments.
Daniel Benavides
Bogota, Colombia.
Daniel Benavides
well maybe you should send the devpak repositry project an updated devpak?
you went through the trouble of fixing it why not share the fix by defualt?
Yes, this bug was already fixed in the version of the site:
http://www14.brinkster.com/aditsu/console/
But I agree with the lasts post, it should be the most recent in the Dev-C++ primary dev pack server.
Daniel Benavides
'Yes of course is open source, this project is about that. '
I am not sure why you are making that point. I was merely pointing out that because it is open source, not all copies of the source are the same, therefore you might find a working version elsewhere.
Clifford