Thread: Pic not showing up

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Pic not showing up

    Hey everyone, I've been trying (slowly, unsuccessfully) to learn DirectDraw, but it hasn't been working for me. As far as I can tell, my code which loads a bitmap is working fine, since earlier I succeeded in making a ship appear on the screen (discoloured, but whole). However, now that I've changed some stuff, (i.e. moved away from keeping an array here and a bit of stuff there to having a struct containing the bitmap data), the ship won't show up! Could somebody take a look at my code and point out what's wrong?
    PHP Code:
    struct BITMAP_FILE
    {
        
    BITMAPFILEHEADER bfh;
        
    BITMAPINFOHEADER bih;
        
    PALETTEENTRY palette[256];
        
    unsigned chardata;
    };

    struct BITMAP_OBJECT
    {
        
    int state;
        
    int attr;
        
    int xy;
        
    int xvyv;
        
    int widthheight;
        
    LPDIRECTDRAWSURFACE image;
    };

    bool CreateBitmapObj(BITMAP_OBJECTboBITMAP_FILEbfint flagsint cxint cyint mode)
    {
        
    //Create

        
    DDSURFACEDESC ddsd;
        
    memset(&ddsd0sizeof(ddsd));
        
    ddsd.dwSize sizeof(ddsd);
        
    ddsd.dwFlags DDSD_CAPS DDSD_WIDTH DDSD_HEIGHT;
        
    ddsd.dwWidth bo.width bf.bih.biWidth;
        
    ddsd.dwHeight bo.height bf.bih.biHeight;
        
    ddsd.ddsCaps.dwCaps DDSCAPS_OFFSCREENPLAIN flags;

        
    memset(&bo0sizeof(bo));
        
    bo.state BOBJ_STATE_ALIVE;
        
    bo.image NULL;

        if(
    ddraw->CreateSurface(&ddsd, &bo.imageNULL) != DD_OK)
            return 
    false;

        
    DDCOLORKEY key;
        
    key.dwColorSpaceHighValue 0;
        
    key.dwColorSpaceLowValue 0;
        
    bo.image->SetColorKey(DDCKEY_SRCBLT, &key);

        
    //Load

        
    if(mode == BOBJ_MODE_CELL)
        {
            
    *= bo.width 1;
            
    *= bo.height 1;
        }

        
    unsigned charsrc;
        
    unsigned chardest;

        
    src bf.data + (bf.bih.biWidth) + x;

        
    memset(&ddsd0sizeof(ddsd));

        
    bo.image->Lock(NULL, &ddsdDDLOCK_WAIT DDLOCK_SURFACEMEMORYPTRNULL);

        
    dest = (unsigned char*)ddsd.lpSurface;
        for(
    int y 0bo.height; ++y)
        {
            
    memcpy(destsrcbo.width);
            
    dest += bo.width;
            
    src += bf.bih.biWidth;
        }

        
    bo.image->Unlock(ddsd.lpSurface);

        
    bo.state |= BOBJ_STATE_LOADED;

        return 
    true;
    }

    void DrawBitmapObj(BITMAP_OBJECTboLPDIRECTDRAWSURFACE dest)
    {
        
    RECT srcdst;

        
    src.left 0;
        
    src.top 0;
        
    src.right bo.width 1;
        
    src.bottom bo.height 1;

        
    dst.left bo.x;
        
    dst.top bo.y;
        
    dst.right bo.bo.width 1;
        
    dst.bottom bo.bo.height 1;

        
    dest->Blt(&dstbo.image, &srcDDBLT_WAIT DDBLT_KEYSRCNULL);

    Just Google It. √

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

  2. #2
    Registered User Kirdra's Avatar
    Join Date
    Aug 2002
    Posts
    105
    Long live GDI eh?

  3. #3
    Registered User 4point5's Avatar
    Join Date
    Oct 2002
    Posts
    44

    Cool

    DirectDraw doesnt come with any functions to load bitmaps, but microsoft has programmed some anyway.

    I have attached a zip file with ddutil.h and ddutil.cpp. Complie ddutil.cpp with your project and add ddutil.h with your #includes.

    There is a function called DDLoadBitmap() that loads a bitmap into a surface. Then all you have to do is blit that surface to your backbuffer and Flip().

    Oh, and there is too much wrong with the your code to even know where to get started
    Last edited by 4point5; 11-04-2002 at 11:22 PM.
    Don't try so hard. Just let it happen.

  4. #4
    Registered User MicroFiend's Avatar
    Join Date
    Nov 2002
    Posts
    80
    I agree with that hunter person about the win GDI, in my opinion you should learnn and love the Win32 GDI and that will give you an easier way to grasp Direct X if you can learn about Device COntexts, Blitting and Double Buffers the GDI way then u will pick up other API's a snap (just my opinion (go ahead flame me now :P))

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Oh, and there is too much wrong with the your code to even know where to get started
    Well, that's nice to know I'll take a look at the DDUtil thing though. BTW, is it actually a DirectX thing, or just a misc. tool that M$ made? And should I already have it, or do I really have to download it? (I'll download it anyways )

    Long live the GDI eh?
    Yep Although I pass on, its legacy remains...
    Just Google It. √

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

  6. #6
    Registered User 4point5's Avatar
    Join Date
    Oct 2002
    Posts
    44

    Cool

    Screw the GDI! Its sucks! Go to hell stupid GDI.

    Just foolin'.

    Actually, I'm not sure where you're supposed to get those files, but I learned about thier existence and downloaded them from sunlight's page.

    I hope they help ya.
    Last edited by 4point5; 11-05-2002 at 02:27 PM.
    Don't try so hard. Just let it happen.

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Hmm, sound like Sunlight made 'em Oh well, if he made them they ought to be good
    Just Google It. √

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

  8. #8
    Registered User 4point5's Avatar
    Join Date
    Oct 2002
    Posts
    44

    Cool

    No, they are made by Micro$oft. Look at the source code.
    Don't try so hard. Just let it happen.

  9. #9
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    Just follow sunlight's tutorials...perhaps you are already. Just don't do what I tried (Learning DX before GDI)

  10. #10
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Made by Microsoft? Sounds good Except that I might be just furthering their cause to take over the world
    Just Google It. √

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

  11. #11
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Actually, I'm not sure where you're supposed to get those files, but I learned about thier existence and downloaded them from sunlight's page.
    I just had a brainwave, and I did a search on my comp for them. Guess what? They were in the include section of my DirectX8 SDK folder Oh well, at least I know they're there now

    **EDIT**
    oops, I just did another search, and they disappeared Oh well
    Last edited by Hunter2; 11-11-2002 at 08:56 PM.
    Just Google It. √

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

  12. #12
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Hunter, in your last post you just went through a crazy amount of emotions lol

  13. #13
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I'm an emotional guy
    Just Google It. √

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

  14. #14
    Registered User 4point5's Avatar
    Join Date
    Oct 2002
    Posts
    44

    Cool

    Did you cry when Bambi and ET died?

    Don't try so hard. Just let it happen.

  15. #15
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I cried for Bambi but et was too ugly!
    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

Similar Threads

  1. Get pixel values from pic
    By Leite33 in forum Windows Programming
    Replies: 4
    Last Post: 09-12-2006, 01:13 PM
  2. Pic 16f84a
    By system_eyes in forum C Programming
    Replies: 2
    Last Post: 08-05-2003, 02:52 AM
  3. My Pic (Finally Bought a scanner!)
    By civix in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 11-19-2002, 02:54 PM
  4. PIC Microcontrolers
    By face_master in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-28-2002, 11:29 PM
  5. pic movement
    By pode in forum Game Programming
    Replies: 31
    Last Post: 08-21-2002, 09:30 PM