Re: [AD] two things

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, 2010-08-05 at 20:43 +0200, Milan Mimica wrote:
> Hi!
> 
> I have found two problems in SVN version. Normally I would just commit a patch, 
> but we're aiming for a stable release soon and I haven't been carefully 
> following discussions lately so I'll ask first.
> 
> 
> 1.
> Isn't al_create_sub_bitmap() supposed to clip w and h parameters to parent's 
> width/height? I know there have been some changes regarding that.
> 

No, it doesn't clip at all. If a user calls

sub = al_create_sub_bitmap(parent, -50, -50, 150, 150)

then draws something to 75/75 inside of the sub-bitmap, it will now
correctly appear at 25/25 relative to the parent.

> 
> 
> 2.
> Index: src/opengl/ogl_bitmap.c
> ===================================================================
> --- src/opengl/ogl_bitmap.c     (revision 13538)
> +++ src/opengl/ogl_bitmap.c     (working copy)
> @@ -561,7 +561,7 @@
>          * However if we do that, without NPOT textures, we get some junk at the
>          * edges of our bitmaps when we draw them.
>          */
> -      unsigned char *buf = al_calloc(ogl_bitmap->true_h, ogl_bitmap->true_w);
> +      unsigned char *buf = al_calloc(4, ogl_bitmap->true_h * ogl_bitmap->true_w);
>         glTexImage2D(GL_TEXTURE_2D, 0, glformats[bitmap->format][0],
>            ogl_bitmap->true_w, ogl_bitmap->true_h, 0,
>            GL_ALPHA, GL_UNSIGNED_BYTE, buf);
> 
> I have hardcoded a "4" there but you get the picture. Valgrind told me about this.
> 

I wonder if we can completely get rid of the calloc. Basically, what
this does it create a buffer filled with zeroes, then calls the
(extremely slow) glTexImage2D with it. But the texture is never used
since as next step you will usually lock it and initialize with bitmap
data.

I think we should just set a flag that it has no texture at all yet.
Then later when it is first locked simply clear the lock buffer but
don't try to retrieve texture data from OpenGL.

An exception would be if you set the bitmap as target. In that case, if
the flag is set that it has no content yet, we'd have to do an initial
clear.

-- 
Elias Pschernig <elias.pschernig@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/