Hey guys I've just been playing around with allegro 5, and playing with examples from codingmadeeasy, this is an example from him, and It works fine when he compiles it. He is however using vs and i'm using codeblocks. The code is

// You generally want to do this after you check to see if the display was created. If the display wasn't created then there's // no point in calling this function al_set_new_display_flags(ALLEGRO_NOFRAME); al_set_window_position(display, 200, 100); al_set_window_title(display, "CodingMadeEasy");

So my original though was maybe I needed to use my own font, So I downloaded it from urban fonts, placed it in project folder and set it up to use it, the font name is molten and was set accordingly and doesn't give the error when it pops up...but after a few seconds it crashes..

If I'm not wrong, al_load_font() (Actually, al_load_ttf_font(), since you're using a truetype font) returns NULL on error.Check if variable font isn't null after loading. If it is, a problem happened while loading it. You can try changing the folder it is placed. Also, try checking if the font's name(and extension) is exactly the same of what you're trying to load.

Sorry, to clarify what I meant by nothing pops up, is that there is no text.

The window is white though, and I have it set so a console will appear for purposes of debugging, but more specifically I meant that it won't print anything to console, its entirely blank when the program crashes.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

Something else I noticed: al_get_standard_path() doesn't actually change or set path information. It creates and returns a pointer to an ALLEGRO_PATH object. This means you will have a memory leak if you don't put the results of the call into an ALLEGRO_PATH pointer, plus if you actually want to use an ALLEGRO_PATH object to properly obtain a file location, you need to use combinations of al_set_path_filename() and al_path_cstr(). Here's the function I wrote to simplify loading textures from a textures folder off of my main game folder:

Note that "temppath" and "gamepath" are defined as global pointers to ALLEGRO_PATH objects and that gamepath has been set at the start of the program using al_get_standard_path(). Also, the first al_destroy_path(temppath) call only works because I specifically set all pointers I use to NULL at the start of my programs, otherwise this would crash everything.

It also may look like my call to al_path_cstr() is a memory leak, but the pointer is actually tracked by the ALLEGRO_PATH object so I don't have to worry about it.

Thank you for the detailed post! Could I ask for a little more detail on how to use it though? I'm in a hurry so forgive my quick post, but you said linking to an allegro program file, which I don't understand, I installed it by drag and drop the bin include and lib folders.

I'm sorry for the hasty reply but College + work = pain in the ass >_<

The following is essentially what you need to do to work with filenames and paths with Allegro's built-in functions. Use the Allegro Manual to get information on the usage of these functions:

1. Create a pointer to an ALLEGRO_PATH object.2. Use al_get_standard_path() to assign a path to your ALLEGRO_PATH object.3. Use al_set_path_filename() to set the name of the file you want to load in your ALLEGRO_PATH object.4. When you're ready to load your file, use al_path_cstr() to acquire a string pointer for use directly in a loading command, like al_load_font(). The string returned is stored and tracked by the ALLEGRO_PATH object that generated it, so you can treat the result like a constant instead of as an object that needs to be destroyed.5. When you're done with your ALLEGRO_PATH object, call al_destroy_path() on it.

More-so a lack of pointer knowledge. *'s indicate that you either want to create a pointer to a variable, that you want to grab the information from a pointed variable, or that a function wants a pointer as one of its arguements.

To make it simple, I'll just state it as is:Pointer is an integer that contains an absolute address to some place in a memory, no more than that. Type of a pointer only helps to know how much data is supposed to be there where pointer points to.

#SelectExpand

1int i; 2int* i_ptr; 3int* a; 4 5i =10; 6/* this puts address of i to a_ptr */ 7i_ptr =&i; 8/* this prints whatever i_ptr actually contains itself */ 9printf("%p ", i_ptr ); 10/* and this prints dereferenced i_ptr, i.e. assuming i_ptr points to an int */ 11printf("%d\n", *i_ptr ); 12/* if you change the value the pointer points to, pointer itself won't change, 13 * but the value pointed by it - will (duh) */ 14i =15; 15printf("%p %d\n", i_ptr, *i_ptr ); 16/* you can also modify a value by dereferencing a pointer */ 17*i_ptr =30; 18printf("%p %d\n", i_ptr, *i_ptr ); 19/* you can dereference a value pointed by pointer as a different type, 20 * but it will just give you garbage if types are incompatible */ 21printf("%p %c\n", (char*)i_ptr, *(char*)i_ptr ); 22/* the most common use of pointers though is remembering where you allocated 23 * your memory */ 24a =malloc(sizeof(int)*32); 25/* With memory allocated like that, you can do pointer math. The pointer acts 26 * not like an integral value, but as a index number for memory cells exactly as 27 * large to contain a single int in them. The following sets zeroth cell to 0, 28 * first cell to 10 and second cell to 20. */ 29*(a +0)=0; 30*(a +1)=10; 31*(a +2)=20; 32/* And that would output contents of first four cells. Note that third cell 33 * contains garbage - this is normal. Memory allocation does not reset anything 34 * that was in the allocated memory block, so if you require initialzied memory, 35 * you'll have to either do it yourself or call calloc. */ 36printf("%p %d %d %d %d\n", a, *(a +0), *(a +1), *(a +2), *(a +3)); 37/* This moves a pointer once cell forward. Note that if you want to call free, 38 * you will need to provide precisely the value returned by previous malloc. */ 39a +=1; 40printf("%p %d %d\n", a, *(a +0), *(a +1)); 41/* there also another, more conventional notation to dereference allocated 42 * memory cells */ 43a [2]=30; 44a [3]=40; 45printf("%p %d %d\n", a, a [2], a [3]);