
Originally Posted by
daavve
idk :P i just want my picture in the game then i press a random key.
I would load ur image into a resource file in ur dll otherwise you have to ship the images along w/ the hack as seperate file. Now I believe theres a function called CreateTextureFromFile or something like that in the d3d sdk. just use it to load ur image. then draw the texture like normal.
Heres an example of how to load a texture from a file:
Code:
LPDIRECT3DTEXTURE9 LoadTexture(char* filename, D3DCOLOR transcolor)
{
//the texture pointer
LPDIRECT3DTEXTURE9 texture = NULL;
//the struct for reading bitmap file info
D3DXIMAGE_INFO info;
HRESULT result;
//get width and height srom bitmap file
result = D3DXGetImageInfoFromFileA(filename, &info);
if(result != D3D_OK) return NULL;
//creat texture by loading bitmap file
D3DXCreateTextureFromFileExA(
d3ddev, //Direct3D device object
filename, //bitmap filename
info.Width, //bitmap image width
info.Height, //bitmap image height
1, //mip-map levels (1 for no chain)
D3DPOOL_DEFAULT, //the type of surface (standard)
D3DFMT_UNKNOWN, //surface format (default)
D3DPOOL_DEFAULT, //memory class for the texture
D3DX_DEFAULT, //image filter
D3DX_DEFAULT, //mip filter
transcolor, //color key for transparency
&info, //bitmap file info (from loaded file)
NULL, //color palette
&texture); //destination texture
//make sure file was loaded correctly
if(result != D3D_OK)return NULL;
return texture;
}
IDirect3DTexture9 Interface (Windows)
U can also use a sprite handler to handle images which may be a lot easier then making ractangles urself and having to worry about SetStreamSource and the like.
A good tutorial on how to use ID3DXSPRITE
http://www.toymaker******/Games/html/sprites.html
Yeh I know it looks like a lot, but trust me, using the Sprites are a LOT easier the creating ur own vertex buffers. and since ur only drawing 1 image the performance penalty should be minute.
You can use a little homemade struct like this to keep track of ur coordinates..
Code:
struct Sprite
{
public:
int x,y;
int width, height;
int movex, movey;
int curframe, lastframe;
int animedelay, animcount;
};
and then u can simply transfer them to positions when ur about to draw the sprite like so:
Code:
void Draw_Ball()
{
D3DXVECTOR3 position(0,0,0); //ball position vector
position.x = (float)ball.x; // Sprite ball;
position.y = (float)ball.y; //screen coords
sprite_handler->Draw(
ball_image, //LPDIRECT3DTEXTURE9
NULL,
NULL,
&position, //LPD3DXVECTOR3
D3DCOLOR_XRGB(255,255,255)); // color... not really important since ur drawing an image on this sprite
}