(0,0) at top left mode for 2D graphics

102 views
Skip to first unread message

anatoly techtonik

unread,
Dec 7, 2012, 9:03:57 AM12/7/12
to pyglet...@googlegroups.com
I've noticed that pyglet uses bottom left corner as (0,0) origin. This creates problems with code ported from pygame, processing and other applications from 2D graphics world where things are traditionally drawn from top to bottom.

Is it possible to define a pyglet mode, where Y axes starts from the top?

Anonymouse

unread,
Dec 7, 2012, 11:09:39 AM12/7/12
to pyglet...@googlegroups.com
It is possible to make your own on_resize function that uses the top-right corner as the origin - it's simply a matter of OpenGL projection matrix.

You'll want something like this...
@window.event
def on_resize(width, height):
  glViewport(0, 0, width, height)
  glMatrixMode(GL_PROJECTION)
  glLoadIdentity()
  glOrtho(0, width, height, 0, 0.1, 1000)

Not tested but I think it should be right.


On 7 December 2012 15:03, anatoly techtonik <tech...@gmail.com> wrote:
I've noticed that pyglet uses bottom left corner as (0,0) origin. This creates problems with code ported from pygame, processing and other applications from 2D graphics world where things are traditionally drawn from top to bottom.

Is it possible to define a pyglet mode, where Y axes starts from the top?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pyglet-users/-/Z3dg_5_mx6AJ.
To post to this group, send email to pyglet...@googlegroups.com.
To unsubscribe from this group, send email to pyglet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.

Reply all
Reply to author
Forward
0 new messages