Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MiloshJ

CreateSphere

This topic is 5729 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

I want to use the createsphere function in visual basic directx, and was wondering if someone could make and send or post a sample program in vb, but without lighting and all that stuff, just using a createsphere make a simple sphere on the screen. I tried using the help file but it didnt help much. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Create a New Project...Add a timer to the form...Add a reference (Project->References) to the "DirectX 8 for Visual Basic Type Library". Cut and paste this into the form. It should be a unlit wireframe sphere spinning.
I think this is the Very bare you could get away with, but should give you something to play with.

Here's a link to some good tutorials...
http://www.exhedra.com/DirectX4VB/Index.asp


Private gD3D As Direct3D8
Private gDX As New DirectX8
Private gD3DX As New D3DX8
Private gDevice As Direct3DDevice8
Private gMesh As D3DXMesh

Private Sub Form_Load()
Set gD3D = gDX.Direct3DCreate

Dim DM As D3DDISPLAYMODE
gD3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DM

Dim PP As D3DPRESENT_PARAMETERS
PP.Windowed = True
PP.SwapEffect = D3DSWAPEFFECT_DISCARD
PP.BackBufferFormat = DM.Format
PP.EnableAutoDepthStencil = True
PP.AutoDepthStencilFormat = D3DFMT_D16
Set gDevice = gD3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Me.hWnd, D3DCREATE_MIXED_VERTEXPROCESSING, PP)

Dim M As D3DMATRIX
D3DXMatrixLookAtLH M, Vec3(0, 0, -10), Vec3(0, 0, 0), Vec3(0, 1, 0)
gDevice.SetTransform D3DTS_VIEW, M
D3DXMatrixPerspectiveFovLH M, 3.14 / 4, Me.ScaleHeight / Me.ScaleWidth, 1, 10000
gDevice.SetTransform D3DTS_PROJECTION, M

Dim Buff As D3DXBuffer
Set gMesh = gD3DX.CreateSphere(gDevice, 1, 20, 20, Buff)

Timer1.Interval = 1000 / 60
Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()
Static Rot As Single
Dim M As D3DMATRIX

gDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET + D3DCLEAR_ZBUFFER, 0, 1, 0
gDevice.BeginScene

D3DXMatrixRotationY M, Rot: Rot = Rot + 0.04
gDevice.SetTransform D3DTS_WORLD, M
gDevice.SetRenderState D3DRS_FILLMODE, D3DFILL_WIREFRAME
gDevice.SetRenderState D3DRS_LIGHTING, False
gMesh.DrawSubset 0

gDevice.EndScene
gDevice.Present ByVal 0, ByVal 0, 0, ByVal 0

End Sub

Public Function Vec3(x, y, z) As D3DVECTOR
Vec3.x = x: Vec3.y = y: Vec3.z = z
End Function


[edited by - dabx11 on December 8, 2002 6:44:59 AM]

[edited by - dabx11 on December 8, 2002 7:00:08 AM]

Share this post


Link to post
Share on other sites
We put it in, but we have a problem trying to move the sphere around. We can move the other stuff like the triangles and lines we created but cant move spheres. Anyone got ideas?

Share this post


Link to post
Share on other sites

  • 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!