tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
1
ZUGRIFFE
1702
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Rhax Rhax ist offline Grünschnabel
    Registriert seit
    Oct 2007
    Beiträge
    3
    ich versuche gerade einen vertexbuffer zu implementieren, habe jedoch nicht viel erfolg. ich erhalte nur ein scharzes bild, es sollte aber ein gelbes dreieck zu sehen sein. mittlerweile bin ich unzählige tutorials durchgegangen (meist c/c++) und ich finde den fehler nicht...

    hab schon viel rumprobiert und auch mit einem IntPtr statt float[] (für den Buffernamen) versucht. wo liegt der fehler?

    system: windows
    sprache: c# (.net 2.0)
    api: opengl 2.0 (tao framework: open gl binding 2.1.0.4 + win platform api binding 1.0.0.4)

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    
    class RenderGL
    {
        Form window = new Form();
        SimpleOpenGlControl control = new SimpleOpenGlControl();
     
        private float[] id = new float[1];
        float[] buffer = {3.0f, 3.0f, 0.0f,
                          9.0f, 3.0f, 0.0f,
                          3.0f, 9.0f, 0.0f};
     
        public RenderGL(string windowTitle)
        {
            title = windowTitle;
     
            window.ClientSize = new System.Drawing.Size(512, 512);
            window.Text = "RenderGL";
            window.Controls.Add(control);
     
            control.Dock = DockStyle.Fill;
            control.InitializeContexts();
     
            Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            Gl.glEnable(Gl.GL_DEPTH_TEST);
     
            Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Gl.glOrtho(0.0, 10.0, 0.0, 10.0, -1.0, 1.0);
     
            Gl.glGenBuffersARB(1, id);
            Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER, id[0]);
            Gl.glBufferDataARB(
                Gl.GL_ARRAY_BUFFER_ARB,
                (IntPtr)(buffer.Length * sizeof(float)),
                buffer,
                Gl.GL_STATIC_DRAW_ARB);
     
            window.Show();
        }
     
        // wird in der Hauptschleife aufgerufen
        public void Render()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
     
            Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER, id[0]);
            Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, 0);
     
            Gl.glColor3f(1.0f, 1.0f, 0.0f);
            Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            Gl.glDrawArrays(Gl.GL_TRIANGLES, 0, buffer.Length / 3);
            Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
     
            control.Draw();
        }
    }
     

  2. #2
    Avatar von Konstantin Gross
    Konstantin Gross Konstantin Gross ist offline Mitglied Platin
    Registriert seit
    Sep 2003
    Ort
    nähe Kassel (Hessen)
    Beiträge
    703
    Hallo, schau mal im Post 3 hat jemand ein funktionierendes Beispiel gepostet, das fast wie deins aussieht

    http://www.zfx.info/DisplayThread.php?TID=24033
     
    Internetseite:
    http://www.texturenland.de

    Blog:
    http://blog.texturenland.de

    Codesnippets:
    .NET-Snippets

    - Sollte ich bei einer Frage weitergeholfen haben, würde ich mich über eine positive Bewertung freuen -

Ähnliche Themen

  1. Vertex selection problem
    Von mOnis im Forum Autodesk Maya (ehemals Alias)
    Antworten: 3
    Letzter Beitrag: 05.06.10, 10:11
  2. openGL - vertex-shader
    Von Cromon im Forum C/C++
    Antworten: 3
    Letzter Beitrag: 30.09.09, 15:02
  3. Antworten: 0
    Letzter Beitrag: 26.06.07, 21:18
  4. [OpenGl] Buffer-Befehl? ("Zucken/Ruckeln")
    Von baum77 im Forum C/C++
    Antworten: 8
    Letzter Beitrag: 13.05.05, 22:39
  5. Problem mit Bones und Vertex Maps
    Von dastool im Forum Cinema 4D
    Antworten: 4
    Letzter Beitrag: 02.12.04, 17:36