Thanks for the replies! To answer Brian, we have a game server with an established protocol, whose "game space" involves a tiled map with the origin in the upper-left corner. Also, objects are 2d image sprites, and by default they draw from the upper-left down (although passing in an origin offset to the Image fed to pyglet's Sprite could solve that part of the problem). The ideal scenario is to have my pyglet sprites (animated and non-animated, we use sprite sheet animations) to "just work," in the same coordinate system as the server, and to have the transformation into OpenGL space happen just before rendering. This way I could, for example, make a mouse hover show a watch window with the x & y coordinates of that sprite, in game- space, with minimal effort. I apologize for posting such a vague question; if sample code or a screenshot would be better let me know. Thanks again!
James, your glOrtho() call and manual y-offset per object is approximately the road I'm going down right now, and I was hopin to avoid rolling my own Sprite, Label, and all the other classes to insert the y-offset. On Jun 6, 10:50 am, jamesr <[EMAIL PROTECTED]> wrote: > oh, sorry - my projection is > > glViewport(0, 0, window.width, window.height) > glMatrixMode(GL_PROJECTION) > glLoadIdentity() > > glOrtho(0, window.width, 0, window.height, -1, 1) > glMatrixMode(GL_MODELVIEW) > > (oh hello community! first post :) > > - James > > On Jun 6, 2008, at 1:48 PM, jamesr wrote: > > > I had this problem too, and I solved it this way: > > > (presuming that X is an object that has x, y, w, h) > > > x, y, w, h = X.x, screenHeight-X.y, X.w, -X.h > > > and then this code to draw those GL objects: > > > glRasterPos2d(x, y) > > glColor4f(br, bg, bb, a) > > glBegin(GL_QUADS) > > glVertex2f(x, y) > > glVertex2f(x+w, y) > > glVertex2f(x+w, y+h) > > glVertex2f(x, y+h) > > glEnd() > > > then for all images i used (where X is again an object with x y w h, > > this time for a picture) > > > img.blit(x, 0-(X.height-y)) > > > This works (mostly) for me! Comments? Better ways? let me know.. > > > On Jun 5, 2008, at 8:16 PM, sunetos wrote: > > >> Hey, I'm new to pyglet, and it seems great so far. One thing that > >> keeps biting me is that the data I need to work with, needs the > >> origin > >> at the top-left corner of the screen. Simply setting glOrtho() and > >> glViewport() before the render isn't sufficient, because then I just > >> get a render that's reflected vertically. Right now it's looking > >> like > >> I'll have to subclass just about every class in pyglet to account for > >> a negative Y offset to get what I need. Is there a better way? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
