Jump to content
  • Advertisement
Sign in to follow this  
Esqulax

Allegro Assistance

This topic is 3963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya guys! I got a wee prob with my program.. basically, ive been out of the "scene" for about 3 years, so it may be something stupid that im missing. I am using Dev-Cpp, with the Allegro library... H'okay.. My prog is thus: #include <stdio.h> #include <allegro.h> #include <string.h> int main() { allegro_init(); set_gfx_mode(GFX_SAFE,640,480,0,0); textprintf_ex(screen,font,0,0,15,-1, "Allegro version = %s\n", allegro_id); //printf("allegro Version: %s\n", allegro_id); //printf("ANY KEY DAMMIT!\n"); system("pause"); allegro_exit(); return 0; } END_OF_MAIN() Explanation: 1)If i compile and run as is... it will compile, but on running, a window opens, then "Project2.exe has encountered a problem and needs to close. We are sorry for the inconvenience." 2)If i comment out the three lines below allegro_init(), ans uncomment the printf's i get a blank window saying "Press any key to continue (Im guessing as a result of system("pause") and the printf's dont... print..f. 3)However, if i add in allegro_message("Allegro version = %s\n", allegro_id); BEFORE the textprintf_ex, a message box appears, then a window, then problem 1 happens. AFTER the textprintf_ex, same a problem 1. SO i know the allegro library is being read (cos the "allegro_message" works. something is making the textprintf go squiffy.. and also the regular printf.... any ideas?

Share this post


Link to post
Share on other sites
Advertisement
For one thing, instead of using system("pause"), you should use this function:
install_keyboard(); at the beginning to ready the keyboard for input. Then replace system("pause") with: readkey();

Hmm, about your problem, try deleting (or commenting out) the allegro_exit() line.

Share this post


Link to post
Share on other sites
Ok...
Added the install_keyboard() func, and the readkey(), same problem as no.1.
knowing my luck it'll be something REALLY simple.

I view the error report that MS want sending to them, and i see:

AppName: project2.exe AppVer: 0.0.0.0 ModName: alleg42.dll
ModVer: 4.2.1.0 Offset: 0001a4ad

Would that imply that my alleg42.dll is corrupt? or would the copiler be pointing to the wrong dll?

Plus i dont think they're really that sorry for the inconvenience.

Share this post


Link to post
Share on other sites
Haven't used allegro , but...
1)Are you sure that text functions can be used without initialization ??
2)You must include a loop in your program , for example :

while (!quit)
{
clear screen
read keys
if key = escape then quit=true
render
}
release the font / images / gfx system


3)you can try a different gfx mode

Share this post


Link to post
Share on other sites
I thought that allegro_init() initialised all of the features that are standard from the allegro.h.
textprintf_ex seems like a pretty standard one.

Why would i need a loop for this to work? Surely a loop would simply run the same code over, making the same errors?

The program is crashing at the textout stage, i found that when i put in the allegro_message.
i mean, the text should display without a loop, even if it flashes up then dissappears.

Ive tried the gfx modes that i can find online, and to no avail.

Sorry to keep coming up with problems!, maybe my computer is mad at me?

Share this post


Link to post
Share on other sites
Quote:
Original post by Esqulax
I thought that allegro_init() initialised all of the features that are standard from the allegro.h.
textprintf_ex seems like a pretty standard one.

I have no idea , just tried to help ;>

Quote:
Original post by Esqulax
Why would i need a loop for this to work?

Nope , you dont.
It will just keep your game running until your press a key

Quote:
Original post by Esqulax
The program is crashing at the textout stage, i found that when i put in the allegro_message.
i mean, the text should display without a loop, even if it flashes up then dissappears.


Take a look here :
http://www.allegro.cc/manual/api/using-allegro/install_allegro


install_allegro(SYSTEM_AUTODETECT, &errno, atexit);




Share this post


Link to post
Share on other sites
SUCCESS!

dont know what i did!
i think it may have been the syntax....or libraries!!

Thanks for your help!

another point though (I know... shoot me...)

when i run it.. 2 windows appear, one like.. command prompt window, and another which displays the stuff i programmed.. is this normal?


#include <allegro.h>


int main (void)
{
allegro_init();
set_gfx_mode(GFX_SAFE, 640,480,0,0);
install_keyboard();
textprintf_ex(screen, font,1,1,10,-1, "Hello Dudes");
textprintf_ex(screen, font,1,12,11,-1, "Press ESC key");
while(!key[KEY_ESC]);
allegro_exit();
return 0;
}
END_OF_MAIN()





Share this post


Link to post
Share on other sites
Ok.. heres an odd one:

using the code from my post immediatly above this one, the program compiles and runs.

If i want to change the GFX mode, i believe i can change it to

GFX_AUTODETECT_WINDOWED,640,480,0,0);

HOWEVER when i change this i get:
[Linker error] undefined reference to `_imp__font'
[Linker error] undefined reference to `_imp__screen'
[Linker error] undefined reference to `_imp__font'
[Linker error] undefined reference to `_imp__screen'
[Linker error] undefined reference to `_imp__key'
[Linker error] undefined reference to `_imp__key'

So i think WOAH!! and change the GFX staement back to what it was... but it gets the same errors! even thought it was working beore!!

the only way ive found to make it work again, is to change from a static library back to non static(using DLL files) then compile.

but when i change it BACK to static library it works again!

this seems odd to me how code can work, then not work 2 mins later after changinf the code. Im pretty sure the lib files dont get changed at all

Share this post


Link to post
Share on other sites
I think i found why it crashes here:


textprintf_ex(screen,font,0,0,15,-1,
"Allegro version = %s\n", allegro_id);




1) allegro_id must be integer , and in your example you're expecting a string (%s).
Replace %s with %d.
edited :
Also remove "\n" , i think that you dont need it..

2)
Quote:

void textprintf_ex(BITMAP *bmp, const FONT *f, int x, int y, int color, int bg, const char *fmt, ...);
Formatted text output, using a printf() style format string. Due to an internal limitation, this function can't be used for extremely long texts.



3) As for gfx modes , i cant really help you.
Better ask on their forums!

Share this post


Link to post
Share on other sites
I think it may only be an issue when i try to run the program from the static lib.
i'll just not do that for the mo, and run using the alleg32.dll until i understand it a bit more.

for now i wanna have a a go and take allegro for a spin
Thanks loads for your help 3D :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!