On 8/22/08, Alex Holkner <[EMAIL PROTECTED]> wrote:
> On 8/22/08, Martin Glueck <[EMAIL PROTECTED]> wrote:
>  > Hi,
>  >
>  > I idea is to implement a scrolling text using the IncrementalTextLayout.
>  >
>  > In some cases, I need this scrolled text 90 degrees rotated.
>  >
>  > Therefore I have apply a rotate and a transformation before I call the draw
>  > method of the text layout.
>  >
>  > The problem seems to be that one a rotation is in effect the result is not
>  > is I would have expected it.
>  > Especially the meaning of the width and heiht properties of the
>  > IncrementalTextLayout is really strange.
>
>
> This is due to IncrementalTextLayout (actually ScrollableTextLayout,
>  its superclass) using a glScissor to clip the text to the dimensions
>  given by width/height.  The scissor is not transformed by the
>  modelview matrix, which is why you're getting incorrect clipping.
>
>  I'm afraid I don't have an easy solution for you; a general solution
>  would require the scissor to be replaced with clipping planes. You
>  could override ScrollableTextLayoutGroup.set_state and make this
>  change yourself if you need to.

Here's a patch that does this, it should fix your problem.  I'm not
sure whether or not to add this into pyglet 1.1-maintenance.

Index: pyglet/text/layout.py
===================================================================
--- pyglet/text/layout.py       (revision 2200)
+++ pyglet/text/layout.py       (working copy)
@@ -543,15 +543,26 @@
     translate_y = 0 # y - view_y

     def set_state(self):
-        glPushAttrib(GL_ENABLE_BIT | GL_SCISSOR_BIT | GL_CURRENT_BIT)
+        glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_CURRENT_BIT)
         glEnable(GL_BLEND)
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-        # Disable scissor to check culling.
-        glEnable(GL_SCISSOR_TEST)
-        glScissor(self._scissor_x - 1,
-                  self._scissor_y - self._scissor_height,
-                  self._scissor_width + 1,
-                  self._scissor_height)
+        # Disable clipping planes to check culling.
+        glEnable(GL_CLIP_PLANE0)
+        glEnable(GL_CLIP_PLANE1)
+        glEnable(GL_CLIP_PLANE2)
+        glEnable(GL_CLIP_PLANE3)
+        # Left
+        glClipPlane(GL_CLIP_PLANE0, (GLdouble * 4)(
+                    1, 0, 0, -(self._scissor_x - 1)))
+        # Top
+        glClipPlane(GL_CLIP_PLANE1, (GLdouble * 4)(
+                    0, 1, 0, -(self._scissor_y - self._scissor_height)))
+        # Right
+        glClipPlane(GL_CLIP_PLANE2, (GLdouble * 4)(
+                    -1, 0, 0, self._scissor_x + self._scissor_width + 1))
+        # Bottom
+        glClipPlane(GL_CLIP_PLANE3, (GLdouble * 4)(
+                    0, -1, 0, self._scissor_y + self._scissor_height))
         glTranslatef(self.translate_x, self.translate_y, 0)

     def unset_state(self):

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