Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Texture transfers

Posted on 2004-04-28
3
Medium Priority
?
679 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 2000 total points
ID: 11019697
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Screencast - Getting to Know the Pipeline
Suggested Courses

926 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