resources - Visual Studio 2012 (C++) - Use included .png file -
i encountering yet problem directx 9 & c++. have been working on 2d games using lpd3dxsprite , lpdirect3dtexture9. can load in textures, when comes distributing finished game, need distribute resources (which can edited, deleted or something, not convenient). know possible import "resource file" visual studio, when refer using d3dxcreatetexturefromfile() not load it. have no idea how this.
if possible, in advance.
i'm not sure it's idea store game assets in windows resource file. if want try it:
method 1.
d3dxcreatetexturefromresource()
,d3dxcreatetexturefromresourceex()
functions looks want.
use case:
// suppose have resource `idb_sprite1` in resource file linked in current executable // , initialized g_pd3ddevice lpdirect3dtexture9 sprite1_texture = 0; hresult hr = d3dxcreatetexturefromresource( g_pd3ddevice, getmodulehandle(null), makeintresource( sprite1 ), &sprite1_texture ); if(failed(hr)) { // there error. check `hr` error description } // no errors: can use `sprite1_texture`
method 2.
- use
loadimage()
function. pass resource viamakeintresource
macro.hbitmap
returned. - use
getbitmapbits()
function retrieve pixel data - use
d3dxcreatetexturefromfileinmemory()
Comments
Post a Comment