Jump to content
  • Advertisement
Sign in to follow this  
Programmer101

Triangles not showing up in a vb6 program

This topic is 4318 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, I'm trying to make a toolset in vb so I'm using Vb6 b/c I don't really want to used mdx. Now I have gotten directx programs to work just fine but I'm really having trouble with getting it to work in vb. The triangles don't come up. This is my init code:
'Create dx object
Set dx = New DirectX8

'create direct3d object
Set d3d = dx.Direct3DCreate

'set present parameters
d3dpp.hDeviceWindow = Me.hWnd
d3dpp.BackBufferCount = 1
d3dpp.BackBufferWidth = 400
d3dpp.BackBufferHeight = 300
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
d3dpp.Windowed = 1
d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, d3ddm
d3dpp.BackBufferFormat = d3ddm.Format
d3dpp.EnableAutoDepthStencil = True
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8
d3dpp.flags = 0

'Create d3d device
Set d3ddev = d3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_MIXED_VERTEXPROCESSING, d3dpp)

d3ddev.SetRenderState D3DRS_ZENABLE, True
d3ddev.SetRenderState D3DRS_ZWRITEENABLE, True
d3ddev.SetRenderState D3DRS_LIGHTING, False
d3ddev.SetRenderState D3DRS_ZENABLE, D3DZB_TRUE
d3ddev.SetRenderState D3DRS_ZWRITEENABLE, D3DZB_TRUE
d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE, True
d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, True
d3ddev.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
d3ddev.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
d3ddev.SetRenderState D3DRS_AMBIENT, RGB(50, 50, 50)
d3ddev.SetRenderState D3DRS_FOGENABLE, False

'set present rectangle
drect.Left = 300
drect.Top = 30
drect.Right = 700
drect.bottom = 330

Dim matProj As D3DMATRIX
D3DXMatrixPerspectiveFovLH matProj, g_pi / 4, 1, 1, 1000
d3ddev.SetTransform D3DTS_PROJECTION, matProj

LoadTerr (0)

Dim VertexSizeInBytes As Long

VertexSizeInBytes = Len(C1Verts(0))

' Create the vertex buffer.
Set g_T1VB = d3ddev.CreateVertexBuffer(VertexSizeInBytes * 66049, 0, D3DFVF_VERTEXFVF, D3DPOOL_DEFAULT)

' fill the vertex buffer from our array
D3DVertexBuffer8SetData g_T1VB, 0, VertexSizeInBytes * (66049), 0, C1Verts(0)

here is the render code:
d3ddev.Clear 0, ByVal 0, D3DCLEAR_ZBUFFER Or D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, RGB(160, 160, 160), 1#, 0

d3ddev.BeginScene

Dim matView As D3DMATRIX
D3DXMatrixLookAtLH matView, vec3(0#, 3#, -5#), _
                            vec3(0#, 0#, 0#), _
                            vec3(0#, 1#, 0#)
                                 
d3ddev.SetTransform D3DTS_VIEW, matView

'Draw the triangles in the vertex buffer
sizeOfVertex = Len(VERTEX)
d3ddev.SetStreamSource 0, g_T1VB, sizeOfVertex
d3ddev.SetVertexShader D3DFVF_CUSTOMVERTEX
For I = 0 To I < 256
        d3ddev.DrawPrimitive D3DPT_TRIANGLESTRIP, I * (2 * (256 + 1)), 256 * 2
Next I

' End the scene
d3ddev.EndScene
     
' Present the backbuffer contents to the front buffer (screen)
d3ddev.Present ByVal 0, drect, 0, ByVal 0

Thanks to anyone who reads this!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!