On Wed, Feb 20, 2008 at 5:45 PM, Alex Holkner <[EMAIL PROTECTED]> wrote:
>
>
> On 2/21/08, Drew Smathers <[EMAIL PROTECTED]> wrote:
> >
> >
> > On Wed, Feb 20, 2008 at 9:58 AM, Txema Vicente <[EMAIL PROTECTED]> wrote:
> > >
> > > I tried with textures, but did not know how to create textures for non
> > power
> > > of 2 sizes.
>
> See Texture.create_for_size and Texture.get_region.
>
>
> >
> > My suggestion is: Don't.  There are plenty of creative ways to use strictly
> > power-of-2 sized images - and this is the most portable solution.  Pyglet
> > internally resizes images for textures
>
> pyglet allocates the next largest valid texture size and copies the
> image data into that larger texture.  Images are not stretched
> (TileableTexture is an exception).
>

Yes, my use of the term resize was little too liberal (maybe analogous
to "canvas" resizing in gimp/photoshop vs. image resizing?).  The
effect I observed were some missing "black holes" in the mapped
texture (the unfilled portions of the larger texture, I presume).  If
you have any suggestions on how to gracefully handle this in a pyglet
application, I would be very interested and appreciative.  Otherwise,
I will continue to force myself to only use power-of-2 images when
creating objects in blender.

My code is basically:

 vs = []
 for (vidxs, tidxs, nidxs) in zip(self.vertex_indices,
     self.texcoord_indices, self.normal_indices):
     for (idx, tidx, nidx) in zip (vidxs, tidxs, nidxs):
        t, n, v = texcoords[tidx], normals[nidx], vertices[idx]
        vs.extend(t + n + v)
 array = (GLfloat * len(vs))(*vs)
 triangles = len(vs) / 8

 glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT)

 # apply the texture ...
 glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT)
 glCullFace(GL_BACK)
 glEnable(self.texture.target)
 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, glvec(*self.ambient))
 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, glvec(*self.diffuse))
 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, self.shininess)
 glBindTexture(self.texture.target, self.texture.id)

 glInterleavedArrays(GL_T2F_N3F_V3F, 0, array)
 glDrawArrays(GL_TRIANGLES, 0, triangles)
 glPopAttrib()
 glPopClientAttrib()


Thanks,
-- 
\\\\\/\"/\\\\\\\\\\\
\\\\/ // //\/\\\\\\\
\\\/ \\// /\ \/\\\\
\\/ /\/ / /\/ /\ \\\
\/ / /\/ /\ /\\\ \\
/ /\\\ /\\\ \\\\\/\
\/\\\\\/\\\\\/\\\\\\
 d.p.s

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to