Jump to content

  • Log In with Google      Sign In   
  • Create Account


Recommendation: pyglet library for Python


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
24 replies to this topic

#21 Knarkles   Members   -  Reputation: 271

Like
0Likes
Like

Posted 01 February 2008 - 09:36 PM

Quote:
Original post by eedok
finally got around to checking this out, but lack of joystick support kind of killed it for me, which is too bad as I'm still looking for a cross-platform game library that supports joysticks and rumble among other needs.


Joystick support is apparently in the works: http://entitycrisis.blogspot.com/2008/02/pyglet-joystick.html

Sponsor:

#22 blackviper91   Members   -  Reputation: 182

Like
0Likes
Like

Posted 04 February 2008 - 11:57 AM

Thanks for posting that. I was about to start learning PyGame tonight, but if Pyglet is as good as it sounds, I'll learn that instead.

I also wish more people would use Python for game dev. It seems like the saved time would be a huge benefit for hobbyist programmers especially.

~Cody

#23 Knarkles   Members   -  Reputation: 271

Like
0Likes
Like

Posted 19 February 2008 - 10:05 PM

FYI: I started making a Pyglet-based 2D game from scratch on Monday: http://www.brainfold.org/blog/. So far, I've liked it very much, and can't think of anything seriously wrong with it. Even the documentation is far better than Pygame's. The only "problem" is the lack of joystick support, but as I already said in an earlier reply, that's apparently in the works. I think Pygame deserves to get dethroned. [smile]

#24 NineYearCycle   Members   -  Reputation: 931

Like
0Likes
Like

Posted 23 February 2008 - 04:58 AM

Kylotan when we were chatting a while back I got the impression that you'd got the Opengl FBO working using pyglet, would you mind sharing?

#25 Kylotan   Moderators   -  Reputation: 3338

Like
0Likes
Like

Posted 24 February 2008 - 01:28 AM

Err, it's a mess, because my OpenGL skills are weak.

# these are your window dimensions
width = 800
height = 600

# Setting it up
framebuffer = c_uint(0)
depthbuffer = c_uint(0)
img = c_uint(0)

if not gl_info.have_extension("GL_EXT_framebuffer_object"):
return False
print "Verifying Framebuffer Support: %i" % gl_info.have_extension("GL_EXT_framebuffer_object")
if not gl_info.have_extension("GL_ARB_draw_buffers"):
return False
print "Verifying ARB buffer drawing Support: %i" % gl_info.have_extension("GL_ARB_draw_buffers")

# Set up rendering state for the offscreen buffer
glClearColor(0.0, 0.0, 0.2, 0.5)
glClearDepth(1.0)
glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)

# "Setting Up"
glGenFramebuffersEXT(1, byref(framebuffer))
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer)

# "Adding a Depth Buffer"
glGenRenderbuffersEXT(1, byref(depthbuffer))
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer)
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height)
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer)

# "Adding a Texture To Render To"
glGenTextures(1, byref(img))
glBindTexture(GL_TEXTURE_2D, img)

# only works with these two lines!!!!!!!!!!!! (nearest works, as well as linear)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, None)
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 0)
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
print status
if status == GL_FRAMEBUFFER_COMPLETE_EXT:
print "complete, yay!"

...

# Using it
# First we bind the FBO so we can render to it
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer)

# Save the view port and set it to the size of the texture
glPushAttrib(GL_VIEWPORT_BIT)
glViewport(0,0,width,height)

# your rendering goes here...

# Restore old view port and set rendering back to default frame buffer
glPopAttrib()
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)

...

# "Cleaning Up"
glDeleteFramebuffersEXT(1, byref(framebuffer))
glDeleteRenderbuffersEXT(1, byref(depthbuffer))
glDeleteTextures(1,byref(img))


Most of it is just copy and pasted from NeHe I think. There are some byref() calls too but it's usually obvious where they go. You can even leave the semi-colons in if you like; Python doesn't care.

Now, if someone can show me how to implement a simple post-processing full screen effect, please do. :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS