Solved

Lock Issue While using DirectDraw

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is Python as good as Java for an RTS game server? 10 1,286
How are Tech stock earnings calculated? 2 66
3D rotation changing an axis 4 74
Python - How does this 2D array not work? 3 75
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 …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now