|
-
Nov 11th, 2007, 03:19 AM
#1
Thread Starter
Lively Member
[DirectX 8] Error
My error: Something about variable block set.
My error line: the line that has " 'error " on it.
My Code:
vb Code:
Dim Dx As DirectX8
Dim D3d As Direct3D8
Dim D As D3DX8
Dim D3DDevice As Direct3DDevice8
Dim MainFont As D3DXFont
Dim MainFontDesc As IFont
Dim TextRect As RECT
Dim fnt As New StdFont
Dim TextToDraw As String
Public Sub DrawText(Text As String, X As Long, Y As Long)
fnt.Name = "Verdana"
fnt.Size = 18
fnt.Bold = True
Set MainFontDesc = fnt
'Error Set MainFont = D.CreateFont(D3DDevice, MainFontDesc.hFont)
TextRect.Top = 1
TextRect.Left = 1
TextRect.Bottom = Y
TextRect.Right = X
D3DDevice.BeginScene
D.DrawText MainFont, &HFFCCCCFF, Text, TextRect, DT_TOP Or DT_CENTER
D3DDevice.EndScene
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End Sub
Public Sub Init()
Dim DispMode As D3DDISPLAYMODE
Dim D3DWindow As D3DPRESENT_PARAMETERS
Set Dx = New DirectX8
Set D3d = Dx.Direct3DCreate()
D3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode
D3DWindow.Windowed = 1
D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
D3DWindow.BackBufferFormat = DispMode.Format
Set D3DDevice = D3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Client.hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
End Sub
-
Nov 11th, 2007, 07:15 PM
#2
Frenzied Member
Re: [DirectX 8] Error
People here actually understand error statements. Don't give us what the error was about, but rather what the error actually was.
-
Nov 12th, 2007, 06:06 PM
#3
Thread Starter
Lively Member
Re: [DirectX 8] Error
object variable or with block not set on line Set MainFont = D.CreateFont(D3DDevice, MainFontDesc.hFont)
-
Nov 12th, 2007, 07:07 PM
#4
Re: [DirectX 8] Error
Like many common errors, this one is described in the article What does this error mean, and how do I fix it? from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)
The problem is that you are trying to use an object that you haven't set up yet.. and on that line you have a few objects: MainFont, D, D3DDevice, and MainFontDesc
- MainFont is not the issue, as that is the one you are trying to Set.
- MainFontDesc is not an issue either, as that has been Set on the previous line.
- Assuming that the Init() routine has run, D3DDevice also will have been Set already.
That leaves us with D, and I can't see any code which sets it - so that is almost certainly the cause. I haven't used DirectX enough to know how it should be set up, but hopefully you will be able to find out from whatever source(s) you have built the other code from (or via a search of this forum).
-
Nov 15th, 2007, 06:14 PM
#5
Thread Starter
Lively Member
Re: [DirectX 8] Error
I think I found the problem, this line:
"vb Code:
Dim D as D3DX
'Needs to be
Dim D as New D3DX
-
Nov 15th, 2007, 11:11 PM
#6
Fanatic Member
Re: [DirectX 8] Error
Shouldn't Set MainFont = D.CreateFont(D3DDevice, MainFontDesc.hFont) only be called once?
-
Nov 20th, 2007, 04:57 PM
#7
Thread Starter
Lively Member
Re: [DirectX 8] Error
First time I use it it crashes.
-
May 17th, 2008, 07:42 AM
#8
New Member
Re: [DirectX 8] Error
 Originally Posted by psychotomus
Shouldn't Set MainFont = D.CreateFont(D3DDevice, MainFontDesc.hFont) only be called once?
YES!
-
May 17th, 2008, 07:46 AM
#9
New Member
Re: [DirectX 8] Error
VB Code:
Dim Dx As DirectX8
Dim D As D3DX8
Must be:
VB Code:
Dim Dx As New DirectX8
Dim D As New D3DX8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|