Once more. How can i load the texture NOT from file in DX8?
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
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
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.
And if it isn''t difficult the sample of code for each variant,
please.
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
Stop whining: You already have the source code.
Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/home/play_starshooter.htm
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
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
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.
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.
To invective: May you write a piece of code? I not absolutely have understood how the destination surface described.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement