Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Lock Issue While using DirectDraw

Posted on 2004-04-20
4
676 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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