Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Go Back  Xtreme Visual Basic Talk > > > > Why Does My Terrain Generator Crashes VB???


Reply
 
Thread Tools Display Modes
  #1  
Old 07-18-2005, 04:41 PM
GBInFlames's Avatar
GBInFlames GBInFlames is offline
Freshman
 
Join Date: Jul 2005
Location: Ontario
Posts: 24
Angry Why Does My Terrain Generator Crashes VB???


K... this is my first post on this forum... i created this account specificaly because of this problem... so Heres the problem, When I try to draw my terrain to the screen it crashes vb, no error messages or anything, it just closes... a few days ago, i was reading a thread where some guy had the same problem, and the dude who replyed to his thread said it had something to do with trying to write to memory that he didn't have access to, and all he had to do was call something beforehand... but i found that thread before i had this problem, and i didn't bookmark it, and now i can't find it again, so im here asking for help...

Heres the important parts of my code...

Code:
Sub SetVertex()
Dim ix As Single
Dim iz As Single
Dim i As Integer

ReDim Vertex(1 To ((Game.MapW + 1) * (Game.MapW + 1)))

i = 1
For iz = 0 To Game.MapH
    For ix = 0 To Game.MapW
        Vertex(i) = MakeVertex(ix, Rnd * 2, iz, 0, 0, 0, (1 / Game.MapW) * ix, (1 / Game.MapH) * iz)
    i = i + 1
    Next ix
Next iz

End Sub
This fills in the vertex info

Code:
Sub SetIndex()
Dim i As Integer
Dim i2 As Integer
Dim itst As Integer

ReDim index(1 To (((Game.MapW * Game.MapH) * 3) * 2))

i2 = 1

For i = LBound(index) To UBound(index) - 5

For itst = 1 To Game.MapH
    If (Game.MapW + 1) * itst = i2 Then
        i2 = i2 + 1
        GoTo Continue
    End If
Next itst

Continue:

index(i) = i2
index(i + 1) = i2 + 1
index(i + 2) = i2 + (Game.MapW + 1) + 1

index(i + 3) = i2 + (Game.MapW + 1) + 1
index(i + 4) = i2 + (Game.MapW + 1)
index(i + 5) = i2

i2 = i2 + 1
i = i + 5
Next i

End Sub
This fills in the index info

Code:
Set VertexBuffer = D3DDevice.CreateVertexBuffer(UBound(Vertex) * Len(Vertex(1)), 0, Unlit_FVF, D3DPOOL_DEFAULT)
If VertexBuffer Is Nothing Then GoTo InitFailed
    
Set IndexBuffer = D3DDevice.CreateIndexBuffer(UBound(index) * Len(index(1)), 0, D3DFMT_INDEX16, D3DPOOL_DEFAULT)
If IndexBuffer Is Nothing Then GoTo InitFailed
This creates the indexbuffer, and the vertexbuffer

Code:
D3DVertexBuffer8SetData VertexBuffer, 0, UBound(Vertex) * Len(Vertex(1)), 0, Vertex(1)
D3DIndexBuffer8SetData IndexBuffer, 0, UBound(index) * Len(index(1)), 0, index(1)
This sets the vertex and index info into there buffers...

Code:
D3DDevice.SetVertexShader Unlit_FVF 'Custom vertex type
    
D3DDevice.SetStreamSource 0, VertexBuffer, Len(Vertex(1))
D3DDevice.SetIndices IndexBuffer, 0 '-1
And this sets the vertex shader to my custom vertex type then it sets my vertex buffer as the stream source, and finaly (Im not to sure about this) it sets my indexbuffer as the index source i think...

Code:
D3DDevice.SetMaterial Material
D3DDevice.SetTexture 0, texture(0)
D3DDevice.DrawIndexedPrimitive D3DPT_TRIANGLELIST, 0, UBound(index), 0, (Game.MapW * Game.MapH) * 2
and then i render it like this...

Now i have watched this program run in the debugger a few times, and all the vertex/index info seems to get set right... its just when the render takes place, it crashes (most of the time), some times it doesn't crash, Itll run but the terrain looks like 3 or 4 different terrains all overlaped... If someone can help me with this problem, i would be very greatfull...
Reply With Quote
  #2  
Old 07-24-2005, 09:13 AM
km176351's Avatar
km176351 km176351 is offline
Regular
 
Join Date: Oct 2003
Posts: 80
Question

Hi, I'm not sure if this quite the same thing but when I was creating a game a little while ago, I was having problems with VB just exiting when I tryed to run the program. I eventually found out that whenever I changed any code in any of the modules after running the program, even just adding a comment, the next time I tryed to run it, it would crash.
I don't know why it used to do this or why it happened but my workaround was to save the project each time before running it again. I would be interested to hear if anyone else had this problem. Other programs I have created have not had it and have not differed that greatly
Reply With Quote
  #3  
Old 07-24-2005, 09:18 AM
ghoti ghoti is offline
Senior Contributor
 
Join Date: Jun 2003
Posts: 818
Default

Hi folks,

i had a similair problem.
When i stared VB changed some code saved it and run it, no problems occured but after the first time i tested the program(game) the game didn't start and VB crashed.

I found out that it had something to do with my code that tested what my videocard was capable in doing. I used the tutorial from directx4vb.com and it gave problems but no errors. When i skipped checking the capabilities of the videocard i hadn't had that problem anymore.

so my guess is that it is code related something that is loaded but not unloaded and gives an error or something in that area.

greetz rein
__________________
Let is snow, let it snow, let it snow
Reply With Quote
  #4  
Old 08-04-2005, 09:17 PM
GBInFlames's Avatar
GBInFlames GBInFlames is offline
Freshman
 
Join Date: Jul 2005
Location: Ontario
Posts: 24
Unhappy ...

Well thx for trying to help guys, but i am still unable to fix the problem ... but it doesn't really matter anymore, because i have scrapped that project, and started over, with a differend method, i think this way might be slower, but atleast it works...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB??? Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
 
Why Does My Terrain Generator Crashes VB???
Why Does My Terrain Generator Crashes VB???
 
-->