Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help file Creation in Visual Basic

QweetQweet Member Posts: 15
Hey all, I just got into Visual Basic programming with directx (specifically directdraw). If you have any questions for me I'll be happy to Attempt to answer them in here!

check out http://francis.dupont.free.fr/coindev/english/
for some good stuff!

Comments

  • thekemo2099thekemo2099 Member Posts: 5
    I'm also using Visual Basic with DirectX (hoping to move on to VC++).
    Could you please explain me (IN DDraw7, NOT DDraw6) what do I need to get a surface described,initialized and/or created efficently from a file. Things have changed since DX6.

    I'm already downloading the DirectX 7 SDK.


  • QweetQweet Member Posts: 15
    K, if you check out the site I posted http://francis.dupont.free.fr/coindev/english/
    it is an excellent resource for directdraw tutorials.

    But here, I'll give you the quick lowdown anyway:
    (This is to make a fullscreen game using flipping!)

    First you need a directx7 object.
    Dim DX As New DirectX7
    Then you need a directdraw object.
    Dim DD As DirectDraw7
    After that you need 2 surface, a backbuffer surface (to hold the stuff offscreen, then you flip it onto the screen) and a primary surface (which is displayed on the screen.)
    Dim Primary As DirectDrawSurface7
    Dim Backbuffer As DirectDrawSurface7
    And then create a surface for the background image, and any other sprites etc.
    Dim Ball As DirectDrawSurface7
    Dim Background As DirectDrawSurface7
    and then you need to initialize everything. I'll copy in the code and explain it afterwards.

    Set DD = DX.DirectDrawCreate("")
    DD.SetCooperativeLevel frmMain.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
    DD.SetDisplayMode 640, 480, 16, 0, DDSDM_DEFAULT
    This sets the Directdraw object, and then it sets the cooperative level of the main form to fullscreen. Then it sets the diplay mode of the screen to 640x480 resolution, with 16bit colour(i think, 8 would be 256 colours).

    Sub CreatePrimarySurface()
    Dim ddsd As DDSURFACEDESC2
    ddsd.lFlags = DDSD_BACKBUFFERCOUNT Or DDSD_CAPS
    ddsd.lBackBufferCount = 1
    ddsd.ddscaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_PRIMARYSURFACE Or DDSCAPS_VIDEOMEMORY
    Set Primary = DD.CreateSurface(ddsd)

    End Sub

    this creates a ddsurfacedesc2, fills in the appropriate things for a primary surface and then sets primary with dd.createsurface(ddsd).

    Sub CreateBackBufferSurface()
    Dim ddscaps As DDSCAPS2
    ddscaps.lCaps = DDSCAPS_BACKBUFFER Or DDSCAPS_VIDEOMEMORY
    Set Backbuffer = Primary.GetAttachedSurface(ddscaps)
    End Sub

    This is a little more confusing.. usually i just copy this code in and not worry about it.. basically its attaching the backbuffer to the primary so it can be "flipped".

    From then on if you want to create surfaces from bitmap files, its very simple:
    Dim ddsd As DDSURFACEDESC2

    Set Background = DD.CreateSurfaceFromFile(App.Path & "ackground.bmp", ddsd)
    Set Ball = DD.CreateSurfaceFromFile(App.Path & "all.bmp", ddsd)

    And then to blit it there is dd.blt and dd.bltfast... the difference is that in blt you specify a rect to blit to... and in bltfast you specify an x and y coordinate to blit to.

    backbuffer.blt rec(0,0,0,0), background, rec(0,0,0,0), ddblt_wait

    Putting in an empty rec specifies you want to copy to the WHOLE screen, and copy the WHOLE image. (rec is a function that returns a rec:
    Function REC(X As Integer, Y As Integer, X1 As Integer, Y1 As Integer) As RECT
    REC.Left = X
    REC.Right = X1
    REC.Top = Y
    REC.Bottom = Y1
    End Function
    )

    for bltfast it is the same:
    backbuffer.bltfast 10, 10, ball, rec(0,0,0,0), ddbltfast_wait

    And then to copy all this to the screen you would just go
    primary.flip nothing, DDFLIP_WAIT

    Which flips the backbuffer contents to the screen.

    And don't forget to set ALL your objects to NOTHING when you're done!

    Simple, no? Any more questions, im happy to answer!

    Oh by the way if you want the src code to the simple directdraw pong game i made (it has all this stuff in it) just tell me or email me qwifpt@hotmail.com .


  • thekemo2099thekemo2099 Member Posts: 5
    Thanks for the info, by the way I checked:

    http://francis.dupont.free.fr/coindev/english/

    and I'm sorry to say a lot of the examples don't work because of two main reasons:

    1. The author of the files is french, he codes in a french version of VB6, which includes a DLL called: VB6FR.dll (can i get it from microsoft.com ?)

    2. In many other VB projects the guy forgot to include subroutines or functions, maybe he forgot to compile the modules that had those subs (most of the examples of this kind involve D3DIM)



  • QweetQweet Member Posts: 15

    : and I'm sorry to say a lot of the examples don't work because of two main reasons:
    :
    : 1. The author of the files is french, he codes in a french version of VB6, which includes a DLL called: VB6FR.dll (can i get it from microsoft.com ?)
    :
    : 2. In many other VB projects the guy forgot to include subroutines or functions, maybe he forgot to compile the modules that had those subs (most of the examples of this kind involve D3DIM)

    I have downloaded all the directdraw examples files, and they all work for me! True, some of the comments and variable and function names are in french but the program still works the same! I was mostly pointing out the tutorials section as reference for directdraw.
  • Shawn CarterShawn Carter Member Posts: 0

    _______ \ http://forcoder.org \ free video tutorials and ebooks about \ C++ Python Swift Perl Visual Basic .NET C# Visual Basic PL/SQL Java MATLAB C Assembly Ruby Delphi PHP JavaScript Go R Scratch Objective-C Hack Clojure Rust Prolog ABAP Lisp ML Fortran Julia Ada COBOL Logo VBScript Apex FoxPro Transact-SQL Alice Bash Awk Kotlin Dart Erlang LabVIEW Crystal Scala Scheme F# D SAS Lua \ __________

Sign In or Register to comment.