Jump to content
  • Advertisement
Sign in to follow this  
darenking

How do I return a pointer to a BITMAP (C++ using Allegro)

This topic is 4813 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

Hello! I am writing a class to control bitmaps in C++ using Allegro. I want to add a method that returns a pointer (or something?) to the bitmap, so that another class or my main() function can draw the bitmap to the screen buffer. I have tried it like this (below), but it doesn't work so clearly it is wrong! ____ //picture.h class Picture { private: BITMAP *m_Image; // <- here is my bitmap public: BITMAP* ImageGet(); // <- and here is my lame attempt at a method that returns a pointer to it }; ____ //picture.cpp BITMAP* Picture::ImageGet(); { return m_Image; } ____ Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Looks right to me. What exactly is the problem?

Perhaps it is your use of the function that is causing problems. Post that if you can.

Matt Hughson

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Maybe change

BITMAP *m_Image;

to

BITMAP m_Image;

AND

BITMAP* ImageGet()

to

BITMAP& ImageGet()

Share this post


Link to post
Share on other sites
OK, so if I have this:

private:
BITMAP m_Image;

Does that mean that the entire bitmap is stored inside the instance of the class, rather than a pointer to the bitmap?

Can you even do that in Allegro? I don't think you can, but I'm not sure.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!