Scaleform GFx FAQ: Using Custom Images, Icons, and Dynamic Textures

This section covers issues dealing with the implementation and usage of rendered textures and video, custom icons, and 3D images.

How do I display my own custom-loaded image or icon inside of Flash?

There are two ways you can accomplish this:

Is it possible to incorporate dynamic textures in a rendered Flash file (e.g., video, 3D)?

In D3D, GTexture contains a IDirect3DTexture9 pointer; replacing it with a render texture will allow you to have dynamic content in it. Since GTexture objects are stored in GImageInfo, they can be looked up based on a linkage identifier (a.k.a. "export name") through GFxMovieDef::GetResource() and resolved appropriately.

The "GFx Player Texture In SWF" sample included in the SDK demonstrates how to display 3D (or video, custom rendered textures) inside a Flash interface by replacing a texture with a custom render target. Currently, the sample draws a 3D cube inside a movable Flash shape; however, developers should be able to use the same approach for video (via Bink or DivX). GFx 3.0 has built in support for video that allows you to perform playback of videos.

I have my own texture format that my engine uses. How do I make sure that textures are saved in my own texture format?

When you run GFxExport, it will write out texture files, which you can have generated in either DDS or TGA format (we recommend TGA). After the export is finished, you can have your own custom tools on the C++ side to go through a directory of files and convert the TGAs into your own custom format.

After images are stored in your own texture format, you have to install the GFxImageCreator class to load those textures into GFx. A GFxImageCreator::CreateImage virtual function will get called for every texture file and get passed to a string file name. Here you can load your custom images, wrap them in GImageInfo and return for GFx to use.

Can I use embedded images in a text field? If so, how?

Yes. There are two ways in which this can be done. You may substitute character strings with images or use HTML <IMG> tags after 2.0.

The limitations of our implementation are as follows: the "SRC" attribute can specify an export name of image in the SWF or the "img://" prefix for GFxImageCreator; the "ALIGN" attribute is ignored—the alignment is always set to "baseline"; the "ID" attribute is ignored. Please note that all extensions work only if _global.gfxExtensions = true.

For more detailed information, including code examples, please see AS2 Extensions Reference.

I have my own textures already loaded as platform specific textures (e.g., “IDirect3DBaseTexture9” (PC) or “CellGcmTexture” (“PS3™”)). How can I use them from GFxImageLoader to use with GFx?

It is possible to use system specific textures from GFxImageLoader, however, they must be wrapped in a GTexture created by GRenderer. To do so, you create a texture with GRenderer::CreateTexture and then use a platform-specific version of InitTexture to initialize if with IDirect3DTexture9*, for example. Once that is done, the created texture can be used in a constructor for GImageInfo that is returned from GFxImageLoader::LoadImage.