From: Donald Manley Newsgroups: comp.os.msdos.djgpp Subject: Help: Allegro and C Date: Fri, 11 Sep 1998 19:02:29 -0700 Organization: Pacific Bell Internet Services Lines: 85 Message-ID: <35F9D634.8805659A@pacbell.net> NNTP-Posting-Host: ppp-209-77-88-248.scrm01.pacbell.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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? 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. What I would like to do is put a mouse pointer on that screen, with a pointer I have designed. However, I need to figgure out how to make the main color of that pointer transparent. 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. 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? 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. Now for question 3.. the final question for now . 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) 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. I can be reached at: Rafkin AT Hotmail DOT com Rafkin AT Pacbell DOT net And I will be keeping an eye on this newsgroup as well. Thank You again, Rafkin