Jump to content
  • Advertisement

Archived

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

Green

Rendering a Surface

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

Hello all, Anyone know how to render a surface onto an object? Or do I need to convert a surface into a texture first so that it can be rendered onto an object. If so, how? Or am I totally going in the wrong direction? I''m trying to combine small bitmaps onto one large bitmap in memory before I create a texture out of them. I looked into multitexturing, but the individual small bitmaps I have need to appear in different exact places on the main texture. Is this possible with multitexturing?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
quote:
Original post by Green
Hello all,

Anyone know how to render a surface onto an object?
Or do I need to convert a surface into a texture first so that it can be rendered onto an object. If so, how?
When you say Surface, I''m thinking you are meaning the IDirectSurface8 surfaces. Here''s a Hierarchial map of how Textures/Surfaces are organized:

IBaseTexture8 -> ITexture8 =>IDirectSurface8

-> means derived
=> means contains.

When you create a texture, a surface is created inside of it. You can create all sorts of textures, ones with rendertargetable Surfaces or ones with Cubemaps , etc. etc.. You simply call a method (function) of the texture to lock the surface associated with teh textue.

However, I have found no way to wrap a valid texture object around a surface already in memory, So I create a texture with a surface with the properties I need. There are a ton of D3DX functions to do this.

If you are going to update it once, then you could use a CopyRects call to copy the surface into the texture surface. If you plan on doing it intermittantly, I suggest looking at the UpdateTexture functions in D3DX. If you plan on updating the texture once a frame, I suggest creating a texture that has a rendertarget surface and rendering to the surface with the device object.

quote:
Original post by Green
I''m trying to combine small bitmaps onto one large bitmap in memory before I create a texture out of them. I looked into multitexturing, but the individual small bitmaps I have need to appear in different exact places on the main texture. Is this possible with multitexturing?
Multitexturing means blending different textures to the same spot on geometry. Maybe you should look into CopyRects() unless you are doing a lot of this, in which case I suggest doing this design time.

Share this post


Link to post
Share on other sites
Thank you for your speedy reply.


I'll do what you sugested:

_______________________________________________________
If you plan on updating the texture once a frame, I suggest creating a texture that has a rendertarget surface and rendering to the surface with the device object.
________________________________________________________

Question:

I'll create a texture with D3DUSAGE_RENDERTARGET for usage. I can do that, but...

How now do I render to this surface?


[edited by - Green on November 19, 2002 10:16:24 PM]

Share this post


Link to post
Share on other sites
ok, looking into this...

CopyRects uses surfaces.
UpdateTexture uses IDirect3DBaseTexture.

If I create a render taget texture, how do I use the above functions? I guess I cant!

CopyRects gives me the flexibility I need for selecting parts of different bit maps and copying them to specific places. CopyRects uses IDirect3DSurface8, so I am back to the same question,

How to convert a IDirect3DSurface8 into a texture so I can render it onto an object?

[edited by - Green on November 19, 2002 11:07:24 PM]

[edited by - Green on November 19, 2002 11:17:10 PM]

Share this post


Link to post
Share on other sites
//Ok I''m trying this:
//I have two textures whith which i create surfaces for. I then copy rect from the second surface to the first. Then I set texture with the first and render an object. However the copying doesnt seem to be taking place. Please help if you can. Thanks in advance.

D3DLOCKED_RECT pLockedRect;

RECT Rectangle[1];
Rectangle[0].left = 0;
Rectangle[0].top = 0;
Rectangle[0].right = 10;
Rectangle[0].bottom = 10;

POINT PointsArray[1];
PointsArray[0].x = 5;
PointsArray[0].y = 5;

IDirect3DSurface8* aSurface[2];

m_pTexture[0]->LockRect(0,&pLockedRect,NULL,0);

m_pTexture[0]->GetSurfaceLevel(0,&aSurface[0]);
m_pTexture[1]->GetSurfaceLevel(0,&aSurface[1]);

aSurface[0]->LockRect(&pLockedRect,NULL,0);
aSurface[1]->LockRect(&pLockedRect,NULL,0);

m_pD3DDevice->CopyRects(aSurface[1],&Rectangle[0],1,aSurface[0],&PointsArray[0]);

aSurface[0]->UnlockRect();
aSurface[1]->UnlockRect();

aSurface[0]->Release();
aSurface[1]->Release();

m_pTexture[0]->UnlockRect(0);

//Now I set texture to m_pTexture[0] and render it onto an object, but I dont get the copy? Agrh!

Share this post


Link to post
Share on other sites
Thanks for replying billybob, but not quite sure what you mean...
Where does Rectangle[1] go?

[edited by - Green on November 20, 2002 1:25:15 AM]

Share this post


Link to post
Share on other sites
Yes, got that, but I have only one function that uses rectangle.

m_pD3DDevice->CopyRects(aSurface[1],&Rectangle[0],1,aSurface[0],&PointsArray[0]);

Where does the other one go? I''m sorry that I''m not getting this, please bear with me!

Share this post


Link to post
Share on other sites
like this:

an array poop[10] makes an array with 10 elements, 0-9. so you need to make an array Rectangle[2] to have an array with 2 elements, 0 and 1.

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!