Python pyglet.gl.GL_TEXTURE_MAG_FILTER Examples
The following are 5
code examples of pyglet.gl.GL_TEXTURE_MAG_FILTER().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyglet.gl
, or try the search function
.
Example #1
Source File: texture.py From pywonderland with MIT License | 7 votes |
def create_image_texture(imgfile): """Create a 2D texture from an image file. """ image = pyglet.image.load(imgfile) data = image.get_data("RGBA", image.width * 4) tex = gl.GLuint() gl.glGenTextures(1, ct.pointer(tex)) gl.glBindTexture(gl.GL_TEXTURE_2D, tex) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE) gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, image.width, image.height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, data) gl.glBindTexture(tex, 0) return tex
Example #2
Source File: texture.py From pywonderland with MIT License | 5 votes |
def create_cubemap_texture(imgfiles): """Create a cubemap texture from image files. """ if len(imgfiles) != 6: raise ValueError("exactly six images are required for a cubemap texture") # generate a new texture cubemap = gl.GLuint() gl.glGenTextures(1, ct.pointer(cubemap)) # bind it to `GL_TEXTURE_CUBE_MAP` and set the filter and wrap mode gl.glBindTexture(gl.GL_TEXTURE_CUBE_MAP, cubemap) gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR_MIPMAP_LINEAR) gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE) gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE) gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_WRAP_R, gl.GL_CLAMP_TO_EDGE) faces = [Image.open(img) for img in imgfiles] # set the faces of the cubemap texture for i, face in enumerate(faces): width, height = face.size try: data = face.tobytes("raw", "RGBX", 0, -1) except TypeError: data = face.tobytes("raw", "RGBA", 0, -1) gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, gl.GL_RGBA, width, height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, data) gl.glGenerateMipmap(gl.GL_TEXTURE_CUBE_MAP) gl.glBindTexture(gl.GL_TEXTURE_CUBE_MAP, 0) return cubemap
Example #3
Source File: test.py From REALCompetitionStartingKit with MIT License | 5 votes |
def imshow(self, arr): H, W, C = arr.shape assert C==3 image = pyglet.image.ImageData(W, H, 'RGB', arr.tobytes(), pitch=W*-3) self.clear() self.switch_to() self.dispatch_events() texture = image.get_texture() gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) texture.width = W texture.height = H texture.blit(0, 0, width=self.win_w, height=self.win_h) self.flip()
Example #4
Source File: test_multitexture.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _bind_texture(self, i): gl.glActiveTexture((gl.GL_TEXTURE0, gl.GL_TEXTURE1, gl.GL_TEXTURE2)[i]) gl.glEnable(gl.GL_TEXTURE_2D) gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture[i].id) gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_COMBINE) gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_ALPHA, gl.GL_REPLACE if i == 0 else gl.GL_ADD) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
Example #5
Source File: framebuffer.py From pineal with GNU Affero General Public License v3.0 | 5 votes |
def buffer_texture(width, height): id_ = gl.GLuint() gl.glGenTextures(1, byref(id_)) gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_TEXTURE_BIT) gl.glActiveTexture(gl.GL_TEXTURE0) gl.glEnable(gl.GL_TEXTURE_2D) gl.glBindTexture(gl.GL_TEXTURE_2D, id_) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexImage2D( gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, width, height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, (gl.GLubyte * (width*height * 4))(), ) gl.glFlush() gl.glBindTexture(gl.GL_TEXTURE_2D, 0) gl.glPopAttrib() return id_