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 ?
Printable View
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 ?
never mind i fixed it, i drew a black image in the backbuffer and that did the trick.
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....
NoteMe's right filling the BackBuffer is the quickest way:
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.VB Code:
Back.BltColorFill ScreenRect, iColor
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...;)
I don't get you? I always declare my rects just like:
and it just automatically uses the RECT from DxVBLib. Are you saying I should declare it differently?VB Code:
ScreenRect as RECT
In the CAr game I'm doing now, I had to write
VB Code:
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...
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....
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.
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...
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.
.....
Nope line like this wont pop up if you only refference DX8
VB Code:
Dim dx As New DirectX7 Dim dd As DirectDraw7
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.
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...
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....Quote:
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'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" ???
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?
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...:D...Quote:
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.
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.
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....
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.
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???
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?
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???
Try this:VB Code:
Public Sub GetKeyboard() as DIKEYBOARDSTATE On Local Error Resume Next Dim KD as DIKEYBOARDSTATE 'Temp keyboard 'Get keyboard information Keyboard.GetDeviceStateKeyboard KD GetKeyboard = KD 'If we lost the device try to re-acquire If Err.Number <> 0 Then Keyboard.Acquire If Err.Number <> 0 Then 'Can't acquire keyboard again Exit Sub End If End If End Sub Private Function InitDInput() As Byte On Error GoTo 1 'Create the direct input object Set DInput = DirectX.DirectInputCreate() Exit Function 1 MsgBox "An error occured while initializing Direct Input: " & vbCrLf & vbCrLf & Err.Description, vbCritical, "Electro Direct Draw" InitDInput = 1 End Function Private Function InitKeyboard(ByVal TargetHandle As Long) As Byte On Error GoTo 1 'Load the keyboard device Set Keyboard = DInput.CreateDevice("GUID_SysKeyboard") 'Get exclusive keyboard access 'NOTE: Exclusive access causes error so must use NonExclusive. Keyboard.SetCommonDataFormat DIFORMAT_KEYBOARD Keyboard.SetCooperativeLevel TargetHandle, DISCL_FOREGROUND Or DISCL_NONEXCLUSIVE 'Acquire the device Keyboard.Acquire Exit Function 1 MsgBox "An error occured while initializing the keyboard: " & vbCrLf & vbCrLf & Err.Description, vbCritical, "Electro Direct Draw" InitKeyboard = 1 End Function Private Sub ReleaseKeyboard() On Error Resume Next 'Remove input devices Keyboard.Unacquire Set Keyboard = Nothing End Sub Private Sub ReleaseDInput() On Error Resume Next 'Release the DInput object Set DInput = Nothing End Sub Public Sub EndDirectDraw(ByVal TargetHandle As Long) 'Release the surfaces (graphics) ReleaseSurfaces 'Release objects ReleaseMouse ReleaseKeyboard ReleaseDInput ReleaseDDraw End Sub Public Function StartDirectDraw( .... , ByVal TargetHandle As Long) 'Init objects If InitDInput = 1 Then GoTo 1 If InitKeyboard(TargetHandle) = 1 Then GoTo 1 Exit Function 1 EndDirectDraw TargetHandle End Function
That should be all you will need. I got to go now so speak to you later.
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....
Oh yea, to check the keys:VB Code:
Dim Keys As DIKEYBOARDSTATE Keys = GetKeyBoard() If Keys.Key(DIK_UP) And &H80 <> 0 Then 'Up key pressed Else 'Not Pressed End If If Keys.Key(DIK_DOWN) And &H80 <> 0 Then 'Down key pressed Else 'Not Pressed 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.
Thanks...I found out more or less the exact same thing right now...Thanks. See you later. And looking forward for your DX9 experiences...:)
I think I found our answer about DX9 .... http://www.visualbasicforum.com/t56320.html
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.
I think I have to get me VB.Net...but I need some money...:D
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.