Results 1 to 3 of 3

Thread: DX: Surfaces

  1. #1

    Thread Starter
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    DX: Surfaces

    Does anyone have any clue why I am failing to lock this surface?

    Code:
    DDSURFACEDESC2 ddsd;
    
    // this should lock the entire region...
    if(FAILED(_lpPrimarySurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL)))
    {
    	DisplayError("Failed to Lock Surface.");
    }
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Have you initialized the surface descriptor? I think you must always zero those structs out and set dwSize to the correct value, even if you only want to retrieve information.

    Code:
    DDSURFACEDESC2 ddsd;
    ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
    ddsd.dwSize = sizeof(DDSURFACEDESC2);
    BTW, this is a handy macro for DirectDraw programming:
    Code:
    #define DD_INITSTRUCT(s) \
      ZeroMemory(&(s), sizeof((s)));\
      (s).dwSize = sizeof((s));
    or in C++ (only MSVC++7, it won't work properly for 6 or older Borlands):
    Code:
    template<typename T>
    inline void DD_INITSTRUCT(T &s) {
      ::ZeroMemory(&s, sizeof(T));
      s.dwSize = sizeof(T);
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    Yes, you're exactly right...when I removed it from my testing function which included the creation of the surface I had already done that, it stopped functioning. Nice call :-)
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width