IID_IDirectDraw7

This is a discussion on IID_IDirectDraw7 within the Game Programming forums, part of the General Programming Boards category; Hello. I am having a problem with using DirectDraw. When I use the CreateWindow() function, in VC++.NET Pro, the linker ...

  1. #1
    Perverted unanimous's Avatar
    Join Date
    Oct 2001
    Posts
    336

    Question IID_IDirectDraw7

    Hello. I am having a problem with using DirectDraw. When I use the CreateWindow() function, in VC++.NET Pro, the linker sees IID_IDirectDraw7 as an unresolved external symbol in my code but if I compile the examples by Andre LaMothe, everything works fine.

    Code:
    DirectDrawCreateEx(NULL,(void **)&lpdd,IID_IDirectDraw7, NULL)
    I attached my .cpp file with the code.

    *edit* I always forget that third I in IID_IDirectDraw7
    Attached Files Attached Files
    Last edited by unanimous; 06-21-2003 at 08:45 AM.
    Give me a bad reputation!!!

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    You should link your program with dxguid.lib
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    Perverted unanimous's Avatar
    Join Date
    Oct 2001
    Posts
    336
    Thanks!! but why would it compile if i used LaMothe's cpp file in my project b/c dxguid.lib wasn't included then either?
    Give me a bad reputation!!!

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    If I remember correctly, he uses a macro called INITGUID

    #define INITGUID

    before all included files. That way dxguid.lib isn't needed, the guids are defined in the .h files.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Perverted unanimous's Avatar
    Join Date
    Oct 2001
    Posts
    336
    OK, that makes sense. Thanks for the help.
    Give me a bad reputation!!!

  6. #6
    Perverted unanimous's Avatar
    Join Date
    Oct 2001
    Posts
    336
    I have another problem. When usinf ddutil.h and .cpp I load a bitmap and when it displays i get a lot of jumbled image behind the image i am displaying. I attached the project it is in a VC++.NET solution.

    *edit* attached the wrong files
    Attached Files Attached Files
    Last edited by unanimous; 06-21-2003 at 07:36 PM.
    Give me a bad reputation!!!

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Code:
    //Global variable
    DDSURFACEDESC2 ddsd;
    
    //SetupSurface() definition
    SetupSurface(DDSURFACEDESC2 ddsd)
    {
         //...
    }
    
    //In GameInit()
    SetupSurface(ddsd);
    You're trying to use SetupSurface() to:
    a) Fill in the global variable ddsd and create a primary surface with it
    b) Later, use the global variable ddsd to load a bitmap

    The problem is:
    SetupSurface() takes a DDSURFACEDESC2 struct, not a pointer to a DDSURFACEDESC2 struct, and since the parameter ddsd has the same name as the global variable ddsd, it will fill in the parameter ddsd, create the primary surface, then the filled-in ddsd goes out of scope and is destroyed, leaving the un-filled global ddsd to be passed to the DDLoadBitmap() function. There are 4 possible solutions:

    1) Change the arguments for SetupSurface() to a DDSURFACEDESC2 reference

    2) Change the name of the argument to "useless" or something, since it isn't needed (the function accesses the global variable directly), and/or delete it.

    3) Instead of simply calling SetupSurface(ddsd), do:
    ddsd = SetupSurface(ddsd);

    4) Something I haven't thought of

    **EDIT**
    BTW, you should probably take option 1 or 2, as option 3 is somewhat... inefficient and hard to read, and *might* not work. And for option 2, you probably should just get rid of the argument.

    *And just as a side note, I find it easier to keep track of where each bit of code is if I keep all function definitions to .cpp files.
    Last edited by Hunter2; 06-21-2003 at 10:38 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    Perverted unanimous's Avatar
    Join Date
    Oct 2001
    Posts
    336
    Thanks I'm going to try that now.
    Give me a bad reputation!!!

  9. #9
    Perverted unanimous's Avatar
    Join Date
    Oct 2001
    Posts
    336
    Yes, I tried both options 1 and 2 and it still had the junk behind it so then i tried compling example 2 from sunlight's tutorials and they too had the stuff behind it so I guess I have to figre out why this is happening b/c things I don't compile look great.
    Give me a bad reputation!!!

  10. #10
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ahh oops, I read your code wrong I thought you were passing ddsd to DDLoadBitmap, but you were passing lpdd instead. Any information I previously posted is now void, and any harm it may have done to your application is not my fault
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  11. #11
    Perverted unanimous's Avatar
    Join Date
    Oct 2001
    Posts
    336
    Wow!!! thats good to hear b/c I tohught that I had just gone stupid, but luckily I have gone stupid but my code is still correct!!! Well I seem to be having more luck with DirectDraw in C# b/c notihng I can think of is making it work with C++. Maybe M$ just doesn't like me.
    Give me a bad reputation!!!

  12. #12
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Hmm... well, I don't know, I didnt look at all your code, I only took a glance at it and pointed out some (wrong) problems that I saw. If you want, you can take a look at the DirectDraw code that I made just a little while ago for my game. It might be a little hard to understand (because of the lack of comments), but it works.

    Setting up and loading/drawing bitmaps is all wrapped up in a few easier-to-use functions, and if you look at the code, it might help with your problem (or on the other hand, it might just confuse you more ), or if you really want you could just adapt the class to your purpose, although that isn't recommended

    **EDIT**
    P.S. There's a lot of things that aren't done too well in my code, just so you know and don't think it's perfect
    Attached Files Attached Files
    Last edited by Hunter2; 06-23-2003 at 06:01 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21