Results 1 to 33 of 33

Thread: Dx7 Problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Location
    RI
    Posts
    96

    Dx7 Problem

    I have a bmp displayed on the screen and you can move it around with the arrow keys but when i move the image it seems that the screen wasnt cleared after i moved it. any ideas ?
    Attached Images Attached Images  
    I program in: vb6,vb.net,html,c++,java/script

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Location
    RI
    Posts
    96
    never mind i fixed it, i drew a black image in the backbuffer and that did the trick.
    I program in: vb6,vb.net,html,c++,java/script

  3. #3
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Yes that is what you have to do...you are just copying the backbuffer to the screen so you are not deleting anything. Drawing a black image to the backbuffer every time would do the trick, but it will be slow. Try to fill the backbuffer with black color in stead. I think that is faster....

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    NoteMe's right filling the BackBuffer is the quickest way:
    VB Code:
    1. Back.BltColorFill ScreenRect, iColor
    Run this after you've flipped to the primary surface. iColor is the background color, usally black. ScreenRect is a type RECT and the size of the screen.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    NAd BTW I think the ScreenREct has to be of DX type, I think I have debugged a n error once for using a VB rect type. I had really problems seeing that error...

  6. #6
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I don't get you? I always declare my rects just like:
    VB Code:
    1. ScreenRect as RECT
    and it just automatically uses the RECT from DxVBLib. Are you saying I should declare it differently?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    In the CAr game I'm doing now, I had to write

    VB Code:
    1. Dim TempRect As DxVBLib.RECT        'Temperary rect size

    It took me ages to find out that one....I have no idea why....but it might have something with that I started the game using DX7 and DX8, but now I have changed the Keyboard class and Music class to only use DX7. So maybe I don't have to declare them that way anymore...let me check...

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    No..it works great now...so I guess that it had somthing to do with using both DX7 and DX8 at the same time...BTW don't try to do that. No mather what anybody else says. You will end up getting a lot of ****ed up errors....

  9. #9
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I guess if you've got DirectX7 and Direct8 both referanced in the project it could cause an error and that would fix it.

    I was thinking about using Dx 7 and 8 (or 9) but I guess i'll avoid it now.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  10. #10
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I have heard people talk about using both 7 and 8 at the same time. But if I did that always when I tried to use a property or a methid of a surface or anythig I had to properties/methods with the same name that I could choose from....and that is not good. It made a lot of errors. I'm not sure if there is something to do against this problem. But if it is, then I assume that using both Dx7 and 8 should go great...

  11. #11
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I've just thought: If you only referance DirectX 8 then DirectX 8 contains DirectX7 so you would just use the DirectX7 stuff from DirectX8, for example DirectDraw stoped at DirectX7 but DirectX8 will contain DirectDraw (Same as was in Direct7 because its not been changed since Dx7). TIthink thats right, can't be sure I'll just check tho, I'm prepared for a hundred and one errors.
    .....
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  12. #12
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Nope line like this wont pop up if you only refference DX8

    VB Code:
    1. Dim dx As New DirectX7          
    2. Dim dd As DirectDraw7

  13. #13
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    hey, who nicked DirectDraw out of DirectX8, i guess thats why DirectX7 is called DxVBLib and DirectX8 is Called DxVBLibA, so you can referance both.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  14. #14
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    So that way it tells you that your UDT is not declared. So you have to use both DX7 and 8 to program in DirectDraw ang get the new from DX8...

  15. #15
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Electroman
    hey, who nicked DirectDraw out of DirectX8, i guess thats why DirectX7 is called DxVBLib and DirectX8 is Called DxVBLibA, so you can referance both.
    I didn't know that it was two diffrent libraries. But maybe you can over steer it some way with alwasy wrie what lib you are talking about. That could do the trick....

  16. #16
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I'm gona go and sulk now, I didn't realise they got rid of DirectDraw I thought they'd jus froze it. Looks like theres gona be a lot of chaos in the future for anybody wanting DirectDraw and DirectX8 ,9 ,10,ect.. in a project.


    "alwasy wrie" ???
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  17. #17
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    It's more or less bak in DX9. Not omproved but it is the same as in DX7. But I havn't read a lot about it. All I have heard is that DX9 is supposed to be the start for VB.Net in DX. So I don¨'t hope that VB6 users will have problem using it. Anyone knows anything about that?

  18. #18
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I heard that Dx9 was only for .NET so VB6 wouldn't be able to use it. I've got someone to download me the Dx9 SDK (they have ADSL) and I should have it by wed so I'll know then, fingers crossed.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  19. #19
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Electroman
    I heard that Dx9 was only for .NET so VB6 wouldn't be able to use it. I've got someone to download me the Dx9 SDK (they have ADSL) and I should have it by wed so I'll know then, fingers crossed.
    I have 1Mbit ADSL too, but I don't have tim eor effort to start testing it out now. I'm in the middle of this big car game, so guess I'm going to wait for someone else to tell me......

  20. #20
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    You know I was looking at the tutorials for Direct3D on http://www.directx4vb.com and 3D doesn't seem that bad, I don't like the idea of textures needing to be squares with sizes of 2^n x 2^n. Even tho the graphics card i'v got (ATI RADEON 7500) works on any size at all and non square textures, prity neat but that means it will only work on my PC if I do that.

    I'll post it on this thread when I know if Dx9 works on VB6.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

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


    I'm going to start with D3D after I have finished this car game. But I don't want to start before we have learned matrixes and more about vectors in space at school. We we are going to start on that soon. So I guess that in 2-3 moths I'm ready to start out....

  22. #22
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    It's all prity well explained in those tutorials (DirectX3D (7)) it describes matrixes and vectors but you'll need to have a good understanding of Trig tho.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  23. #23
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I'm not worried about the math. I'm an A student in math and a B+ in physics. But I want to learn everything before I starts. So I can learn the DX part faster.


    BTW: have you ever used DXInput. For the keyboard???

  24. #24
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Yea, I made a DirectDraw Engine that uses DInput for the mouse and keyboard http://www.Electroman.co.uk/Electro2DE7.htm. The engine works fine except I'v been adding Collision detection and the pixel perfect one thros up errors everywhere, I feel like throing a brick at it some times.

    Wots your problem using DInput?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  25. #25
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Is it possible to test if the key is not pushed down in a pretty way. Becuase I only wants to add friction to the car when the acceleration button is not pressed down. If I add friction to it all the time it will destoy the purpose of the nice Log function I have made for the cars acceleration...Any ideas???

  26. #26
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Try this:
    VB Code:
    1. Public Sub GetKeyboard() as DIKEYBOARDSTATE
    2. On Local Error Resume Next
    3. Dim KD as DIKEYBOARDSTATE 'Temp keyboard
    4.    
    5.     'Get keyboard information
    6.     Keyboard.GetDeviceStateKeyboard KD
    7.     GetKeyboard = KD
    8.    
    9.     'If we lost the device try to re-acquire
    10.     If Err.Number <> 0 Then
    11.         Keyboard.Acquire
    12.        
    13.         If Err.Number <> 0 Then
    14.             'Can't acquire keyboard again
    15.            
    16.             Exit Sub
    17.         End If
    18.     End If
    19. End Sub
    20.  
    21. Private Function InitDInput() As Byte
    22. On Error GoTo 1
    23.     'Create the direct input object
    24.     Set DInput = DirectX.DirectInputCreate()
    25.     Exit Function
    26.    
    27. 1
    28. MsgBox "An error occured while initializing Direct Input: " & vbCrLf & vbCrLf & Err.Description, vbCritical, "Electro Direct Draw"
    29. InitDInput = 1
    30. End Function
    31.  
    32. Private Function InitKeyboard(ByVal TargetHandle As Long) As Byte
    33. On Error GoTo 1
    34.  
    35.     'Load the keyboard device
    36.     Set Keyboard = DInput.CreateDevice("GUID_SysKeyboard")
    37.    
    38.     'Get exclusive keyboard access
    39.     'NOTE: Exclusive access causes error so must use NonExclusive.
    40.     Keyboard.SetCommonDataFormat DIFORMAT_KEYBOARD
    41.     Keyboard.SetCooperativeLevel TargetHandle, DISCL_FOREGROUND Or DISCL_NONEXCLUSIVE
    42.    
    43.     'Acquire the device
    44.     Keyboard.Acquire
    45.     Exit Function
    46.    
    47. 1
    48. MsgBox "An error occured while initializing the keyboard: " & vbCrLf & vbCrLf & Err.Description, vbCritical, "Electro Direct Draw"
    49. InitKeyboard = 1
    50. End Function
    51.  
    52. Private Sub ReleaseKeyboard()
    53. On Error Resume Next
    54.     'Remove input devices
    55.     Keyboard.Unacquire
    56.     Set Keyboard = Nothing
    57. End Sub
    58.  
    59. Private Sub ReleaseDInput()
    60. On Error Resume Next
    61.     'Release the DInput object
    62.     Set DInput = Nothing
    63. End Sub
    64.  
    65. Public Sub EndDirectDraw(ByVal TargetHandle As Long)
    66.     'Release the surfaces (graphics)
    67.     ReleaseSurfaces
    68.    
    69.     'Release objects
    70.     ReleaseMouse
    71.     ReleaseKeyboard
    72.     ReleaseDInput
    73.     ReleaseDDraw
    74. End Sub
    75.  
    76. Public Function StartDirectDraw( .... , ByVal TargetHandle As Long)
    77.  
    78.     'Init objects
    79.     If InitDInput = 1 Then GoTo 1
    80.     If InitKeyboard(TargetHandle) = 1 Then GoTo 1
    81.  
    82.     Exit Function
    83. 1
    84. EndDirectDraw TargetHandle
    85. End Function

    That should be all you will need. I got to go now so speak to you later.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  27. #27
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I know how to initialize the keyboard in DX and how to use it. Bu tI don't think that it is an event triggered when you relese a key in DX. And I can't figgure out how to to this in a good way whitout a event. I think I will start a new thread asking this question. But thanks anyway....

  28. #28
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Oh yea, to check the keys:
    VB Code:
    1. Dim Keys As DIKEYBOARDSTATE
    2.  
    3.     Keys = GetKeyBoard()
    4.    
    5.     If Keys.Key(DIK_UP) And &H80 <> 0 Then
    6.         'Up key pressed
    7.     Else
    8.          'Not Pressed
    9.     End If
    10.    
    11.     If Keys.Key(DIK_DOWN) And &H80 <> 0 Then
    12.         'Down key pressed
    13.     Else
    14.          'Not Pressed
    15.     End If

    If you use a boolean to hold weather the key is pressed and in the else bit set the boolean to false and if its pressed make it true.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  29. #29
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Thanks...I found out more or less the exact same thing right now...Thanks. See you later. And looking forward for your DX9 experiences...

  30. #30
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I think I found our answer about DX9 .... http://www.visualbasicforum.com/t56320.html

  31. #31
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    My mate who I got the Dx9 SDK has been ill so I only got the SDK today, I got it working and it says in the installation that it works on VB6 aswel but the samples are all in .NET. Not to mention I can't get VB6 to add a referance to any dll's so I haven't been able to try it in VB I have got C++.NET tho and it works for that, I don't really like using C++ for this sort of thing tho cos i'm still learning C++. I looked at the link, guess i'm gona have to wait till I got VB.NET before I can use Dx9. It looks really good in C++ tho.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  32. #32
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I think I have to get me VB.Net...but I need some money...

  33. #33
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I got a friend who has VB.NET so I think i'll borrow it and see if its worth changing just yet. Only think i don't like is the language is suposed to be a bit diferent. I guess i'll pick it up quick tho.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

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