Jump to content
  • Advertisement
Sign in to follow this  
kain0015

Copy Sprite into Surface?

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

Hi! I wanted to ask if its possible to copy a sprite into a surface. With StretchRect i can only copy surfaces. Is there a way to copy the sprite direct into the surface? Or do i have to make a new surface, load img into surface, and copy new surface in the one i want to copy the sprite? Another Question (dont want to make a new topic): How can i make images "uneditable" or invisible? ATM my pictures are in .png format, so everyone can edit them.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by kain0015
Hi!
I wanted to ask if its possible to copy a sprite into a surface. With StretchRect i can only copy surfaces.
Is there a way to copy the sprite direct into the surface? Or do i have to make a new surface, load img into surface, and copy new surface in the one i want to copy the sprite?

Technically there is no such things as a "sprite" in D3D, so I'm going to assume you mean a texture that you use as a sprite.

A texture is made up of (one or more) surfaces, so all you have to do is use the GetSurfaceLevel method on the texture and it will give you a surface that you can use as the source for your copy.

Quote:

Another Question (dont want to make a new topic): How can i make images "uneditable" or invisible? ATM my pictures are in .png format, so everyone can edit them.

You can't. At best you can make it a bit harder to edit your images. If people want to mess with your images, they will. Companies have spent a ton of money using all sorts of fancy tricks to protect their assets, but it never matters. So don't waste your time protexting the files, spend the time making your game worthwhile.

Share this post


Link to post
Share on other sites
Hmm... did it with GetSurfaceLevel, but sth. doesnt work.
Here's the source:
LPDIRECT3DSURFACE9 tmpSurface;

m_lpD3DDevice->CreateOffscreenPlainSurface(104, 104, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tmpSurface, NULL);

textureToInsert->GetSurfaceLevel(0, &tmpSurface);

RECT destRect = {20, 20, 124, 124};

m_lpD3DDevice->StretchRect(tmpSurface, NULL, m_lpGamefield, &destRect,D3DTEXF_NONE);

He can load the texture into tmpSurface, but everytime I try to copy tmpSurface into m_lpGamefield nothing happens (nothing got copied).

Another question:
I tried to get the height of the texture (textureToInsert->Height), but the compiler always gives the message "'Height' : is not a member of 'IDirect3DTexture9'".
Any Idea?

Share this post


Link to post
Share on other sites
What are you using theese textures / surfaces for?

why do you not use simple vertices and build "quads" on which you apply theese textures?

EDIT:
Blizzard Entertainment are using a "MPQ-file" zip-like storage to protect their images / sounds. It's not too hard to open theese but it's atleast something, if you REALLY want to unable people to edit your images.

I don't have a link for the MPQ file extract / packager but I have had them so I know they exist, google if ur friend.

Share this post


Link to post
Share on other sites
I'm making a tetris-clone (first game :P) and I use the textures for the falling blocks and the surface as the "gamefield". When the block stops falling I want to copy the texture (block) into the gamefield-surface.
And I dont get what you mean with "simple vertices" or "build quads".

Share this post


Link to post
Share on other sites
GetSurfaceLevel doesn't copy the data to a surface, it sets the surface pointer to the result. Your call to CreateOffscreenPlainSurface is just creating a memory leak.

Are you checking your return values to see if the calls are succeeding? You can't just assume they are. You also need to be examining the Debug Output. Read the Forum FAQ, specifically the debugging part.

Share this post


Link to post
Share on other sites
hmm... so i dont have to use CreateOffscreenPlainSurface if I get a pointer? If I debug it everythings works fine until StretchRect.

Edit: I tried it without CreateOffscreenPlainSurface but StretchRect still Failes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!