# Path: cuwo/vector.py
# def ivec3(x=0, y=0, z=0):
# def vec3(x=0, y=0, z=0):
# def qvec3(x=0, y=0, z=0):


import sys
import sdl2
import sdl2.ext
import threading
import math
import os
                import traceback
from cuwo import tgen
from cuwo.vector import Vector3, Quaternion
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.constants import GLfloat_4
from OpenGL.GL import shaders
from OpenGL.GL.ARB.vertex_buffer_object import *
from queue import PriorityQueue, Full
from ctypes import *
QUAD_SIZE = VERTEX_SIZE * 4


class ChunkData(object):
    data = None
    vbo = None

    def __init__(self, data):
        self.data = data

    def create_vbo(self):
        data, size = self.data.get_data_pointer()
        self.vertex_count = size * 4
        size *= QUAD_SIZE
        self.vbo = glGenBuffersARB(1)
        p = c_void_p(data)
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.vbo)
        glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, p, GL_STATIC_DRAW)
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)
        self.data = None

    @staticmethod
    def begin():
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glEnableClientState(GL_COLOR_ARRAY)

    @staticmethod
    def end():
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)

# Path: cuwo/vector.py
# def ivec3(x=0, y=0, z=0):
# def vec3(x=0, y=0, z=0):
# def qvec3(x=0, y=0, z=0):


# Path: tools/mapviewer.py
import sys
import sdl2
import sdl2.ext
import threading
import math
import os
                import traceback
from cuwo import tgen
from cuwo.vector import Vector3, Quaternion
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.constants import GLfloat_4
from OpenGL.GL import shaders
from OpenGL.GL.ARB.vertex_buffer_object import *
from queue import PriorityQueue, Full
from ctypes import *

QUAD_SIZE = VERTEX_SIZE * 4


class ChunkData(object):
    data = None
    vbo = None

    def __init__(self, data):
        self.data = data

    def create_vbo(self):
        data, size = self.data.get_data_pointer()
        self.vertex_count = size * 4
        size *= QUAD_SIZE
        self.vbo = glGenBuffersARB(1)
        p = c_void_p(data)
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.vbo)
        glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, p, GL_STATIC_DRAW)
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)
        self.data = None

    @staticmethod
    def begin():
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glEnableClientState(GL_COLOR_ARRAY)

    @staticmethod
    def end():
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)

        glDisableClientState(GL_VERTEX_ARRAY)