[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2010-07-02, Peter Wang <novalazy@xxxxxxxxxx> wrote:
> On 2010-07-02, Matthew Leverton <meffer@xxxxxxxxxx> wrote:
> > I was about to submit an updated memblit.c that fixes
> > clipping+flipping for memory bitmaps, but after I updated to the
> > latest SVN revision it stopped working.
> >
> > I think r13417 broke / changed something that affects ex_subbitmap.
> > The destination window seems to duplicate the x/y offsets and the
> > stretch blit doesn't work at all. It works fine on r13416.
> >
> > I couldn't reproduce it with simple examples, so maybe it has
> > something to do with multiple displays? (Or maybe I'm just imagining
> > things altogether...)
>
> It's pretty strange. I can only reproduce it intermittently on this
> machine :-P
.. or did I?
The problem appears to be the use of glRasterPos which is affected by
the modelview matrix. Try the attached patch.
There is another suspicious looking use of glRasterPos, to deal
with drawing the backbuffer to itself (ogl_bitmap.c:417).
Do we support that? The code looks pretty dodgy.
Peter
diff --git a/src/opengl/ogl_bitmap.c b/src/opengl/ogl_bitmap.c
index dd74abc..779b40c 100644
--- a/src/opengl/ogl_bitmap.c
+++ b/src/opengl/ogl_bitmap.c
@@ -803,16 +803,21 @@ static void ogl_unlock_region(ALLEGRO_BITMAP *bitmap)
#if !defined ALLEGRO_GP2XWIZ && !defined ALLEGRO_IPHONE
if (ogl_bitmap->is_backbuffer) {
+ bool popmatrix = false;
/* glWindowPos2i may not be available. */
+ /* XXX this is too conservative? */
if (al_get_opengl_version() >= 1.4) {
glWindowPos2i(bitmap->lock_x, gl_y);
}
else {
+ glPushMatrix();
+ glLoadIdentity();
/* The offset is to keep the coordinate within bounds, which was at
* least needed on my machine. --pw
*/
glRasterPos2f(bitmap->lock_x,
bitmap->lock_y + bitmap->lock_h - 1e-4f);
+ popmatrix = true;
}
glDisable(GL_BLEND);
glDrawPixels(bitmap->lock_w, bitmap->lock_h,
@@ -824,6 +829,9 @@ static void ogl_unlock_region(ALLEGRO_BITMAP *bitmap)
ALLEGRO_ERROR("glDrawPixels for format %s failed (%s).\n",
_al_format_name(format), error_string(e));
}
+ if (popmatrix) {
+ glPopMatrix();
+ }
}
else {
glBindTexture(GL_TEXTURE_2D, ogl_bitmap->texture);