Archived

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

texture from texture ??

This topic is 5778 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

for my little sprites i want to load a file with all sprites in it. but a time a only want to show one. so i want to copy a part from a texture in a texture. is there any method ?? or what is the proper way ??

Share this post


Link to post
Share on other sites
If you want to create a new texture from a part of an old, look into the copy rects function. I''m not an expert but I think that might be what your lookig for

[Edited by - kmsixpence on October 17, 2005 7:12:00 PM]

Share this post


Link to post
Share on other sites
If you want to create a new texture from a part of an old, look into the copy rects function. I''m not an expert but I think that might be what your lookig for

[Edited by - kmsixpence on October 17, 2005 7:13:49 PM]

Share this post


Link to post
Share on other sites
You don't have to map the entire texture onto your quad. Use coordinates less than 1 to map a smaller area of your texure onto the quad.
So that instead of using (for your texure coordinates):
0,0 - 1,0
0,1 - 1,1

You'd use:
0,0 - 0.5,0
0,0.5 - 0.5,0.5

Of course you don't have to use 0.5, the value depends on how many sprites you've got on a texture, and how you've arranged them, but hopefully you get the idea.

John B

Edited by - JohnBSmall on February 16, 2002 5:40:49 PM

Share this post


Link to post
Share on other sites
yes this is true. but i don''t want to put this texture on a quad. i want to put it in the sprite. perhaps for d3d it''s the same but i need something where i can use pixel-coordinates of the bmp which i loaded in the texture. perhaps you know something like this ??

Share this post


Link to post
Share on other sites
yes this is true. but i don''t want to put this texture on a quad. i want to put it in the sprite. perhaps for d3d it''s the same but i need something where i can use pixel-coordinates of the bmp which i loaded in the texture. perhaps you know something like this ??

Share this post


Link to post
Share on other sites
Well I''m not sure exactly what you mean by sprite. If you''re using the ID3DXSprite interface then it lets you specify a source rectangle when you draw it I think.
But it doesn''t sound like you''re using that. You really need to define sprite.
Although actually, I only know about DX8.1, so if you''re using DX7, then I can''t help anyway.

Sorry,
John B

Share this post


Link to post
Share on other sites
Well, texture coordinates is the way you should do it, as everyone else said; but instead of hardcoding the coordinates, this is what you should do: Imagine the following where each number represents a color and is one pixel of your sprite bitmap file.

4211111131
2000000001
1000000001
3000000001
4211111131
2000000001
1000000001
3000000001

The second through the fourth row (horizontal) is the first sprite, the sixth through the eighth row is the second sprite. The first row and the fifth row is the border of your sprite picture. When you load in the bitmap, have your program scan for how many sprites there are by counting how many pixels are colored 4 in the first column. Once you done that, set up a RECT table (ie. new RECT[iNumSprites]) and figure out the width and length of each sprite. You can do that by calculating the distance between the pixels colored 2 and colored 3. So now you can blit the first frame by blitting RECT[0], second frame by blitting RECT[1], etc. I hope this helps you more than it confuse you.

Share this post


Link to post
Share on other sites
Well, texture coordinates is the way you should do it, as everyone else said; but instead of hardcoding the coordinates, this is what you should do: Imagine the following where each number represents a color and is one pixel of your sprite bitmap file.

4211111131
2000000001
1000000001
3000000001
4211111131
2000000001
1000000001
3000000001

The second through the fourth row (horizontal) is the first sprite, the sixth through the eighth row is the second sprite. The first row and the fifth row is the border of your sprite picture. When you load in the bitmap, have your program scan for how many sprites there are by counting how many pixels are colored 4 in the first column. Once you done that, set up a RECT table (ie. new RECT[iNumSprites]) and figure out the width and length of each sprite. You can do that by calculating the distance between the pixels colored 2 and colored 3. So now you can blit the first frame by blitting RECT[0], second frame by blitting RECT[1], etc.

As for your concern about the quad thing, just use transparency. DirectDraw7 has that functionality, it just doesn''t blit the transparent color when you go lpdds->blt();

I hope this helps you more than it confuse you.

Share this post


Link to post
Share on other sites