本文整理汇总了Python中pyglet.gl.glMatrixMode函数的典型用法代码示例。如果您正苦于以下问题:Python glMatrixMode函数的具体用法?Python glMatrixMode怎么用?Python glMatrixMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glMatrixMode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: set_viewport
def set_viewport(left, right, bottom, top):
"""
This sets what coordinates appear on the window.
Note: It is recommended to only set the viewport to integer values that
line up with the pixels on the screen. Otherwise if making a tiled game
the blocks may not line up well, creating rectangle artifacts.
>>> import arcade
>>> arcade.open_window("Drawing Example", 800, 600)
>>> set_viewport(-1, 1, -1, 1)
>>> arcade.quick_run(0.25)
"""
global _left
global _right
global _bottom
global _top
_left = left
_right = right
_bottom = bottom
_top = top
# GL.glViewport(0, 0, _window.height, _window.height)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glOrtho(_left, _right, _bottom, _top, -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
开发者ID:mwreuter,项目名称:arcade,代码行数:30,代码来源:window_commands.py
示例2: world_projection
def world_projection(self, aspect):
"""
Sets OpenGL projection and modelview matrices such that the window
is centered on self.(x,y), shows at least scale world units in every
direction, and is oriented by angle.
"""
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
if aspect < 1:
gluOrtho2D(
-self.scale,
+self.scale,
-self.scale / aspect,
+self.scale / aspect)
else:
gluOrtho2D(
-self.scale * aspect,
+self.scale * aspect,
-self.scale,
+self.scale)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
gluLookAt(
self.x, self.y, +1.0,
self.x, self.y, -1.0,
sin(self.angle), cos(self.angle), 0.0)
开发者ID:tartley,项目名称:sole-scion,代码行数:27,代码来源:camera.py
示例3: on_resize
def on_resize(self, width, height):
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.gluPerspective(60., width / float(height), .01, 1000.)
gl.glMatrixMode(gl.GL_MODELVIEW)
self.view['ball'].place([width/2, height/2], (width+height)/2)
开发者ID:embr,项目名称:trimesh,代码行数:7,代码来源:viewer.py
示例4: on_draw
def on_draw():
pyglet.clock.tick()
window.clear()
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
(w, h) = window.get_size()
gl.glScalef(
float(min(w, h))/w,
-float(min(w, h))/h,
1
)
gl.gluPerspective(45.0, 1, 0.1, 1000.0)
gl.gluLookAt(0, 0, 2.4,
0, 0, 0,
0, 1, 0)
for vision in window.visions.values():
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
vision()
buf = pyglet.image.get_buffer_manager().get_color_buffer()
rawimage = buf.get_image_data()
window.texture = rawimage.get_texture()
开发者ID:mattiabressan,项目名称:pineal,代码行数:26,代码来源:windows.py
示例5: _reset_projection
def _reset_projection(self):
if self.fullcanvas:
if self._pygimage is None:
return
width, height = self._pygimage.width, self._pygimage.height
else:
size = self.GetClientSize()
width, height = size.width, size.height
b = 0
t = height
if self.flip_lr:
l = width
r = 0
else:
l = 0
r = width
if self.rotate_180:
l,r=r,l
b,t=t,b
if width==0 or height==0:
# prevent OpenGL error
return
self.wxcontext.SetCurrent()
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(l,r,b,t, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:BackupTheBerlios,项目名称:ctrax-svn,代码行数:32,代码来源:wxglvideo.py
示例6: _layerProjectLocalToScreenUndo
def _layerProjectLocalToScreenUndo(self):
"""Undoes the _layerProjectLocalToScreen() operation."""
if self._scissorBox is None and self.localBounds is None:
return
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPopMatrix()
gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:wwoods,项目名称:pyglet_piss,代码行数:7,代码来源:layer.py
示例7: hud_mode
def hud_mode(self):
"Set matrices ready for drawing HUD, like fps counter"
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(0, self.win_width, 0, self.win_height)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:camera.py
示例8: on_resize
def on_resize(self, width, height):
"""Calculate the new viewport preserving aspect ratio"""
aspect = float(WIDTH)/HEIGHT
self.viewport_width = int(min(width, height*aspect))
self.viewport_height = int(min(height, width/aspect))
self.viewport_x_offs = (width-self.viewport_width) // 2
self.viewport_y_offs = (height-self.viewport_height) // 2
x = (width-WIDTH) / 2
gl.glViewport(self.viewport_x_offs,
self.viewport_y_offs,
self.viewport_width,
self.viewport_height,
)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, self.viewport_width, 0, self.viewport_height, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
logging.debug("Viewport: %s, %s, %s, %s" % (self.viewport_x_offs,
self.viewport_y_offs,
self.viewport_width,
self.viewport_height,
))
# adjust elements depending on the new viewport
self.label.x = self.viewport_width // 2
self.label.y = self.viewport_height // 2
开发者ID:reidrac,项目名称:pyglet-template,代码行数:31,代码来源:__init__.py
示例9: handle_resize
def handle_resize(w, h):
gl.glViewport(0, 0, w, h)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, w, h, 0, 0, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
开发者ID:moshev,项目名称:project-viking,代码行数:7,代码来源:project_viking.py
示例10: SetOrigin
def SetOrigin(self):
size = self.GetVirtualSize()
self.SetScrollbar(wx.HORIZONTAL, self.GetScrollPos(wx.HORIZONTAL), size[0],
self.map.width * 32 * self.zoom, refresh=True)
self.SetScrollbar(wx.VERTICAL, self.GetScrollPos(wx.VERTICAL), size[1],
self.map.height * 32 * self.zoom, refresh=True)
size = self.GetGLExtents()
if size.width <= 0:
size.width = 1
if size.height <= 0:
size.height = 1
self.tilemap.updateDimmingSprite(
int(size.width) + 2, int(size.height) + 2, 1 / self.zoom)
gl.glViewport(0, 0, size.width, size.height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(
0, size.width / self.zoom, 0, size.height / self.zoom, -1, 1)
x = (-self.GetScrollPos(wx.HORIZONTAL)) / self.zoom
y = ((-(self.map.height * 32) + size.height / self.zoom) +
self.GetScrollPos(wx.VERTICAL) / self.zoom)
gl.glTranslatef(x, y, 0)
self.translateX = -x + size.width / 2 / self.zoom
self.translateY = -y + size.height / 2 / self.zoom
self.onscreenwidth = int(size.width / self.zoom)
self.onscreenheight = int(size.height / self.zoom)
self.tilemap.setDimXY(self.translateX - 1, self.translateY + 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:borisblizzard,项目名称:arcreator,代码行数:28,代码来源:tilemap_panel.py
示例11: on_resize
def on_resize(width, height):
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(-width/2, width/2, -height/2, height/2, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
return EVENT_HANDLED
开发者ID:adam-urbanczyk,项目名称:chemshapes,代码行数:7,代码来源:demo.py
示例12: _resize
def _resize(self, width, height):
aspect = float(self._width)/self._height
self._viewport_width = int(min(width, height*aspect))
self._viewport_height = int(min(height, width/aspect))
self._viewport_x_offs = (width-self._viewport_width) // 2
self._viewport_y_offs = (height-self._viewport_height) // 2
x = (width-self._width) / 2
gl.glViewport(self._viewport_x_offs,
self._viewport_y_offs,
self._viewport_width,
self._viewport_height,
)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, self._viewport_width, 0, self._viewport_height, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
logging.debug("Viewport: %s, %s, %s, %s" % (self._viewport_x_offs,
self._viewport_y_offs,
self._viewport_width,
self._viewport_height,
))
开发者ID:PermianLizard,项目名称:Pyweek-17,代码行数:25,代码来源:director.py
示例13: get_vlist
def get_vlist(geom, batch=None, group=None, data=None):
"""Get a "new" C{pyglet.graphics.VertexList} for this
geometry. If a batch is given, vertex list will be added to the batch
"""
# projection with one world coordinate unit equal to one screen pixel
# glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (0, windowWidth, 0, windowHeight);
window = pyglet.window.get_platform().get_default_display().get_windows()[0]
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.gluOrtho2D(0,
window.width,
0,
window.height)
_data = [('v3f', geom.vertex_data)]
if hasattr(geom, 'normal_data'):
_data.append(('n3f', geom.normal_data))
if hasattr(geom, 'texcoord_data'):
_data.append(('t2f', geom.texcoord_data))
if data:
_data.extend(data)
count = len(geom.vertex_data) // geom.vertex_pitch
indexed = hasattr(geom, 'indices')
if batch:
if indexed:
return batch.add_indexed( count,
geom.drawing_mode, group, geom.indices, *_data)
return batch.add( count,
geom.drawing_mode, group, *_data)
if indexed:
return pyglet.graphics.vertex_list_indexed( count, geom.indices, *_data )
return pyglet.graphics.vertex_list( count, *_data)
开发者ID:Knio,项目名称:miru,代码行数:31,代码来源:geom.py
示例14: on_draw
def on_draw(self):
self.clear()
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
(w, h) = self.get_size()
gl.glScalef(
float(min(w, h))/w,
-float(min(w, h))/h,
1
)
gl.gluPerspective(45.0, 1, 0.1, 1000.0)
gl.gluLookAt(0, 0, 2.4,
0, 0, 0,
0, 1, 0)
global render_texture
render_texture = self.texture
for v in self.visions.values():
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
v.iteration()
buf = pyglet.image.get_buffer_manager().get_color_buffer()
rawimage = buf.get_image_data()
self.texture = rawimage.get_texture()
clock.tick()
开发者ID:ff-,项目名称:pineal,代码行数:30,代码来源:windows.py
示例15: on_resize
def on_resize(self, width, height):
'''
calculate perspective matrix
'''
v_ar = width/float(height)
usableWidth = int(min(width, height*v_ar))
usableHeight = int(min(height, width/v_ar))
ox = (width - usableWidth) // 2
oy = (height - usableHeight) // 2
glViewport(ox, oy, usableWidth, usableHeight)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(60, usableWidth/float(usableHeight), 0.1, 3000.0)
''' set camera position on modelview matrix
'''
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
gluLookAt(width/2.0, height/2.0, height/1.1566,
width/2.0, height/2.0, 0,
0.0, 1.0, 0.0)
''' update scene controller with size
'''
self.controller.resize(width, height)
#clears to a grey.
glClearColor(0.4,0.4,0.4,0.)
return pyglet.event.EVENT_HANDLED
开发者ID:chrisbiggar,项目名称:sidescrolltesting,代码行数:26,代码来源:leveleditor.py
示例16: on_resize
def on_resize(self, width, height):
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0, width, 0, height, -1000, 1000)
glMatrixMode(GL_MODELVIEW)
return pyglet.event.EVENT_HANDLED
开发者ID:AojiaoZero,项目名称:thbattle,代码行数:7,代码来源:baseclasses.py
示例17: _layerProjectLocalToScreen
def _layerProjectLocalToScreen(self):
"""Maps self.coordLocal to self.coordScreen within OpenGL."""
if self._scissorBox is None and self.localBounds is None:
return
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPushMatrix()
gl.glLoadIdentity()
# gluOrtho2D declares the render space for the corners of the window.
# So, we want to set it up in such a way that our layer renders in
# the right place. In other words, determine window corners that
# map cl -> cs. All clipping, etc is already handled by the coordsLocal
# getter.
cs = self.coordsScreen
cl = self.coordsLocal
sw = self.scene.width
sh = self.scene.height
# Determine the window width and height. We want a local-sized chunk
# of this to correspond to a screen-sized chunk of the screen. That is,
# cl[2] / ww == cs[2] / sw
ww = cl[2] * sw / cs[2]
wh = cl[3] * sh / cs[3]
# cs[0] / sw = (x - nx) / ww
nx = cl[0] - cs[0] * ww / sw
ny = cl[1] - cs[1] * wh / sh
gl.gluOrtho2D(nx, nx+ww, ny, ny+wh)
gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:wwoods,项目名称:pyglet_piss,代码行数:28,代码来源:layer.py
示例18: select_object
def select_object(x, y, objects=None):
from miru.context import context
if objects is None:
objects = context.camera.objects
# following technique is adapted from
# http://www.cse.msu.edu/~cse872/tutorial9.html
w = context.window.width
h = context.window.height
select_buffer = ctypes.cast((100 * gl.GLuint)(), ctypes.POINTER(gl.GLuint))
gl.glSelectBuffer(100, select_buffer)
viewport = (4 * gl.GLint)()
gl.glGetIntegerv(gl.GL_VIEWPORT, viewport)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
# rotate the camera first
angle = context.camera.angle
gl.glRotatef(angle.z, 0, 0, 1)
gl.glRotatef(angle.y, 0, 1, 0)
gl.glRotatef(angle.x, 1, 0, 0)
gl.gluPickMatrix(x, y, 3, 3, viewport)
gl.glRenderMode(gl.GL_SELECT)
gl.gluPerspective(45., w / float(h), 0.1, 1000.)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glInitNames()
gl.glPushName(-1)
context.camera.render(select_pass=1, visible=objects)
gl.glFlush()
hits = gl.glRenderMode(gl.GL_RENDER)
gl.glPopName()
selected = None
if hits:
try:
m = sys.maxint << 100
idx = 0
for i in range(0, 100, 4):
if not select_buffer[i]:
selected = objects[idx]
break
m = min(select_buffer[i+1], m)
if m == select_buffer[i+1]:
idx = select_buffer[i+3]
except IndexError:
pass
context.window.on_resize(context.window.width, context.window.height)
return selected
开发者ID:Knio,项目名称:miru,代码行数:60,代码来源:utils.py
示例19: on_draw
def on_draw():
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
# draw_obj(bear, bear_tex)
draw_obj(ball, ball_tex)
开发者ID:ChunyangSun,项目名称:VisionAndPhysicsEngine,代码行数:7,代码来源:demo3.py
示例20: gl_setup
def gl_setup(): # general GL setup
glMatrixMode(GL_PROJECTION)
glMatrixMode(GL_MODELVIEW)
gluOrtho2D(0, WIDTH, 0, HEIGHT) # dont understand, check this # TODO
glLoadIdentity()
glTranslatef(CENTX, CENTY, 0)
glClear(GL_COLOR_BUFFER_BIT)
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:field.py
注:本文中的pyglet.gl.glMatrixMode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论