Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Glyce

DirectX 9, 2D, and Tiles

This topic is 5305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been poking around DirectX tutorials, and trying to focus only on DirectX 9. I can''t seem to find anything on Blitting, or any similar method for creating Tiled textures. Those that I have found are always for previous versions of DirectX, and from what I think I''ve read, those methods have been removed from DX9. If I''m wrong, or if anyone knows any information, I''d appreciate it if you could post it. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
use the dx sprite, it is 2d, and sounds probably perfect for it.

if u want some code ive created a class on it.

class ColRGB {
public:
DWORD colour;

ColRGB(int r, int g, int b)
{
colour = D3DCOLOR_XRGB(r,g,b);
}

ColRGB()
{
}
};

class Sprite {
private:
LPD3DXSPRITE lp_Sprite;
public:
Sprite()
{
}

~Sprite()
{
if( lp_Sprite != NULL )
{
lp_Sprite->Release();
lp_Sprite=NULL;
}
}

void init(LPDIRECT3DDEVICE9 * lp_Device)
{
lp_Sprite=NULL;
D3DXCreateSprite(*lp_Device, &lp_Sprite );
}

void draw(LPDIRECT3DTEXTURE9 * texture, float x, float y, int width, int height, int frameX, int frameY, float scaleX=1, float scaleY=1,ColRGB colour=ColRGB(255,255,255))
{
RECT abcRect;
abcRect.top = frameY * height;
abcRect.left = frameX * width;
abcRect.bottom = abcRect.top + height;
abcRect.right = abcRect.left + width;
D3DXVECTOR2 dScaling(scaleX, scaleY);
D3DXVECTOR2 dCoords(x, y);
lp_Sprite->Draw( *texture, &abcRect, &dScaling, NULL, 0.0f, &dCoords, colour.colour );
}
};


to use it you have to...
Sprite mySprite;

//somewhere in init code...
mySprite.init(d3dDevice);

//somewhere in draw code....
mySprite.draw(aDxTexture,xPos,yPos,imagewidth,imageheight);


//u may want to slightly modify it but, it is very simple


[edited by - johnnyBravo on January 6, 2004 7:17:17 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!