Re: [AD] OpenGL and upside down |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2008-03-18, Peter Hull <peterhull90@xxxxxxxxxx> wrote:
> On Tue, Mar 18, 2008 at 2:43 AM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
> > Correct me if I'm wrong, but OpenGL shouldn't be aware of any "negative
> > pitch" at all. It's just any Allegro and user code which locks a
> > rectangle needs to keep in mind that ptr += rect.pitch might actually
> > decrement ptr.
> That's what I was thinking; Allegro would set itself to suit OpenGL,
> rather than the other way around.
I was curious so had a quick test :-) The examples mainly work except for text
rendering.
Peter
--- src/opengl/ogl_bitmap.c (revision 11437)
+++ src/opengl/ogl_bitmap.c (local)
@@ -290,7 +290,7 @@ static ALLEGRO_LOCKED_REGION *ogl_lock_r
}
glPixelStorei(GL_PACK_ROW_LENGTH, pack_row_length);
//FIXME: ugh. isn't there a better way?
- upside_down(bitmap, x, y, w, h);
+ if(0) upside_down(bitmap, x, y, w, h);
}
else {
//FIXME: use glPixelStore or similar to only synchronize the required
@@ -305,9 +305,9 @@ static ALLEGRO_LOCKED_REGION *ogl_lock_r
}
}
- locked_region->data = bitmap->memory + pitch * y + pixel_size * x;
+ locked_region->data = bitmap->memory + pitch * (y + h - 1) + pixel_size * x;
locked_region->format = bitmap->format;
- locked_region->pitch = pitch;
+ locked_region->pitch = -pitch;
return locked_region;
}
@@ -328,7 +328,7 @@ static void ogl_unlock_region(ALLEGRO_BI
if (ogl_bitmap->is_backbuffer) {
GLint unpack_row_length;
//FIXME: ugh. isn't there a better way?
- upside_down(bitmap, bitmap->lock_x, bitmap->lock_y, bitmap->lock_w, bitmap->lock_h);
+ if(0) upside_down(bitmap, bitmap->lock_x, bitmap->lock_y, bitmap->lock_w, bitmap->lock_h);
/* glWindowPos2i may not be available. */
if (al_opengl_version() >= 1.4) {