delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/12/10:53:13

Reply-To: <arfa AT clara DOT net>
From: "Arthur" <arfa AT clara DOT net>
To: "DJGPP Mailing List" <djgpp AT delorie DOT com>,
"Donald Manley" <Rafkin AT pacbell DOT net>
Subject: RE: Help: Allegro and C
Date: Sat, 12 Sep 1998 15:45:17 +0100
Message-ID: <000801bdde5b$f57c5bc0$f54e08c3@arthur>
MIME-Version: 1.0
In-Reply-To: <35F9D634.8805659A@pacbell.net>
Importance: Normal

>    I am new to this news group, so if I get a little carried away,
> forgive me. I am also new to programming in C, having read a tutorial
> from the web on ANSI C, and though inexperienced, follow along pretty
> well with what it says, and can to some extent read code and follow what
> it is doing at which point etc..
>    I have downloaded Allegro for DJGPP, and installed it, and I might
> add, am very impressed with it's demo and examples. It does seem to be a
> very powerfull library, in paticular when it comes to graphics. The
> mouse, and keyboard routines come in handy as well.
>    However, I am having more trouble understanding a few things, and
> would like to take this time to ask several questions related to Allegro
> and to C itself.
>
>    To begin with, though the programs I write can be run from windows,
> they open a dos window to run from. I would like to make it, so that it
> can either be run from dos, or if ran from windows, uses the full screen
> but leaves the taskbar at the bottom, though i do realize that if i do
> this, i would lose the ability to set the resolution for the program. Is
> there a way to do this? How?

Did you realise that DJGPP is a compiler for DOS? Although you can program
apps for Windows using RSXNTDJ (although it's nowhere near as good as a
dedicated Windows compiler), Allegro doesn't support it. You'll need to get
hold of WinAllegro, which is probably what you want. Can't remember the link
off-hand, but visit http://www.talula.demon.co.uk/allegro/ for a link to the
WinAllegro project.

>    I have used example 15, from Allegro's examples to display a bitmap
> to the screen, altering it only in the following way to set an 800x600
> resolution. It is a beginning. I changed the set_gfx_mode to
> (GFX_AUTODETECT, 800, 600, 0, 0). I am not sure what the 0, 0 is for
> yet, but I'll look that up and hope I understand it.

For a virtual screen. Nice, memory hogging, hardware scrolling.

>    What I would like to do is put a mouse pointer on that screen, with a
> pointer I have designed.

There is a command which will do this - check out the "Mouse Routines"
chapter of the manual, particularly the set_mouse_sprite command.

> However, I need to figgure out how  to make the
> main color of that pointer transparent.

In 256-colour (8-bit) mode, the transparent colour is colour index 0. In
true-colour modes it's magenta (maximum red, minimum green, maximum blue).

> I have read the docs Allegro
> provides on transparencies but am having some difficulty understanding
> it. I havn't really had the priviledge of working with color palettes
> before, to understand how they work, wich I figgure is part of why I am
> having trouble.

You could always use true-colour modes until you get the hang of the
library.

>    From reading the docs, I understand that i need to first make a
> pointer to a color table with:
>
> extern COLOR_MAP *color_map;
>
>    then use:
>
> void create_trans_table(COLOR_MAP *table, PALETTE pal, int r, g, b, void
> (*callback)(int pos));
>
>    Now, I can see that I am passing it the pointer to the color map i
> created earlier, and a palette (I am assuming this is the current
> palette dos is using?), the RGB value of the transparencies.. from
> 0(fully transparent) to 255(fully visible) for red, green and blue
> individually.. void (*callback)(int pos) completely losses me, and how
> do I tell it wich color i wish to make transparent?

The transparancy table is for something different - it makes the sprite
translucent (alpha blended) to the background. For instance, if the
background is black and the sprite is bright blue, the sprite will appear a
darker blue because the two colours (background and sprite) are merged. What
you want is a sprite which completely misses out certain pixels.

>    Now, I do realize it would be easy to just tell me what each part
> does, but I learn more by example. If someone could write up a couple
> examples of how it's done, and explain step by step what each part is
> doing, then I can learn from that and alter to fit my needs.

If you send me (personally, not the newsgroup) the 256-colour image you want
as the sprite, I'll do a small routine for you.

>    Now for question 3.. the final question for now <grin>. I realize
> that text strings are made from char arrays, with the last part of the
> array meant for end of string marker. If one sets up a char array with
> 30 elements, it means one can have up to 29 characters in that string.
> However, I would like to find out how one can set up a dynamic char
> array, capable of forming itself to the size of whatever is presented to
> it. It's my fear, that if I make an array of say, 100 elements, someone
> will want to enter a string of 101 characters. (2 more than the array
> can hold.) This could be a problem with any size array, and I would
> perfer to allocate only as much memory as is needed for the string. Is
> there a way to do this? Again an example would prove very helpfull.
> (and no, i'm not trying to get others to do my work, I learn better by
> seeing how it should be, and being explained of how each portion works)

Check out the pointers tutorial at
http://www.chesworth.com/pv/vault/vault.htm

>    There, I've taken up enough of your newsgroup for one post, If I
> recieve help, I may very well post here more often, and in turn, as I
> learn what I am doing, I can help others. Thank you very much for taking
> the time to read this, and for any answers I recieve.

You may also like to subscribe to the Allegro Mailing List (visit
http://www.talula.demon.co.uk/allegro/ for details).

James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019