Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Lock Issue While using DirectDraw

Posted on 2004-04-20
4
Medium Priority
?
694 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
[X]
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
4 Comments
 
LVL 1

Accepted Solution

by:
bredbored earned 200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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