Results 1 to 30 of 30

Thread: [RESOLVED][VB]Some directdraw questions

  1. #1

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Resolved [RESOLVED][VB]Some directdraw questions

    ok, some of these may sound n00bish, I am new to directX, so here goes:

    after I have started the fullscreen mode, created the primary and backbuffer surfaces, how would I display buttons on the screen? do they need to be defined as their own surfaces, or just as RECTs? would I need to create a flipping chain just for these buttons? or is there a way I could just leave the primary surfaces up there? (and is it recommended I do so?)

    Thanks in advance.
    Last edited by outcast24817; May 18th, 2005 at 11:36 PM.
    **not completely learned**
    Complete control of the registry ~

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Some directdraw questions

    What version of DX are you using, and what language. prior to DX9 it is pretty differnt on how to do it compared to DX9.


    ØØ

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Some directdraw questions

    didnt directdraw only come with DX 7? didnt it change after that?

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Some directdraw questions

    DDraw does not come as a part of DX8, but in DX 9 it is back......but DDraw is the same in both versions, but how to make a GUI is pretty different....


    ØØ

  5. #5

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: Some directdraw questions

    well, i have the latest version of directx on my sytem, 9.2 b or something. but my project is using directx 7 (at least, thats what it is linked to)
    **not completely learned**
    Complete control of the registry ~

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Some directdraw questions

    I didnt actually know that thanks noteme

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Some directdraw questions

    If I remember irght in my old days, there was no simple way to use Win GUI in DX7. And DX7 had no classes on it's own for drawing a GUI. I remember seein Arbiter (was it him) that made his own chatt app in a game of his where he made the textbox ++ him self from scratch.


    And that is probably the easiest way to do it.

    And old friend of ours here on the forum (long time no see M) wrote a couple of tutorials on the topic. You can find them here:

    http://rookscape.com/vbgaming/tutBW.php
    http://rookscape.com/vbgaming/tutBX.php


    Then again, I am not sure if you are using VB at all, since you never told us, so if you are using C++ then you have a tutorial here:

    http://www.gamedev.net/reference/art...article994.asp

    But then again, if you are using C++, then you could just have used DX9 and used the GUI classes there to save you some trouble. So thats why I am guessing you are using VB.



    PSX9.0b is not the newest one. DX9.0c is.


    ØØ

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Some directdraw questions

    Quote Originally Posted by Pino
    I didnt actually know that thanks noteme

    NP...just happy to spread around some knowledge...



    ØØ

  9. #9

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: Some directdraw questions

    yea, i am using VB, and the last time i updated directx that was the newest one


    I looked at those pages, and they dont really show me what i need to know. I have looked at other code, and tried to duplicate it for my own uses, but it doesnt work. I am not trying to make my own window and such, i have a fullscreen game i am trying to make and JUST need to blt pictures to the screen. lol.
    **not completely learned**
    Complete control of the registry ~

  10. #10
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Some directdraw questions

    Well if you are just trying to Blt pictures to the screen, then do it as you do with all the other pictures you have on the screen. (Hopefully, ifyou have any)

    So just load them the normal way to a surface, and Blt them as usual.

    Do you have anything on your screeen at all?




    PS: Example code of what has been done after reading Machairaas tutorials.
    http://visualbasicforum.com/attachme...achmentid=8010




    ØØ

  11. #11

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: Some directdraw questions

    well, thats just it, i am a little confused about the theory, say i wanted to make my button go to the screen, would i load the bmp of the button into a surface, and then blt the surface to the backbuffer? or somehow load it into a RECT and then blt that to the backbuffer or what?
    **not completely learned**
    Complete control of the registry ~

  12. #12
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Some directdraw questions

    I am a bit confused about your term rect here. If you are talking about the RECT struct then that is not a conatiner for a picture. It stores information about the size of something (like a picture), if you mean something else, please elaborate.


    But what you should do is to load it to the surface, as you said, and then Blt it to the backbuffer, before you flip it to the screen.Thats correct.



    ØØ

  13. #13
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [VB]Some directdraw questions

    Like NoteMe said, all RECT stores is the size of the picture, not the picture itself.

  14. #14

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    ah... I think i see why i cant get anything on the screen.
    So i would load a picture to the surface, then i would create a RECT that has the dimensions of the picture, and then blt it onto the backbuffer, then flip the backbuffer. correct?
    **not completely learned**
    Complete control of the registry ~

  15. #15
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [VB]Some directdraw questions

    Yeah, that is exactly the way to go. The reason why you have the RECT there, is so you can choose to only Blt a small part of the picture, like for a helth bar, or if you have batched more then one picture into one surface, you can choose what picture from the surface you want to Blt.




    ØØ

  16. #16

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    right, so in this peice of code:

    BltFast(dx As Long, dy As Long, ddS As DirectDrawSurface7, srcRect As RECT, trans As CONST_DDBLTFASTFLAGS) As Long

    dx and dy would be?
    **not completely learned**
    Complete control of the registry ~

  17. #17
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [VB]Some directdraw questions

    If you have the DX SDK installed, you probably have the docs installed too. If not, it is higly recomended that you install it. It says there what all the parameters is.

    But if I remeber right, it is the X coordiante and the Y coordinate where you want to draw the sprite.

    And you can see that the rect for BltFast is the source rect. So you can't stretch and other things, but you can leave out a part of the source image if you want that.


    Hope that helps.
    ØØ

  18. #18

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    I already have the SDK, but it doesnt help much, most of it is for c++, and the managed languages section has some stuff, but under the directdraw section it has this

    Note: This documentation is preliminary and is subject to change.
    Warning: Microsoft® DirectDraw® has been deprecated. Deprecated components of Microsoft DirectX® 9.0 for Managed Code are considered obsolete. While these components are still supported in this release of DirectX 9.0 for Managed Code, they may be removed in the future. When writing new applications, you should avoid using these deprecated components. When modifying existing applications, you are strongly encouraged to remove any dependency on these components.
    The DirectDraw application programming interface (API) is the component of DirectX that enables you to directly manipulate display memory, the hardware blitter, hardware overlay support, and flipping surface support. For more information, see the Microsoft.DirectX.DirectDraw managed code reference documentation.

    So i go to the microsoft.directX.directdraw managed code refrerence documentation, and all of it gives me the same "deprecated" message.

    furthermore, i have attempted to load surfaces from files, and it doesnt want to work for me, the pictures are bmps. and I get an error on this part of the code:
    retval = dd.CreateSurfaceFromFile(path, ddsdf)
    retval is an integer, dd is my directdraw object, path is a string that is the path to the bmp, and ddsdf is a DDSURFACEDESC2 (with it's height set at 49, and its width set at 200) (the size of my picture) and some other things for ddsdf: ddsdf.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
    ddsdf.DDSCAPS.lCaps = DDSCAPS_OFFSCREENPLAIN And DDSCAPS_VIDEOMEMORY

    so when i run it I get an error that says: method or data member not found. and it highlights .CreateSurfaceFromFile

    I am beginning to think direct3D would be easier to work with... it isn't "deprecated"
    **not completely learned**
    Complete control of the registry ~

  19. #19
    Junior Member noi_max's Avatar
    Join Date
    Jul 2004
    Location
    Portland OR
    Posts
    18

    Re: [VB]Some directdraw questions

    Hi.

    Your CreateSurfaceFromFile method is used to set a surface.
    For example:
    VB Code:
    1. Dim mySurface As DirectDrawSurface7
    2.    Dim ddsdf As DDSURFACEDESC2
    3.    
    4.    ddsdf.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
    5.    ddsdf.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
    6.    ddsdf.lWidth = lWidth
    7.    ddsdf.lHeight = lHeight
    8.    
    9.    Set mySurface = DD.CreateSurfaceFromFile(Path, ddsdf)
    Hope that helps

  20. #20

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    thanks noi_max! but now i get errors when I try to blt to the backbuffer:

    retval = backbuffer.BltFast(200, 200, startgame1, REC(1, 200, 1, 49), DDBLTFAST_WAIT)

    it says: runtime error 91, object variable or with block variable not set
    got any ideas as to what is causing that?
    **not completely learned**
    Complete control of the registry ~

  21. #21
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [VB]Some directdraw questions

    I guess REC is supposed to be RECT???



    ØØ

  22. #22
    Junior Member noi_max's Avatar
    Join Date
    Jul 2004
    Location
    Portland OR
    Posts
    18

    Re: [VB]Some directdraw questions

    retval = backbuffer.BltFast(200, 200, startgame1, REC(1, 200, 1, 49), DDBLTFAST_WAIT)
    What is this:

    REC(1, 200 1, 49)

    Some kinda function?

    Anyhow, did you not set your surface (I'm guessing it's startgame) or your backbuffer? Is this fullscreen?

    Assuming you're working in fullscreen mode:
    * Create complex primary surface.
    * Create and attach backbuffer
    * Create your other surfaces
    * Blit surfaces onto backbuffer
    * Flip backbuffer onto primary.

    This is of course after you do your DirectX initialization. Looks like you've got some tutorial links in the thread to check out too.

    As complex as this all seems to you now.. believe me.. Direct3D is not easier.

    Here's some of my basic Initialization code.. if you're interested.
    VB Code:
    1. Public Sub InitDirectDrawFullScreen(frm As Form, ByVal lWidth As Long, _
    2.    ByVal lHeight As Long, ByVal bpp As Long)
    3.  
    4.    Set DX = New DirectX7
    5.    Set DD = DX.DirectDrawCreate("")
    6.    
    7.    DD.SetCooperativeLevel frm.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
    8.    DD.SetDisplayMode lWidth, lHeight, bpp, 0, DDSDM_DEFAULT
    9.    
    10.    Dim ddsd As DDSURFACEDESC2
    11.    
    12.    ddsd.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
    13.    ddsd.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_COMPLEX Or _
    14.       DDSCAPS_FLIP
    15.    ddsd.lBackBufferCount = 1
    16.    Set Primary = DD.CreateSurface(ddsd)
    17.    
    18.    Dim caps As DDSCAPS2
    19.    caps.lCaps = DDSCAPS_BACKBUFFER
    20.    
    21.    Set BackBuffer = Primary.GetAttachedSurface(caps)
    22.    
    23.    'Call sub to Init other surfaces
    24.    InitSurfaces
    25.    
    26. End Sub

  23. #23

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    well, i checked my code, re-wrote a few things, ect, but i still get the same error when I try to blt to the backbuffer.

    Here is the REC code:

    VB Code:
    1. Function REC(left As Integer, right As Integer, bottom As Integer, top As Integer) As RECT
    2.  REC.left = left
    3.  REC.right = right
    4.  REC.bottom = bottom
    5.  REC.top = top
    6. End Function

    I have tried my code with a normal RECT and using just this code above...
    **not completely learned**
    Complete control of the registry ~

  24. #24
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [VB]Some directdraw questions

    How did you set up the backbuffer, and how did you set up startgame1?



    ØØ

  25. #25

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    heres how i set up startgame1

    VB Code:
    1. Public startgame1 As DirectDrawSurface7
    2. dim buttondesc as ddsurfacedesc2
    3.  
    4. buttondesc.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
    5. buttondesc.DDSCAPS.lCaps = DDSCAPS_OFFSCREENPLAIN
    6. buttondesc.lWidth = 200
    7. buttondesc.lHeight = 49
    8. Set startgame1 = dd.CreateSurfaceFromFile("startgame1.bmp", buttondesc)
    9.  
    10. 'and the backbuffer settings:
    11. Set dd = dx.DirectDrawCreate("")  'create the DirectDraw interface
    12. dd.SetCooperativeLevel frmgame.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
    13. 'initialize directdraw interface
    14. dd.SetDisplayMode 640, 480, 32, 0, DDSDM_DEFAULT
    15.  
    16. 'primary
    17. ddsd.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
    18. ddsd.DDSCAPS.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
    19. ddsd.lBackBufferCount = 1
    20. Set primary = dd.CreateSurface(ddsd)
    21. 'backbuffer
    22. Dim DDSCAPS As DDSCAPS2
    23. ddsd2.DDSCAPS.lCaps = DDSCAPS_BACKBUFFER
    24. Set backbuffer = primary.GetAttachedSurface(ddsd2.DDSCAPS)
    **not completely learned**
    Complete control of the registry ~

  26. #26

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    i decided to start from scratch. I actually got something to happen this time, i can display the picture "startgame1" on the screen, the only thing is, when i start it I get that picture, and the rest of the background is a flickering mass of pixels that at one point could have been part of the last image my computer displayed before starting my app.

    Then i go back into developement and i get an automation error on the backbuffer.flip line
    I have included the code. could someone please take a look and tell me what I am doing wrong???
    Attached Files Attached Files
    **not completely learned**
    Complete control of the registry ~

  27. #27

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    still need help...
    **not completely learned**
    Complete control of the registry ~

  28. #28
    Junior Member noi_max's Avatar
    Join Date
    Jul 2004
    Location
    Portland OR
    Posts
    18

    Re: [VB]Some directdraw questions

    Hi!

    Couple of things you needed:

    1) A means of exiting the game. For testing I just put your terminate sub into the Form_Click event

    2) A seperate sub to initialize your offscreen surfaces, so if you've lost them you can call the sub to re-load them.
    You don't need to do this for the Primary or attached backbuffer, that's why i seperated it from your Init DX code.

    Here are the changes
    Attached Files Attached Files

  29. #29

    Thread Starter
    Lively Member outcast24817's Avatar
    Join Date
    Nov 2004
    Location
    USA
    Posts
    122

    Re: [VB]Some directdraw questions

    thanks noi.

    after hours of doing this myself I found that the error is caused when i exit the app and it tries to flip a surface that isnt there.

    but I didnt know if that was a problem with my code, or if I left something out... I guess I forgot to terminate, lol

    thanks for you're help guys!
    Last edited by outcast24817; May 17th, 2005 at 09:14 PM.
    **not completely learned**
    Complete control of the registry ~

  30. #30
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [VB]Some directdraw questions

    When a thread is resolved. Please add the green check mark to the first post in the thread by editing it. I did it for you this time.


    Thanks
    ØØ

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