Archived

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

billybob

memcpy to a file?

Recommended Posts

is there a way to memcpy to a file? i would like to create a vertex buffer, but the create routine takes a LOOONNG time. i would like to be able to just put this vertex buffer in a file, and after it was created just load the file into memory. this was possible with qbasic, using BSAVE and BLOAD. i need the same thing.

Share this post


Link to post
Share on other sites
Attempting to serialize data and state information controlled by a COM interface is a Bad Idea™. It''s virtually impossible to recreate the buffer itself from a file.

In general, serialization of any object-oriented data structure should not be done directly (ie, don''t try to binary copy the object). The solution to your problem is to schedule the creation of the vertex buffer at a low-activity period in your application''s execution.

Share this post


Link to post
Share on other sites
quote:
Original post by Oluseyi
Attempting to serialize data and state information controlled by a COM interface is a Bad Idea™. It''s virtually impossible to recreate the buffer itself from a file.

In general, serialization of any object-oriented data structure should not be done directly (ie, don''t try to binary copy the object). The solution to your problem is to schedule the creation of the vertex buffer at a low-activity period in your application''s execution.

uhhh err ok. is there no way to save and load a vertex buffer? that would help IMMENSLY.

Share this post


Link to post
Share on other sites
Wait a sec....

If I understand the problem, the solution is very easy. When you lock the vertex buffer (which you are probably doing when you create the vertices), you have a contiguous string of memory. Just save that to a file. When you reload, just lock the new vertex buffer and load from thr file to the locked buffer pointer. You aren''t saving the Vertex Buffer, you are saving the data from the buffer. That is very straightforward.

Share this post


Link to post
Share on other sites
quote:
Original post by CrazedGenius
Wait a sec....

If I understand the problem, the solution is very easy. When you lock the vertex buffer (which you are probably doing when you create the vertices), you have a contiguous string of memory. Just save that to a file. When you reload, just lock the new vertex buffer and load from thr file to the locked buffer pointer. You aren''t saving the Vertex Buffer, you are saving the data from the buffer. That is very straightforward.


that sounds simple enough, how do i do it? the current file io commands i know won''t cut it for that.

Share this post


Link to post
Share on other sites