Solved

Lock Issue While using DirectDraw

Posted on 2004-04-20
4
677 Views
Last Modified: 2013-12-08
Iam using DirectDraw Component to create primary surface in windowed mode , when i try to lock
the primary surface to acess the primary surface memory , it works,  but some times it won't allow me to lock the surface it gives me DDERR_GENERIC. This problem persists until i exit from the application.  Can any one help me.

Here is the code


      hr = lpDDSPrimary->Lock( NULL , &ddsd, DDLOCK_WAIT |DDLOCK_SURFACEMEMORYPTR    | DDLOCK_READONLY , NULL );
      if(hr ==DD_OK)
      {
         if(ddsd.lpSurface !=NULL)
          {
                // i will do processing of surface here
                    }
                   lpDDSPrimary->Unlock(ddsd.lpSurface);

      }
      else
      {
            CString eMsg="Error in lock  ";
            GetErrorMsg(hr,eMsg);
            throw "Error Unable to Lock Surface";      
      }
 

Thnaks in advance

0
Comment
Question by:SHari
4 Comments
 
LVL 1

Accepted Solution

by:
bredbored earned 50 total points
ID: 10873024
In theory you ought to use
if( SUCCEEDED( hr ) )
rather than
if( hr == DD_OK )

Also in theory, IDirectDrawSurface7::Lock does not return DDERR_GENERIC.

Did you set ddsd.dwSize to sizeof ddsd?

Finally, IDirectDrawSurface7::Unlock takes a pointer to a rectangle as its parameter.  This rectangle must be the same rectangle specified in the call to IDirectDrawSurface7::Lock.  Therefore you should change
lpDDSPrimary->Unlock( ddsd.lpSurface );
to
lpDDSPrimary->Unlock( NULL );

All of there points are applicable to versions of DirectDraw other than 7.

Nick
0
 
LVL 17

Expert Comment

by:davebytes
ID: 11019440
Sounds strange.

My brain says many cards and drivers will not allow access to the primary buffer via locking.

What are you trying to do that you need to lock the primary?  and not double-buffering and locking down the back-buffer instead?

-d
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
game engine recommendation 3 729
Spell-checking 1 101
GPU processing of c++ library 7 121
Stocks - How do I research and choose a Spider stock, and how does it make money? 3 91
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 …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 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