Skip to content

Using Resources

Maeiky edited this page Jan 31, 2020 · 6 revisions

From our previous project "Hello GZE GUI", we will include some external resources.


First we need some file to be read from our application:

  • An image
  • A Font

Grab these 2 files and put these in a new folder named "RcExe" next to "Scene.cw"


Modify Scene.cw , add some these import:


import GZ.Gfx.Clip.Img;
import GZ.File.RcImg;

In the Scene function body, replace the line of our Box creation by an Image instead.


//oObj = new Box(this, 300,300,  200,200,    5);

//!New Image Object:    X ,Y,       Resource File
oObj = new Img(this, 400.0, 300.0, "Exe|Rc/Tf.png");

Here a resource object is created from a this path: "Exe|Rc/Tf.png". Before the pipe delimiter '|', it's the resource location. "Exe" means that the resource is relative to our executable path.

But we don't have this file after our executable is generated in the "_out" folder


Edit the make file Make_For_Windows.cwMake to add the resources in the final directory. Add this command just before the link stage


>
;We copy the resources to the final output directory (To be accessible from the application)
-#Copy src_(Demo)/RcExe _out/{_sPlatform}_{_sOpt}/Rc/
>
;Take all object file in the output folder and link them to make a binary
...


The complete project is here



Clone this wiki locally