|
This tutorial is almost identical to Lesson 6:Texture Mapping. The only change is in the init_scene()
procedure where the texture is loaded. Before I show that piece of code I should briefly explain how to
create the resource in your executable. NOTE:This is Microsoft Visual C++ specific. It may be possible
with other compliers, but I don't know how to do it.
When you have your project set up, go to the Insert menu and select Resource. The Insert
Resource dialog will appear. Select Bitmap and then press the Import button. The OpenFile
dialog will appear, change File Types to All Files and select your bitmap file. It will be added as a
resource and automatically named something like 'IDB_BITMAP1'. That name is important because you'll use it
to load the resource.
This process will also create a header file called 'resource.h'. You need to add it to your includes at the
top of your source file (DXWindow.cpp in this case).
Finally, here is the code to load the texture, it replaces the call to D3DXCreateTextureFrom File
//Direct3D allows you to load textures from resources embedded in the executable.
hr=D3DXCreateTextureFromResourceA(g_d3d_device, //Our Direct3D device
NULL, //Our 'instance', NULL uses current
MAKEINTRESOURCE(IDB_BITMAP1),
&g_texture);
|