# Path: PyOpenGLng/HighLevelApi/PrimitiveVertexArray.py
# class TriangleVertexArray(GlVertexArrayObject):
# 
#     """ Base class to draw primitives as triangles. """
# 
#     # Fixme: 3d
# 
#     ##############################################
# 
#     def __init__(self, items=None):
# 
#         super(TriangleVertexArray, self).__init__()
# 
#         self._number_of_items = 0
#         self._positions_buffer = GlArrayBuffer()
#         self._normals_buffer = GlArrayBuffer()
#         self._colours_buffer = GlArrayBuffer()
# 
#         if items is not None:
#             self.set(*items)
# 
#     ##############################################
# 
#     def set(self, positions, normals, colours):
# 
#         """ Set the vertex array from an iterable of triangles. """
# 
#         self._number_of_items = positions.shape[0]
# 
#         # Fixme:
#         #  - set from high level primitive: slow
#         #  - set from Numpy array: fast but check for mistake
# 
#         # vertex = np.zeros((self._number_of_objects, 3), dtype='f') # dtype=np.float
# 
#         self._positions_buffer.set(positions)
#         self._normals_buffer.set(normals)
#         self._colours_buffer.set(colours)
# 
#     ##############################################
# 
#     def bind_to_shader(self, shader_program_interface):
# 
#         """ Bind the vertex array to the shader program interface attribute.
#         """
# 
#         # Fixme: we cannot reuse the vbo
# 
#         self.bind()
#         shader_program_interface.position.bind_to_buffer(self._positions_buffer)
#         shader_program_interface.normal.bind_to_buffer(self._normals_buffer)
#         shader_program_interface.colour.bind_to_buffer(self._colours_buffer)
#         self.unbind()
# 
#     ##############################################
# 
#     def draw(self):
# 
#         """ Draw the vertex array as lines. """
# 
#         self.bind()
#         GL.glDrawArrays(GL.GL_TRIANGLES, 0, 3*self._number_of_items)
#         self.unbind()


import math
import numpy as np
from .PrimitiveVertexArray import TriangleVertexArray

    # Fixme: scale!

    positions, normals = unit_cube()

    colour2 = (1, 0, 0, 1)
    colour4 = (1, 0, 0, 1)
    colour8 = (1, 0, 0, 1)
    colour6 = (1, 0, 0, 1)

    colour1 = (0, 1, 0, 1)
    colour3 = (0, 1, 0, 1)
    colour7 = (0, 1, 0, 1)
    colour5 = (0, 1, 0, 1)

    colours = np.array([
        colour1, colour2, colour4,  # left
        colour1, colour4, colour3,  # left
        colour5, colour8, colour6,  # right
        colour8, colour5, colour7,  # right
        colour6, colour1, colour5,  # bottom
        colour6, colour2, colour1,  # bottom
        colour8, colour3, colour4,  # top
        colour8, colour7, colour3,  # top
        colour7, colour1, colour3,  # far
        colour7, colour5, colour1,  # far
        colour4, colour2, colour6,  # near
        colour8, colour4, colour6], # near
                         dtype=np.float32)


# Path: PyOpenGLng/HighLevelApi/PrimitiveVertexArray.py
# class TriangleVertexArray(GlVertexArrayObject):
# 
#     """ Base class to draw primitives as triangles. """
# 
#     # Fixme: 3d
# 
#     ##############################################
# 
#     def __init__(self, items=None):
# 
#         super(TriangleVertexArray, self).__init__()
# 
#         self._number_of_items = 0
#         self._positions_buffer = GlArrayBuffer()
#         self._normals_buffer = GlArrayBuffer()
#         self._colours_buffer = GlArrayBuffer()
# 
#         if items is not None:
#             self.set(*items)
# 
#     ##############################################
# 
#     def set(self, positions, normals, colours):
# 
#         """ Set the vertex array from an iterable of triangles. """
# 
#         self._number_of_items = positions.shape[0]
# 
#         # Fixme:
#         #  - set from high level primitive: slow
#         #  - set from Numpy array: fast but check for mistake
# 
#         # vertex = np.zeros((self._number_of_objects, 3), dtype='f') # dtype=np.float
# 
#         self._positions_buffer.set(positions)
#         self._normals_buffer.set(normals)
#         self._colours_buffer.set(colours)
# 
#     ##############################################
# 
#     def bind_to_shader(self, shader_program_interface):
# 
#         """ Bind the vertex array to the shader program interface attribute.
#         """
# 
#         # Fixme: we cannot reuse the vbo
# 
#         self.bind()
#         shader_program_interface.position.bind_to_buffer(self._positions_buffer)
#         shader_program_interface.normal.bind_to_buffer(self._normals_buffer)
#         shader_program_interface.colour.bind_to_buffer(self._colours_buffer)
#         self.unbind()
# 
#     ##############################################
# 
#     def draw(self):
# 
#         """ Draw the vertex array as lines. """
# 
#         self.bind()
#         GL.glDrawArrays(GL.GL_TRIANGLES, 0, 3*self._number_of_items)
#         self.unbind()


# Path: PyOpenGLng/HighLevelApi/Solids.py
import math
import numpy as np
from .PrimitiveVertexArray import TriangleVertexArray


    # Fixme: scale!

    positions, normals = unit_cube()

    colour2 = (1, 0, 0, 1)
    colour4 = (1, 0, 0, 1)
    colour8 = (1, 0, 0, 1)
    colour6 = (1, 0, 0, 1)

    colour1 = (0, 1, 0, 1)
    colour3 = (0, 1, 0, 1)
    colour7 = (0, 1, 0, 1)
    colour5 = (0, 1, 0, 1)

    colours = np.array([
        colour1, colour2, colour4,  # left
        colour1, colour4, colour3,  # left
        colour5, colour8, colour6,  # right
        colour8, colour5, colour7,  # right
        colour6, colour1, colour5,  # bottom
        colour6, colour2, colour1,  # bottom
        colour8, colour3, colour4,  # top
        colour8, colour7, colour3,  # top
        colour7, colour1, colour3,  # far
        colour7, colour5, colour1,  # far
        colour4, colour2, colour6,  # near
        colour8, colour4, colour6], # near
                         dtype=np.float32)


    return TriangleVertexArray((positions, normals, colours))