Archived

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

SMurf7

Problem with memory functions while surface is locked

Recommended Posts

Hi, I''m new around here, and I''m making a small program which draws an oscilloscope onto the screen (640 X 480, 8 bit). I''m attempting to implement horizontal scrolling in it, by drawing the wave to an empty buffer, copying the buffer data to the active buffer (that is, one that is attached to a locked surface) and then shifting the pixels across. I try to do this using the memcpy and memset functions, like this:- (buffer and buffer2 are UCHAR*, buffer2 is locked) memcpy(buffer2, buffer, sizeof(buffer)); memset(buffer, 0, 640*480); for (loop1=0; loop1<400; loop1++) memcpy(buffer+(loop1*640), buffer+(1+(loop1*640)),640); However, every time I attempt to run my program, it exits as soon as it reaches the memcpy line. No doubt I''m doing something really stupid here, so please correct me

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi,

Did you use a debugger to step through your code and work out that that was where it terminated? In DirectX 7 at least, you can''t use a debugger when a surface is locked - the program will terminate immediately after the lock if you try to step through, so your problem could actually be somewhere else. I once had a bug in my code which operated on a locked surface, and had to use log files and the like to work out where it was. Hope this is helpful

Share this post


Link to post
Share on other sites
Well, I didn''t use the debugger, due to knowing what you have said (it''s difficult to control under a locked surface). I know these lines are the culprit because if I comment them out then the program works fine (albeit "wrong").

I did think that it may have been due to the fact that the source surface was NULL at the time, but even after filling it with zeros it still wouldn''t work.

Share this post


Link to post
Share on other sites