Difficult-Rocket/libs/pyglet/graphics/vertexarray.py
shenjack d84b490b99
with more logger
Add | more formatter and some more

Fix | type mis match

sync pyglet

Enhance | logger with Template

add lib-not-dr as requirement

sync pyglet

sync pyglet

Add | add lto=yes to nuitka_build

just incase

sync pyglet

sync lib_not_dr

Remove | external requirement lib-not-dr

some logger

sync lib-not-dr

sync pyglet

sync lib-not-dr

sync lib-not-dr

sync pyglet

sync pyglet

Fix | console thread been block

Update DR rs and DR sdk

sync lib not dr

sync lib-not-dr

sync lib-not-dr

sync pyglet and lib-not-dr

sync pyglet 0.1.8

sync lib not dr

logger almost done?

almost!

sync pyglet (clicpboard support!)

sync lib not dr

sync lib not dr

color code and sync pyglet

do not show memory and progress building localy

sync pyglet

synclibs
2023-11-20 20:12:59 +08:00

48 lines
1.1 KiB
Python

import pyglet
from pyglet.gl import GLuint, glGenVertexArrays, glDeleteVertexArrays, glBindVertexArray
__all__ = ['VertexArray']
class VertexArray:
"""OpenGL Vertex Array Object"""
def __init__(self):
"""Create an instance of a Vertex Array object."""
self._context = pyglet.gl.current_context
self._id = GLuint()
glGenVertexArrays(1, self._id)
@property
def id(self):
return self._id.value
def bind(self):
glBindVertexArray(self._id)
@staticmethod
def unbind():
glBindVertexArray(0)
def delete(self):
glDeleteVertexArrays(1, self._id)
self._id = None
__enter__ = bind
def __exit__(self, *_):
glBindVertexArray(0)
def __del__(self):
if self._id is not None:
try:
self._context.delete_vao(self.id)
self._id = None
except (ImportError, AttributeError):
pass # Interpreter is shutting down
def __repr__(self):
return "{}(id={})".format(self.__class__.__name__, self._id.value)