Jump to content
  • Advertisement
Sign in to follow this  
jor1980

I only see the primitives one second

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

Hi i have created the next code that reads the data of a 3d eye from a file, but when i execute the code i only see the eye only one second.What is wrong? here is the code: Imports Microsoft.DirectX.Direct3D Imports Microsoft.DirectX Public Class Form1 Private device As Device Dim verticest As CustomVertex.PositionColoredTextured() = New CustomVertex.PositionColoredTextured(112) {} Dim indices As Short() = New Short(626) {} Public Sub Initialize() Dim Present As PresentParameters = New PresentParameters Present.Windowed = True Present.SwapEffect = SwapEffect.Discard device = New Device(0, DeviceType.Hardware, Me.Handle, CreateFlags.SoftwareVertexProcessing, Present) device.RenderState.Lighting = False End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Text = "DirectX Tutorial using Visual Basic" Initialize() Me.Setstyle(Controlstyles.AllPaintingInWmPaint Or Controlstyles.Opaque, True) Dim nºarchivo As Integer = FreeFile() FileOpen(nºarchivo, My.Computer.FileSystem.SpecialDirectories.Desktop & "\ojo23d", OpenMode.Input) For i = 0 To 112 Dim dato As String dato = LineInput(nºarchivo) Dim Datoparts As String() Datoparts = Split(dato, " ") verticest(i).SetPosition(New Vector3(NumerosDecimales(Datoparts(0)), NumerosDecimales(Datoparts(1)), NumerosDecimales(Datoparts(2)))) verticest(i).Color = Color.Red.ToArgb verticest(i).Tu = (NumerosDecimales(dato(3))) verticest(i).Tv = (NumerosDecimales(dato(4))) Next For i = 0 To 208 Dim dato As String dato = LineInput(nºarchivo) Dim Datoparts As String() Datoparts = Split(dato, " ") indices(3 * i) = Datoparts(0) indices((3 * i) + 1) = Datoparts(1) indices((3 * i) + 2) = Datoparts(2) Next End Sub Private Sub Form1_OnPaint(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Paint device.RenderState.CullMode = Cull.None device.Clear(ClearFlags.Target, Color.Black, 1, 0) Dim imagen As New Bitmap("C:\Users\Jorge\Desktop\ojo.bmp") Dim textura As New Texture(device, imagen, Usage.Dynamic, Pool.Default) device.MultiplyTransform(TransformType.Projection, Matrix.PerspectiveFovLH(Math.PI / 4, _ Me.Width / Me.Height, 1, 50)) device.MultiplyTransform(TransformType.World, Matrix.LookAtLH(New Vector3(0, 0, 30), New Vector3(0, 0, 0), New Vector3(0, 1, 0))) device.VertexFormat = CustomVertex.PositionColoredTextured.Format device.SetTexture(0, textura) device.BeginScene() device.DrawIndexedUserPrimitives(PrimitiveType.TriangleList, 0, 113, 209, indices, True, verticest) device.EndScene() device.Present() Me.Invalidate() End Sub

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Cambo_frog
Don't call Invalidate() in your OnPaint handler.


you were right, now it works ok.

i put that sentence because i saw in a tutorial, but also put the next:

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)

End Sub

but if i put that i only saw the things behind my form, Could you explain me way those sentences works?


Thank´s for all


Share this post


Link to post
Share on other sites
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!