Jump to content
  • Advertisement

Archived

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

zask

Once more. How can i load the texture NOT from file in DX8?

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

Advertisement
I don''t know if there''s a very simple way to load a texture from a windows handle.

You can load from a resource:
D3DXCreateTextureFromResource

You can load from a file that is in memory:
D3DXCreateTextureFromFileInMemory

And you can create a blank texture:
D3DXCreateTexture

But if you want to load from a windows bitmap, then you''ll probably have to copy the data in yourself.

John B

Share this post


Link to post
Share on other sites
Whats meen "you''ll probably have to copy the data in yourself."?
And if it isn''t difficult the sample of code for each variant,
please.

Share this post


Link to post
Share on other sites
Take a look at what''s done in D3DFont.

Stop whining: You already have the source code.


Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/home/play_starshooter.htm

Share this post


Link to post
Share on other sites
Basically, what everyone is saying is, "just load the dang thing from file."

You aren''t explaining why the thing must come from a handle. Indeed most of us don''t use handles for graphics when dealing with DirectX. The only time i ever used handles with bitmaps is 1) resources (johnbsmall tells you the function you need for resources) 2) using the default windows graphics renderer (in which case, why do you need directx functions?)

The graphic could just as easily come from a file, or a file in memory, or a resource. You also aren''t explaining what you plan on doing with the bitmap. Blit it to a directx tex? Use it as a texture? Write a paint program?

Without these two details, everyone is going to keep suggesting "D3DXCreateTextureFromFileInMemory" or "D3DXCreateTextureFromResource".

And i don''t mean to be a jerk, but in these forums most people will point you to the right function, then it''s up to YOU to figure out how to use it (i suggest looking at www.msdn.microsoft.com to figure out how to use the functions.) Most ppl will not take the time to right you sample code -- we have our own code to write.

DmGoober

Share this post


Link to post
Share on other sites
IDirect3DTexture8::LockRect

and something like

GetDIBits

Make sure your bitmap is in the same color format as the direct3d surface. If not, use GDI to blt it to a bitmap with the same color resolution (CreateDIBSection).

Anyways, you lock the texture and copy all the pixels in one line at a time. At the end of the line you have to add the pitch given by IDirect3DTexture8::LockRect, since you are not guarenteed sucessive lines are contiguous in memory.

Share this post


Link to post
Share on other sites
To invective: May you write a piece of code? I not absolutely have understood how the destination surface described.

Share this post


Link to post
Share on other sites
quote:
Original post by zask
To invective: May you write a piece of code? I not absolutely have understood how the destination surface described.


As has been said a million times before, people here will point you in the right direction, but its up to you to learn it.

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!