Skip to main content
gamedev.net
🔒 Locked

DirectDraw Direct Memory Access

Started by october121 6 replies 300+ views
Original Post
october121
october121
This may be a dumb question, but is there a way to get reasonably fast direct access to a directdraw surface in C++? I can''t seem to get framerates above 2 FPS...
SPAR
SPAR
show us your source code
october121
october121
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
ddsd.dwSize = sizeof(DDSURFACEDESC2);

hRet = dds->Lock(NULL, &ddsd, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL);
if (hRet != DD_OK)
{
ErrStr = ErrLock;
return FALSE;
}

surf = (BYTE *)ddsd.lpSurface;
pitch = ddsd.lPitch;

for (i=0;i<(int)(ddsd.dwWidth);i+=4)
{
for (j=1;j<(int)(ddsd.dwHeight);j++)
{

//actual code removed to save space

}
}

dds->Unlock(NULL);
mr_jrt
mr_jrt
If you''re doing that each frame, the nested loops are gonna kill your frame rate.

(Although it depends on what the code is between them, but it gets executed 76,800 times each frame for a 640x480 surface)



Waassaap!!
Waassaap!!
october121
october121
Alright...that''s what I thought. I wasn''t sure how much of the problem was that and how much was directX...because even in 320x240 it runs slow, and it was fine when I implemented the same code in dos. so I guess it''s on to optimizing...heh. thanks all.
bogdanontanu
bogdanontanu
Hi

Remember: u will get almost 90% of the speed of dos if u make ur code the best..(micro$oft doc writes it black on white)

So i thing u have to think about using ASM (like me) if u wanna have decent speed... and dont use the video cards accelerated 3D features...

Bogdan
obysoft
neocron
neocron

This may be a daft response :-) Are you sure you''ve compiled in Release mode (as opposed to Debug).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.