Python pyglet.gl.glEnable() Examples
The following are 19
code examples of pyglet.gl.glEnable().
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: render.py From RLSchool with Apache License 2.0 | 6 votes |
def _gl_enable_color_material(): gl.glColorMaterial(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT_AND_DIFFUSE) gl.glEnable(gl.GL_COLOR_MATERIAL) gl.glShadeModel(gl.GL_SMOOTH) gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, rendering.vector_to_gl( 0.192250, 0.192250, 0.192250)) gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, rendering.vector_to_gl( 0.507540, 0.507540, 0.507540)) gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, rendering.vector_to_gl( .5082730, .5082730, .5082730)) gl.glMaterialf(gl.GL_FRONT, gl.GL_SHININESS, .4 * 128.0)
Example #2
Source File: renderer.py From pineal with GNU Affero General Public License v3.0 | 6 votes |
def rendering_window(draw, h, w): window = pyglet.window.Window(width=w, height=h, visible=False) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) # gl.glEnable(gl.GL_LINE_SMOOTH) # gl.glEnable(gl.GL_POLYGON_SMOOTH) # gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST) # gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST) @window.event def on_draw(): pyglet.clock.tick() window.clear() gl.glLoadIdentity() draw() pyglet.clock.set_fps_limit(30) pyglet.clock.schedule_interval(lambda dt: None, 1.0/30)
Example #3
Source File: test_image.py From pyglet with BSD 3-Clause "New" or "Revised" License | 6 votes |
def draw_triangle_left(self): if self.show_triangle_left: w = 200 h = 200 x = self.window.width // 4 - w // 2 y = (self.window.height - h) // 2 gl.glEnable(gl.GL_DEPTH_TEST) gl.glBegin(gl.GL_TRIANGLES) gl.glColor4f(1, 0, 0, 1) gl.glVertex3f(x, y, -1) gl.glColor4f(0, 1, 0, 1) gl.glVertex3f(x+w, y, 0) gl.glColor4f(0, 0, 1, 1) gl.glVertex3f(x, y+h, 1) gl.glEnd() gl.glDisable(gl.GL_DEPTH_TEST) gl.glColor4f(1, 1, 1, 1)
Example #4
Source File: test_multitexture.py From pyglet with BSD 3-Clause "New" or "Revised" License | 6 votes |
def render(self): # Enable blending gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) # Enable transparency gl.glEnable(gl.GL_ALPHA_TEST) gl.glAlphaFunc(gl.GL_GREATER, .1) # Load textures self.texture = pyglet.image.TextureGrid( pyglet.image.ImageGrid( pyglet.image.load( self.test_data.get_file('images', 'multitexture.png')), 1, 4)) self.background = pyglet.image.load( self.test_data.get_file('images', 'grey_background.png')).get_texture() # Create vertex list showing the multi texture self.vertex_list = pyglet.graphics.vertex_list(4, ('v2f', (32, 332, 64, 332, 64, 364, 32, 364)), ('0t3f', self.texture[1].tex_coords), ('1t3f', self.texture[2].tex_coords), ('2t3f', self.texture[3].tex_coords))
Example #5
Source File: gs_running.py From pycraft with MIT License | 5 votes |
def set_3d(self, size): """Configure OpenGL to draw in 3d.""" width, height = size GL.glEnable(GL.GL_DEPTH_TEST) GL.glViewport(0, 0, width, height) GL.glMatrixMode(GL.GL_PROJECTION) GL.glLoadIdentity() GL.gluPerspective(65.0, width / float(height), 0.1, 60.0) GL.glMatrixMode(GL.GL_MODELVIEW) GL.glLoadIdentity() x, y = self.player.rotation GL.glRotatef(x, 0, 1, 0) GL.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x))) x, y, z = self.player.position GL.glTranslatef(-x, -y, -z)
Example #6
Source File: draw.py From Pyno with MIT License | 5 votes |
def selector(init, corner): '''Selection tool representation''' quad_data = pyglet.graphics.vertex_list_indexed( 4, [0, 1, 2, 2, 3, 0], ('v2i', (init[0], init[1], corner[0], init[1], corner[0], corner[1], init[0], corner[1])), ('c4B', (120, 200, 255, 50) * 4)) # glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) quad_data.draw(gl.GL_TRIANGLES) gl.glDisable(gl.GL_BLEND)
Example #7
Source File: draw.py From Pyno with MIT License | 5 votes |
def quad_aligned(x, y, w, h, color): quad_data = pyglet.graphics.vertex_list_indexed( 4, [0, 1, 2, 2, 3, 0], ('v2i', (x, y, x + w, y, x + w, y + h, x, y + h)), ('c4B', color * 4)) gl.glEnable(gl.GL_BLEND) quad_data.draw(pyglet.gl.GL_TRIANGLES) gl.glDisable(gl.GL_BLEND)
Example #8
Source File: draw.py From Pyno with MIT License | 5 votes |
def set_state(self): # Toggle smooth lines gl.glEnable(gl.GL_POLYGON_SMOOTH) gl.glEnable(gl.GL_BLEND)
Example #9
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_
Example #10
Source File: test_image.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def enable_alpha(self): gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
Example #11
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 #12
Source File: simulator.py From VerifAI with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_draw(self): self.window.clear() gl.glMatrixMode(gl.GL_PROJECTION) gl.glPushMatrix() gl.glLoadIdentity() self.camera() gl.glEnable(self.background.target) gl.glEnable(gl.GL_BLEND) gl.glBindTexture(self.background.target, self.background.id) W = 10000. graphics.draw(4, gl.GL_QUADS, ('v2f', (-W, -W, W, -W, W, W, -W, W)), ('t2f', (0., 0., W * 5., 0., W * 5., W * 5., 0., W * 5.)) ) gl.glDisable(self.background.target) for lane in self.world.lanes: self.draw_lane_surface(lane) self.draw_lane_lines(lane) for obj in self.world.objects: self.draw_object(obj) for car in self.world.cars: self.draw_car(car.trajectory[-1], car.color) gl.glPopMatrix() self.label.text = self.task_name self.label.draw() self.iter +=1 if self.iter%10 == 0: print('Iterations: ', self.iter) if self.iter == self.max_iters: self.event_loop.exit()
Example #13
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def draw(self, x, y): gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_CURRENT_BIT) gl.glColor4f(1, 1, 1, 1) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.texture.blit(x - self.hot_x, y - self.hot_y, 0) gl.glPopAttrib()
Example #14
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def draw(self, x, y): gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_CURRENT_BIT) gl.glColor4f(1, 1, 1, 1) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.texture.blit(x - self.hot_x, y - self.hot_y, 0) gl.glPopAttrib()
Example #15
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def draw(self, x, y): gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_CURRENT_BIT) gl.glColor4f(1, 1, 1, 1) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.texture.blit(x - self.hot_x, y - self.hot_y, 0) gl.glPopAttrib()
Example #16
Source File: render.py From RLSchool with Apache License 2.0 | 5 votes |
def _gl_enable_smooth_lines(): # make the lines from Path3D objects less ugly gl.glEnable(gl.GL_LINE_SMOOTH) gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST) # set the width of lines to 4 pixels gl.glLineWidth(4) # set PointCloud markers to 4 pixels in size gl.glPointSize(4)
Example #17
Source File: render.py From RLSchool with Apache License 2.0 | 5 votes |
def _gl_enable_blending(): # enable blending for transparency gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
Example #18
Source File: render.py From RLSchool with Apache License 2.0 | 5 votes |
def _setup_3d(self): w, h = self.get_size() gl.glEnable(gl.GL_DEPTH_TEST) gl.glDepthFunc(gl.GL_LEQUAL) gl.glEnable(gl.GL_DEPTH_TEST) gl.glEnable(gl.GL_CULL_FACE) viewport = self.get_viewport_size() gl.glViewport(0, 0, max(1, viewport[0]), max(1, viewport[1])) gl.glMatrixMode(gl.GL_PROJECTION) gl.glLoadIdentity() gl.gluPerspective(*self.perspective) gl.glMatrixMode(gl.GL_MODELVIEW) gl.glLoadIdentity() y, x = self.rotation gl.glRotatef(x, 0, 1, 0) gl.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x))) # NOTE: for GL render, its x-z plane is the ground plane, # so we unpack the position using `(x, z, y)` instead of `(x, y, z)` x, z, y = self.position if not self.debug_mode: y += self.perspective_over_drone[0] z += self.perspective_over_drone[1] gl.glTranslatef(-x, -y, -z)
Example #19
Source File: render.py From RLSchool with Apache License 2.0 | 4 votes |
def show_drone(self, position, rotation): """ Show the drone 3D model with corresponding translation and rotation. """ # Get the transform matrix for drone 3D model x, z, y = position transform = np.eye(4) transform[:3, 3] = [x, y, z] # NOTE: change the view size of drone 3D model transform[0, 0] = 2.5 transform[1, 1] = 2.5 transform[2, 2] = 2.5 # Match drone model space x-y-z to openGL x-z-y # TODO: read the config.json and match the propeller positions model_space_transform = rotation_transform_mat(-np.pi / 2, 'roll') transform = np.dot(transform, model_space_transform) yaw, pitch, roll = rotation if self.debug_mode: # NOTE: manually set values to debug rotation, # it's useful when input act is in form [c, c, c, c]. yaw = np.pi / 2 # pitch = np.pi / 2 # roll = np.pi / 2 transform = np.dot(transform, rotation_transform_mat(yaw, 'yaw')) transform = np.dot(transform, rotation_transform_mat(pitch, 'pitch')) transform = np.dot(transform, rotation_transform_mat(roll, 'roll')) # Add a new matrix to the model stack to transform the model gl.glPushMatrix() gl.glMultMatrixf(rendering.matrix_to_gl(transform)) # Enable the target texture if self.drone_texture is not None: gl.glEnable(self.drone_texture.target) gl.glBindTexture(self.drone_texture.target, self.drone_texture.id) # Draw the mesh with its transform applied self.drone_drawer.draw(mode=self.drone_vertex_list_mode) gl.glPopMatrix() # Disable texture after using if self.drone_texture is not None: gl.glDisable(self.drone_texture.target)