Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » MASkinG question

This thread is locked; no one can reply to it. rss feed Print
MASkinG question
kholdstayr
Member #7,575
August 2006

I've been reading about the MASkinG library and I am confused on one thing. The information about MASkinG's own Bitmap wrapper class suggests that it shouldn't be used and instead we should use Allegro's own built in graphics functions. I am wondering how you can extract the Allegro BITMAP object that the MASkinG Bitmap class contains, in order to draw on it with the Allegro functions.

Say for example you are making a widget for use with MASkinG. The draw method for the Widget you create is called by the MASkinG system with a MASkinG Bitmap object as its argument. Basically, I am wondering how you can take the MASkinG Bitmap object and use the standard Allegro graphics drawing functions on the Allegro style BITMAP structure that it contains.

I looked through the MASkinG Bitmap.h header and I couldn't seem to find any function that returns an Allegro BITMAP*, so I am not sure how you would do this. I suppose I could hack the code or something but I would rather not break anything.

miran
Member #2,407
June 2002

Hmm, well, that documentation might not be completely accurate. I changed my mind about this 20 times over. In the end I decided to keep the documentation as is, but there's nothing wrong if you use Bitmap's functions. In the end they're just wrappers for Allegro's BITMAP functions.

As for your question, the Bitmap class has a conversion operator that converts a Bitmap to a BITMAP (in fact it just returns the underlying BITMAP pointer, so no real conversion is actually done). This means that you can use a Bitmap as if it was a BITMAP. For example:

class MyWidget : public Widget {
   protected:
      void Draw(Bitmap &canvas) {
         clear_to_color(canvas);
         rectfill(canvas, 10, 20, 30, 40, makecol(123,123,123));
         circlefill(canvas, 30, 40, 20, Color(200,100,100));
         line(canvas, 20, 30, 40, 50, Color::green);
      }
};

--
sig used to be here

kholdstayr
Member #7,575
August 2006

Thanks for the response. I didn't have a chance to install MASKing when I had asked the question yesterday, so I couldn't look at the official documentation that comes with the install.

Anyway, just now I tried to install the AllegroFont library that MASkinG requires and I have some compiling errors. I am using the latest mingw compiler with allegro 4.2 and I made sure to uncomment the appropriate line in the makefile (TARGET=MINGW32_STATIC). I also checked the .h file as the AllegroFont readme said to. When I run make on the makefile I get the following compiler error:

1C:\mingw\AlFont206>mingw32-make
2gcc -c -Wall -O2 -march=pentium -fomit-frame-pointer -finline-functions -ffast-m
3ath -Ifreetype/include -Iinclude src/alfont.c -o obj/mingw32/static/alfont.o
4In file included from src/alfont.c:17:
5include/alfont.h:464:3: warning: no newline at end of file
6src/alfont.c: In function `alfont_textout_aa_ex':
7src/alfont.c:876: error: invalid lvalue in unary `&'
8src/alfont.c:876: error: invalid lvalue in unary `&'
9src/alfont.c: In function `alfont_textout_ex':
10src/alfont.c:1962: error: invalid lvalue in unary `&'
11src/alfont.c:1962: error: invalid lvalue in unary `&'
12src/alfont.c: In function `alfont_text_length':
13src/alfont.c:2740: error: invalid lvalue in unary `&'
14src/alfont.c:2740: error: invalid lvalue in unary `&'
15src/alfont.c: In function `alfont_ugetc':
16src/alfont.c:3052: warning: unused variable `lpszW_pointer'
17mingw32-make: *** [alfont.o] Error 1

I get the exact same error if I try to compile AllegroFont library as a DLL as well.

miran
Member #2,407
June 2002

Use an older version of AlFont. I have v1.9something on my MASkinG page. Apparently the guy who decided to continue to develop AlFont after the original author abandoned it isn't doing a very good job...

--
sig used to be here

Go to: