Solved

Lock Issue While using DirectDraw

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

26 Experts available now in Live!

Get 1:1 Help Now