Jump to content
  • Advertisement

Archived

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

october121

DirectDraw Direct Memory Access

This topic is 6495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
create the surface in system memory, you can read from it fast but don''t try blitting with the surface. it''s SLOW.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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!!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!