<commit_before>package org.macrogl.examples

import org.lwjgl.opengl._
import org.lwjgl.BufferUtils
import org.macrogl._

object SingleTriangle {
  def main(args: Array[String]) {
    Display.setDisplayMode(new DisplayMode(800, 600))
    Display.create()

    val vertices = Array(
      -0.5f,  0.5f, 0.0f,  1, 0, 0,  0, 0,
       0.0f, -0.5f, 0.0f,  0, 1 ,0,  0, 0,
       0.5f,  0.5f, 0.0f,  0, 0, 1,  0, 0
    )

    val fb = BufferUtils.createFloatBuffer(vertices.length)
    fb.put(vertices)
    fb.flip()

    val mb = new MeshBuffer(GL15.GL_STATIC_DRAW, 3)
    mb.acquire()
    mb.send(0, fb)
    def readResource(path: String) = io.Source.fromURL(getClass.getResource(path)).mkString

    val pp = new Program("test")(
      Program.Shader.Vertex(readResource("/vertex.glsl")),
      Program.Shader.Fragment(readResource("/fragment.glsl"))
    )

    pp.acquire()

    while (!Display.isCloseRequested) {
      for {
        _   <- using.program(pp)
        acc <- using.meshbuffer(mb)
      } {
        GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f)
        raster.clear(GL11.GL_COLOR_BUFFER_BIT)

        acc.render(GL11.GL_TRIANGLES)
      }

      Display.update()
    }

    pp.release()
    mb.release()
    Display.destroy()
  }<commit_msg>Changed MeshBuffer to AttributeBuffer.<commit_after>package org.macrogl.examples

import org.lwjgl.opengl._
import org.lwjgl.BufferUtils
import org.macrogl._

object SingleTriangle {
  def main(args: Array[String]) {
    Display.setDisplayMode(new DisplayMode(800, 600))
    Display.create()

    val vertices = Array(
      -0.5f,  0.5f, 0.0f,  1, 0, 0,
       0.0f, -0.5f, 0.0f,  0, 1, 0,
       0.5f,  0.5f, 0.0f,  0, 0, 1
    )

    val fb = BufferUtils.createFloatBuffer(vertices.length)
    fb.put(vertices)
    fb.flip()

    val mb = new AttributeBuffer(GL15.GL_STATIC_DRAW, 3, 6)
    mb.acquire()
    mb.send(0, fb)
    
    def readResource(path: String) = io.Source.fromURL(getClass.getResource(path)).mkString

    val pp = new Program("test")(
      Program.Shader.Vertex(readResource("/vertex.glsl")),
      Program.Shader.Fragment(readResource("/fragment.glsl"))
    )

    pp.acquire()

    val attr = Array((0, 3), (3, 3))

    while (!Display.isCloseRequested) {
      for {
        _   <- using.program(pp)
        acc <- using.attributebuffer(mb)
      } {
        GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f)
        raster.clear(GL11.GL_COLOR_BUFFER_BIT)

        acc.render(GL11.GL_TRIANGLES, attr)
      }

      Display.update()
    }

    pp.release()
    mb.release()
    Display.destroy()
  }
{'fraction_non_alphanumeric': 0.14447040498442368, 'fraction_numerical': 0.044003115264797506, 'mean_word_length': 2.504774897680764, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6015769', 'n_tokens_mistral': 1061, 'n_tokens_neox': 969, 'n_words': 173}