Solved

Texture transfers

Posted on 2004-04-28
3
626 Views
Last Modified: 2013-12-26
I am using visual basic 6 and direct x 9.  In direct x one loads a texture from a .dds or .bmp file. In visual basic, one can create a picture box and draw graphics on it and then save it as a .bmp file. In order to transfer the contents of a picture box to a texture, one must save the picture as a .bmp file to disk, then reload the texture from disk as a .bmp file.  Is there a way to transfer the picture to the texture without going through the process of saving to and loading back from disk. Is there an alternative process  that I could use, bearing in mind that I want to do realtime texture modifications in the same way that one would use say the picture.line function to draw a line on a picture, I want to be able to draw a line on a mesh ?

Then, does anyone know if it is possible to texture an object in dx9 with an avi file ?

Thanks

Cybermike3D
0
Comment
Question by:cybermike3d
3 Comments
 
LVL 17

Accepted Solution

by:
davebytes earned 500 total points
Comment Utility
I'm not exactly sure of the limitations in VB for doing pointer-based work, but that's the way to do it.

Actually, both answers can work the same.

You want a dynamic texture, USAGE_DYNAMIC.  That is, one whose data is going to change frequently.  Create a raw D3D texture object of the correct dimensions (again, I always suggest keeping to power-of-2 for cleanliness...).  I'd likely suggest making it a raw ARGB8888 format.  CreateTexture off the device, or D3DXCreateTexture will both work.

Then, when the source changes, LockRect the entire texture, giving you a ptr, and an offset per row.  Grab a DIB from the bitmap, and walk the two step by step copying pixels for each row, then jumping to the start of the new row of data.

Similar approach for an AVI.  Decompress into a memory buffer, lock a texture, copy the data.

There are more optimal approaches using functions like D3DXFillTexture to simplify raw byte-processing through the texture (just need the source data), or D3DXLoadSurfaceFromMemory which might work better for auto-converting data formats for you without need to walk either surface directly.

d
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now