OpenTK Würfel erstellen

  • VB.NET

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von 00yoshi.

    OpenTK Würfel erstellen

    Hallo,

    ich möchte in OpenGL / OpenTK einen Würfel erstellen. Da ich sowieso schon davon nix versteh, hab ich genug zu knobeln. Also:
    Gebt mir bitte nur ein Codebeispiel (GLBox.Paint) wie ich ein quadratisches Face erstelle Bittäääääääää :)

    lg LsFan
    Ernsthaft. Es gibt wahrscheinliche hunderte Tutorials wie man mit OpenGL einen Würfel zeichnet. Also nenne mir einen Grund weshalb hier nochmal jemand einen halben Artikel als Antwort für dich schreiben sollten, den du wahrscheinlich gar nicht liest oder nur halb verstehst.


    Opensource Audio-Bibliothek auf github: KLICK, im Showroom oder auf NuGet.

    VB.NET-Quellcode

    1. ´GL.Clear(ClearBufferMask.ColorBufferBit)
    2. GL.Clear(ClearBufferMask.DepthBufferBit)
    3. 'Basic Setup for viewing
    4. Dim perspective As Matrix4 = Matrix4.CreatePerspectiveFieldOfView(1.04, GlControl1.Width / GlControl1.Height, 1, 10000) 'Setup Perspective
    5. Dim lookat As Matrix4 = Matrix4.LookAt(100, 20, 0, 0, 0, 0, 0, 1, 0) 'Setup camera
    6. GL.MatrixMode(MatrixMode.Projection) 'Load Perspective
    7. GL.LoadIdentity()
    8. GL.LoadMatrix(perspective)
    9. GL.MatrixMode(MatrixMode.Modelview) 'Load Camera
    10. GL.LoadIdentity()
    11. GL.LoadMatrix(lookat)
    12. GL.Viewport(0, 0, GlControl1.Width, GlControl1.Height) 'Size of window
    13. GL.Enable(EnableCap.DepthTest) 'Enable correct Z Drawings
    14. GL.DepthFunc(DepthFunction.Less) 'Enable correct Z Drawings
    15. GL.Rotate(mousepos.Y / 2, 0, 0, 1)
    16. GL.Rotate(mousepos.X / 2, 1, 0, 0)
    17. GL.PushMatrix()
    18. GL.Begin(BeginMode.triangles)
    19. GL.Color3(Color.Yellow)
    20. GL.Vertex3(-25, -25, -25)
    21. GL.Color3(Color.Gray)
    22. GL.Vertex3(-25, -25, 25)
    23. GL.Color3(Color.Chocolate)
    24. GL.Vertex3(25, -25, -25)
    25. gl.end

    In paintevent
    ,dann fertig.
    p.s. kann man leicht ergoogeln.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „00yoshi“ ()