Rabbyt and texture targets

3 views
Skip to first unread message

penguin

unread,
Dec 28, 2009, 2:51:45 AM12/28/09
to Rabbyt
Hello again! I've got another problem with rabbyt sprites, except it's
not so much of a problem because I've solved it for now, but not to my
satisfaction.

So here's the situation - let's say I'm loading a gigantic sprite with
pyglet.resource.image (not pyglet.resource.texture, which wouldn't
have this problem). That returns a pyglet texture whose target is
GL_TEXTURE_RECTANGLE_ARB or GL_TEXTURE_RECTANGLE_NV. I've been getting
a cryptic 'Invalid operation' from any OpenGL operation performed
after rabbyt.Sprite.render(), and after digging around I realized that
the cSprite's _render() function assumes that it gets a GL_TEXTURE_2D
and binds the texture that way. Now I've gotten a workaround for it

glPushMatrix()
if self.texture.target !=
GL_TEXTURE_2D:
glEnable
(self.texture.target)
glBindTexture(self.texture.target,
self.texture.id)
self.texture_id = 0
else:
self.texture_id =
self.texture.id
glTranslate(0, 0, self.z)
rabbyt.Sprite.render
(self)
glPopMatrix()
if self.texture.target != GL_TEXTURE_2D:
glDisable(self.texture.target)


Which is kind of iffy. But it works, so I'm not gonna complain for
now :)

What I'm after is making it less iffy - this could turn into more of a
pyglet question than a rabbyt one at this stage. What can I do to
ensure that pyglet loads rabbyt-friendly textures? (I've loaded images
with pyglet.resource.image(xxx, False), which shouldn't do anything
new since the default argument for the 'load ARB rectangle extension'
parameter is False, and, uh it didn't do anything new. So much for
superstition). Or would this best be solved at the rabbyt level -
making render() more flexible in terms of its targets? That would be
up to you, of course.

I realize that a quick way to uniffyfy the code is to have a state
flag instead of setting texture_id each render(), and I'll get to it
as soon as I hack together the bookkeeping.

penguin

unread,
Dec 28, 2009, 3:12:20 AM12/28/09
to Rabbyt
Forgot to mention, I'd use pyglet.resource.texture() instead of
pyglet.resource.image() if it were just that... but I'm also using
ImageGrid and Animation to make a Rabbyt sprite have super-easy frame
animations.

Matthew Marshall

unread,
Dec 28, 2009, 11:06:39 PM12/28/09
to Rabbyt
Sounds like the best option is to add support for multiple texture
targets to Rabbyt. I don't have time to work on it at the moment, but
if you want to give it a shot that would be great :-)

MWM

penguin

unread,
Dec 29, 2009, 11:28:59 PM12/29/09
to Rabbyt
I'm busy at the moment too, since I'm hurriedly trying to finish up
this game with what little free time I have. But in a few days I
should be done, and after that I'd definitely love to add multiple
texture support to rabbyt. And even add in support for working with
pyglet Animation objects, if you'd like.

On Dec 28, 11:06 pm, Matthew Marshall <matt...@matthewmarshall.org>
wrote:

Matthew Marshall

unread,
Dec 30, 2009, 10:33:03 PM12/30/09
to Rabbyt
On Dec 29, 10:28 pm, penguin <jaq...@dartmouth.edu> wrote:
> I'm busy at the moment too, since I'm hurriedly trying to finish up
> this game with what little free time I have. But in a few days I
> should be done, and after that I'd definitely love to add multiple
> texture support to rabbyt. And even add in support for working with
> pyglet Animation objects, if you'd like.

No pressure. I'm just saying that if modifying rabbyt is the easiest/
best way to get what you need, go for it :-)

Reply all
Reply to author
Forward
0 new messages