discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNUstep Makefiles (resource specific)


From: Nicola Pero
Subject: Re: GNUstep Makefiles (resource specific)
Date: Thu, 6 Oct 2005 04:10:54 +0100 (BST)

> Is there any tutorial on how to use the "RESOURCE_FILES" options in
> GNUstep makefiles?
> 
> If not, could someone tell me where those parameters go? I'd like to
> know how to load up image files in SDL

Hmmm ... loading an image into an application ... now that rings a bell --
I thought I had written about that in the Tutorials! ... <searching on the
web> ...  <searching on my hard disk> ... <searching on my old laptop's
hard disk> ... well it looks like it's an unfinished tutorial that was
never published ;-)

Anyway I'll just copy here the tutorial fragment from there -- here are
the relevant paragraphs from the unpublished thing (excuse the texinfo
markup) --

---

\subsubsection{Loading Images into your Application}
To prepare an image for loading into your app, you simply need to put
it in your application's source directory, and add it to the list of
your application's resource files in your \texttt{GNUmakefile}, as 
in the following example:
\begin{verbatim}
MyAppName_RESOURCE_FILES = myIcon.png
\end{verbatim}
Upon compiling, \texttt{make} will copy all the resource files into your
application's main bundle (which is the one inside the \texttt{.app}
directory), so that they are simply available to the application.  If
you are unfamiliar with bundles you should not worry - you may think
about the main bundle as simply a directory containing all your
application resources (images, sounds, plug-ins, configuration files,
etc) and which gets installed together with your application.  It's 
the same as the \texttt{.app} directory which gets created when you 
compile your application.  All your resource files get copied into 
this directory, and are available very directly to your code. 

For example, you can access any image in your main bundle simply by
name, by using \texttt{NSImage}'s method \texttt{+imageNamed:}, which
returns the image with the specified name from the application's main
bundle. 

To load the \texttt{myIcon.png} of the previous example, you would
simply do:
\begin{verbatim}
NSImage *image;

image = [NSImage imageNamed: @"myIcon"];
\end{verbatim}

If the image can not be found in your application's main bundle,
GNUstep looks for it in the GNUstep system directories.  For example,
the familiar GNUstep logo icon is returned by:
\begin{verbatim}
NSImage *gnustepLogo;

gnustepLogo = [NSImage imageNamed: @"GNUstep"];
\end{verbatim}

---

I probably ought to finish it, polish it a bit, and put it on the web. ;-)

Thanks





reply via email to

[Prev in Thread] Current Thread [Next in Thread]