Re: [AD] two things

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


Peter Wang wrote:
On 2010-08-06, Elias Pschernig <elias.pschernig@xxxxxxxxxx> wrote:
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.

Hmm, isn't it correct, since I specified GL_ALPHA, GL_UNSIGNED_BYTE?
i.e. for each pixel in the texture I'm only providing the alpha value,
each of which is a single byte.

IDK, valgrind says this and i do get artifacts (not in ex_haiku though):

==3694== Invalid read of size 1
==3694==    at 0x4028AA9: ???
==3694==  Address 0x66ade7a is 1 bytes after a block of size 49,761 alloc'd
==3694== at 0x40228C9: calloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==3694==    by 0x80EE26D: al_calloc_with_context (memory.c:83)
==3694==    by 0x814376C: ogl_upload_bitmap (ogl_bitmap.c:564)
==3694==    by 0x80C1C2A: al_create_bitmap (bitmap.c:124)
==3694==    by 0x80C2E32: al_clone_bitmap (bitmap.c:667)
==3694==    by 0x81468F9: al_grab_font_from_bitmap (fontbmp.c:232)
==3694==    by 0x81466A0: _al_load_bitmap_font (fontbmp.c:159)
==3694==    by 0x8146252: al_load_font (font.c:350)



--
Milan Mimica
http://sparklet.sf.net




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