Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5952909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:44:56+00:00 2026-05-22T17:44:56+00:00

in my code I have a struct for bitmaps. struct bat { float x;

  • 0

in my code I have a struct for bitmaps.

struct bat 
{
 float x;
 float y;
 ALLEGRO_BITMAP *bmp;
};

There are functions that handle loading and drawing the bitmaps to screen.

ALLEGRO_DISPLAY *display;

bool init_display(void)
{
   puts("-- initializing display. --");
   display = al_create_display(display_width, display_height);
   if(display)
   {
     al_clear_to_color(al_map_rgb(0,0,0));
     queue = al_create_event_queue();
     al_register_event_source(queue, al_get_display_event_source(display));
     if(init_objects()){return true; puts("-- display initialized. --");}
     else return false;
   }
   else return false;
}

bool create_bat(struct bat *bat, float x_coord, float y_coord, const char *path)
{   
    puts("-- creating bat. --");
    bat->x = x_coord;
    bat->y = y_coord; 
    bat->bmp = al_load_bitmap(path);
    if(bat->bmp){puts("-- bat created. --"); return true;}
    else return false;
}

struct bat bat; 

bool init_objects(void)
{
   puts("-- initializing objects. --");
   if(al_init_image_addon())
   {
      al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
      al_set_target_backbuffer(display);
      if(!create_bat(&bat, 0, 0, "img.jpg"))
      { puts("-- creating bat failed. --"); return false;}
      puts("-- objects initialized. --"); 
      return true;
   }
else return false;
}

I’m always getting this output when I use an absolute path for the bitmap to load or a relative one.

-- initializing display. --
-- initializing objects. --
-- creating bat. --
-- creating bat failed. --

What am I doing wrong? Thanks. (OS: Ubuntu 10.10)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:44:56+00:00Added an answer on May 22, 2026 at 5:44 pm

    I think you need to install external dependencies to load a jpg image and link your executable with it. The manual says:

    The following types are built into the Allegro image addon and guaranteed to be available: BMP, PCX, TGA. Every platform also supports JPEG and PNG via external dependencies.

    See this: http://alleg.sourceforge.net/a5docs/5.0.3/image.html

    You would need the libjpeg and libjpeg-dev addon if you still do not have. Find some information about the different addons here:

    http://wiki.allegro.cc/index.php?title=Install_Allegro5_From_SVN/Linux/Debian

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code struct Student { char name[48]; float grade; int marks[10,5]; char
I have a code that looks something like: struct Data { int value; };
I have a fairly simple const struct in some C code that simply holds
I have a struct struct request { int code; char *message; }; that I'd
I have code that boils down to the following: template <typename T> struct Foo
I have code in my header file that looks like: typedef struct _bn bnode;
If I have some code that looks something like: typedef struct { bool some_flag;
I have this code:( BITMAPS is a free name) class BITMAPS{ public: static ALLEGRO_BITMAP
I have a struct that contains a float var. I am trying to read
I have code like this: template <typename T, typename U> struct MyStruct { T

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.