Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » clear_to_color problem

This thread is locked; no one can reply to it. rss feed Print
 1   2 
clear_to_color problem
Richard Phipps
Member #1,632
November 2001
avatar

I've just changed my project from using a dynamic linked 4.0.3 allegro version to a static linked 4.1.14.

Despite make failing when creating the docs, (using GCC 2.95) the library seems ok.

However my program now crashes using:

void clear_to_color(BITMAP *bitmap, int color);

so:

clear_to_color(bmp, 0);

crashes..

Anyone else had this? :(

ReyBrujo
Moderator
January 2001
avatar

Obvious questions: bmp is a valid pointer? I have seen someone passed three parameters to clear_to_color... has it changed in the WIP?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

Yes, no code changed, but it suddenly started crashing on clear_to_color. I'm not sure whether the lib was built ok, it seems to have been..

Plus, I've gone from 4.0.3 to 4.1.14 so I'm not sure if this the cause.

X-G
Member #856
December 2000
avatar

Base check: Did you recompile your entire project, deleting all intermediate files first, after changing to the WIP?

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Richard Phipps
Member #1,632
November 2001
avatar

Yes, all object files were deleted. Compiling with static linking no problems. GDB doesn't seem to help.

Changing to clear_bitmap(bmp); works.. But I do need to be able to clear to a colour in some cases.

ReyBrujo
Moderator
January 2001
avatar

And if you pass a color, it hungs? Try compiling your program with the debug allegro library, triggering gdb, and letting it hung. You set up your GFX mode before calling it?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

I tried using GDB it shows _mangled main after the clear_to_colour.

I just recompiled the exhello example with static linking and 640 x 480 (my LCD monitor can't display less than this). It also crashes. :-/

EDIT: commenting out the clear_to_colour line makes it work fine.

ReyBrujo
Moderator
January 2001
avatar

Can you create the smallest program triggering the error? And you cannot debug with GDB, unless you put a breakpoint in the clear_to_color call. MinGW?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

1/*
2 * Example program for the Allegro library, by Shawn Hargreaves.
3 *
4 * This is a very simple program showing how to get into graphics
5 * mode and draw text onto the screen.
6 */
7 
8#include "allegro.h"
9 
10 
11int main(void)
12{
13 /* you should always do this at the start of Allegro programs */
14 if (allegro_init() != 0)
15 return 1;
16 
17 /* set up the keyboard handler */
18 install_keyboard();
19 
20 /* set a graphics mode sized 320x200 */
21 if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
22 if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
23 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
24 allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
25 return 1;
26 }
27 }
28 
29 /* set the color palette */
30 set_palette(desktop_palette);
31 
32 /* clear the screen to white */
33 // Uncomment and it crashes.
34 //clear_to_color(screen, makecol(255, 255, 255));
35 
36 /* you don't need to do this, but on some platforms (eg. Windows) things
37 * will be drawn more quickly if you always acquire the screen before
38 * trying to draw onto it.
39 */
40 acquire_screen();
41 
42 /* write some text to the screen with black letters and transparent background */
43 textout_centre_ex(screen, font, "Hello, world!", SCREEN_W/2, SCREEN_H/2, makecol(0,0,0), -1);
44 
45 /* you must always release bitmaps before calling any input functions */
46 release_screen();
47 
48 /* wait for a keypress */
49 readkey();
50 
51 return 0;
52}
53 
54END_OF_MAIN();

I'm not sure about GDB, I use MinGW yes..

ReyBrujo
Moderator
January 2001
avatar

I have WIP 13 installed. Can you give me the command line to compile the file? Sorry, I don't have the WIP in source, wiped it after installing. I want to see if I can reproduce it with the previous WIP.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

Hmmm..

Quote:

gcc.exe "C:\Allegro\examples\exhello.c" -o "C:\Allegro\examples\exhello.exe" -DALLEGRO_STATICLINK -fexpensive-optimizations -g3 -mwindows -I"C:\Dev-CPP\include" -L"C:\Dev-CPP\lib" -lalleg_s -lgdi32 -ldxguid -lole32 -ldinput -lddraw -lwinmm -ldsound

This WORKS.

Quote:

gcc.exe "C:\Allegro\examples\exhello.c" -o "C:\Allegro\examples\exhello.exe" -DALLEGRO_STATICLINK -fexpensive-optimizations -O3 -g3 -mwindows -I"C:\Dev-CPP\include" -L"C:\Dev-CPP\lib" -lalleg_s -lgdi32 -ldxguid -lole32 -ldinput -lddraw -lwinmm -ldsound

This crashes to desktop and puts windows into 640 x 480 x 8bit mode.

The -O3 seems to cause the crash!

ReyBrujo
Moderator
January 2001
avatar

Hmm... some optimization went wierd... try -O2 (I don't know why people use -O3 in projects that are not C++).

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

X-G
Member #856
December 2000
avatar

-O3 is a pretty aggressive optimization level that some times breaks programs. -O2 is really the max you can go for safely...

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Richard Phipps
Member #1,632
November 2001
avatar

Quote:

-O3 is a pretty aggressive optimization level that some times breaks programs. -O2 is really the max you can go for safely...

I didn't know this. :o

Uhhhh.. Guys. -O or -O2 crashes as well.. :'( Only no optimization makes it work (and this it the exhello example here).

Can anyone else test this?

ReyBrujo
Moderator
January 2001
avatar

Just noticed I didn't have the static libraries. Will test with the latest WIP on MSVC.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

I just downloaded the 4.1.13, make and make install (with STATICLINK=1) reported no problems.

Trying to compile the exhello program with any optimization still crashes.
It there possibly something wrong with those commandline options? I've only ever used dynamic linking.

ReyBrujo
Moderator
January 2001
avatar

Your example with the 4.1.14 and the command line you said that did not work... worked here. So, it must be something there...

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

Oh damn. :(

EDIT: That is with the -O3 optimization?

ReyBrujo
Moderator
January 2001
avatar

Yep, worked with them, and without the Dev-C++ paths. Maybe those paths are messing something up?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

I have an older GCC, v2.95 I think. Is it possibly related to this?

ReyBrujo
Moderator
January 2001
avatar

Hmm... I have that version at home, not here. I will check it out later today (8 or so hours from now). I doubt it is related to GCC, though.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Sirocco
Member #88
April 2000
avatar

Side note: On older version of Allegro 3.xx, clear_to_color() regularly failed on me, which was why I almost never used it prior to migrating to 4.xx. I also had similar problems assigning sub-bitmaps, but that's another story entirely ^.^

-->
Graphic file formats used to fascinate me, but now I find them rather satanic.

Richard Phipps
Member #1,632
November 2001
avatar

Well, dynamic linking with 4.1.13 or 4.1.14 doesn't work either. Despite doing a make uninstall and a clean build.

It looks like I'm stuck with 4.0.3 then. :(

Evert
Member #794
November 2000
avatar

Quote:

I have an older GCC, v2.95 I think. Is it possibly related to this?

Possibly - I'll have a look at the problem when I get home and see if I can trace it to the source.
Meanwhile, could you possibly try with a newer version of gcc?

Richard Phipps
Member #1,632
November 2001
avatar

I did download the latest GCC file, but it crashes winace and winzip can't read it.

Gah!

Anyway, I need to do some more programming on my game now as I have a lot to do. I'll try to look at this when it's done..

 1   2 


Go to: