Home » Community » Newbie corner » Usage of images in different .h and .cpp files
Usage of images in different .h and .cpp files [message #27600] |
Sun, 25 July 2010 13:52 |
281264
Messages: 270 Registered: June 2010 Location: Spain
|
Experienced Member |
|
|
Hi,
I have the following question: how to use images contained in a single .iml file in different classes, each one defined by its corresponding .h and .cpp file?
Cheers,
Javier
|
|
|
Re: Usage of images in different .h and .cpp files [message #27602 is a reply to message #27600] |
Sun, 25 July 2010 15:23 |
|
281264 wrote on Sun, 25 July 2010 13:52 | Hi,
I have the following question: how to use images contained in a single .iml file in different classes, each one defined by its corresponding .h and .cpp file?
Cheers,
Javier
|
Hi Javier,
Just put#define IMAGECLASS MyImages
#define IMAGEFILE images.iml
#include <Draw/iml_header.h> in your headers and #define IMAGECLASS MyImages
#define IMAGEFILE images.iml
#include <Draw/iml_source.h> in one of your cpp files.
Best regards,
Honza
|
|
|
|
Re: Usage of images in different .h and .cpp files [message #27608 is a reply to message #27606] |
Sun, 25 July 2010 18:51 |
|
You got it almost right Javier. The only problem is that iml_source.h must be included only once.
How it works: iml_header.h provides declarations, while iml_source.h provides definitions. So you must use iml_source.h only once, doesn't matter where, and only put the iml_header.h code in the rest of the places where necessary. Otherwise you get linker errors about multiple definitions.
In your case everything you have to do to get it work is to remove the definition from one of the cpp files (that is step 2 or step 4).
Honza
|
|
|
Re: Usage of images in different .h and .cpp files [message #27612 is a reply to message #27608] |
Sun, 25 July 2010 21:32 |
281264
Messages: 270 Registered: June 2010 Location: Spain
|
Experienced Member |
|
|
Thanks.
I addition, I have realised that also
#define IMAGECLASS Imagenes
must be declared only once in the multiple header files. Therefore, in my case (as I included the file “OpenGLExample.h as #include "OpenglExample.h
the above mentioned “definition” has to be included in “OpenGLExample.h" only.
Cheers,
Javier
|
|
|
Goto Forum:
Current Time: Fri Apr 26 00:13:59 CEST 2024
Total time taken to generate the page: 0.04160 seconds
|