<s> import ctypes , time <EOL> import numpy as np <EOL> from PIL import Image <EOL> from pi3d . constants import * <EOL> from pi3d . Texture import Texture <EOL> class OffScreenTexture ( Texture ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name ) : <EOL> """<STR_LIT>""" <EOL> super ( OffScreenTexture , self ) . __init__ ( name ) <EOL> from pi3d . Display import Display <EOL> self . ix , self . iy = Display . INSTANCE . width , Display . INSTANCE . height <EOL> self . im = Image . new ( "<STR_LIT>" , ( self . ix , self . iy ) ) <EOL> self . im = self . im . convert ( "<STR_LIT>" ) <EOL> self . image = np . array ( self . im ) <EOL> self . blend = False <EOL> self . mipmap = False <EOL> self . _tex = ctypes . c_int ( ) <EOL> self . framebuffer = ( ctypes . c_int * <NUM_LIT:1> ) ( ) <EOL> opengles . glGenFramebuffers ( <NUM_LIT:1> , self . framebuffer ) <EOL> self . depthbuffer = ( ctypes . c_int * <NUM_LIT:1> ) ( ) <EOL> opengles . glGenRenderbuffers ( <NUM_LIT:1> , self . depthbuffer ) <EOL> def _load_disk ( self ) : <EOL> """<STR_LIT>""" <EOL> def _start ( self , clear = True ) : <EOL> """<STR_LIT>""" <EOL> opengles . glBindFramebuffer ( GL_FRAMEBUFFER , self . framebuffer [ <NUM_LIT:0> ] ) <EOL> opengles . glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , <EOL> GL_TEXTURE_2D , self . _tex . value , <NUM_LIT:0> ) <EOL> opengles . glBindRenderbuffer ( GL_RENDERBUFFER , self . depthbuffer [ <NUM_LIT:0> ] ) <EOL> opengles . glRenderbufferStorage ( GL_RENDERBUFFER , GL_DEPTH_COMPONENT16 , <EOL> self . ix , self . iy ) <EOL> opengles . glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_DEPTH_ATTACHMENT , <EOL> GL_RENDERBUFFER , self . depthbuffer [ <NUM_LIT:0> ] ) <EOL> if clear : <EOL> opengles . glClear ( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ) <EOL> def _end ( self ) : <EOL> """<STR_LIT>""" <EOL> opengles . glBindTexture ( GL_TEXTURE_2D , <NUM_LIT:0> ) <EOL> opengles . glBindFramebuffer ( GL_FRAMEBUFFER , <NUM_LIT:0> ) <EOL> def delete_buffers ( self ) : <EOL> opengles . glDeleteFramebuffers ( <NUM_LIT:1> , self . framebuffer ) <EOL> opengles . glDeleteRenderbuffers ( <NUM_LIT:1> , self . depthbuffer ) </s>
