Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Texture mapping with allegro and opengl

This thread is locked; no one can reply to it. rss feed Print
Texture mapping with allegro and opengl
miguel meza
Member #5,447
January 2005

Hi,
i have mi method for loading a bmp,
and this is the code:

void CImageLoader::LoadBMP( char* strImageName, UINT textureArray[], int textureID )
{
  BITMAP* pImageBuffer1;
  pImageBuffer1 = load_bmp( strImageName, NULL);
        glGenTextures(1, &textureArray[textureID]);
        glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);
        
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImageBuffer1->w, pImageBuffer1->h, GL_RGBA, GL_UNSIGNED_BYTE, pImageBuffer1->dat);   // here is the problem

         destroy_bitmap( pImageBuffer1 );  
}

I did that code in my other computer, and it worked perfectly (amd64), and now, i have to program in my laptop (dell xps, intel core 2 duo), but it doesnt works in my lap!!

the problem is when i use the gluBuild2Mipmaps.....

this is the error the debugger throws:
First-chance exception at 0x68b27372 in avance1.exe: 0xC0000005: Access violation reading location 0x02ab3000.
Unhandled exception at 0x68b27372 in avance1.exe: 0xC0000005: Access violation reading location 0x02ab3000.

how is it possible that in both computers compile, but in one runs, and in the other doesnt......

thanks for any possible help

Kitty Cat
Member #2,815
October 2002
avatar

I notice you're not testing if load_bmp fails. You should probably also use load_bitmap instead of the format-specific load_bmp.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

gnolam
Member #2,030
March 2002
avatar

Anything wrong with GLuint allegro_gl_make_texture_ex (int flags, BITMAP *bmp, GLint internal_format);?

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

HoHo
Member #4,534
April 2004
avatar

As gnolam said you should use allegro_gl_make_texture_ex. IIRC, .dat pointer contains more than just raw pixel data, it had line pointers in it too and that is probably what breaks things.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

miguel meza
Member #5,447
January 2005

Hi,
Kitty Cat: i checked if the texture was loaded, and it was (i also try with load_bitmap), if i comment:
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImageBuffer1->w, pImageBuffer1->h, GL_RGBA, GL_UNSIGNED_BYTE, pImageBuffer1->dat);
it doesnt send me and error, but obviously it doesnt maps the texture to the primitive..

Gnolam: how do i use the GLuint allegro_gl_make_texture_ex (int flags, BITMAP* bmp, GLint internal_format)

i read the docs, but i'm not sure what should i send in the "GLint internal_format" parameter. can you give me a little example how would it be the complete method?

HoHo: then why did it worked perfectly in my other computer? i only recompiled it in my lap with the same compiler (vs2005) the code is EXACTLY the same ???

HoHo
Member #4,534
April 2004
avatar

Quote:

then why did it worked perfectly in my other computer?

Probably because I was wrong :P

Note to self:
next time make sure you know what you are talking about. There is a separate lines[] pointer in BITMAP structure that does what I said :P

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

vbovio
Member #8,283
January 2007

unless you want to make your own function, look for:

allegro_gl_make_texture
allegro_gl_make_masked_texture

---------------
BovioSoft

miguel meza
Member #5,447
January 2005

well, i can do this....
BITMAP* bmp1 = load_bmp( "Bitmap.bmp" , NULL);
allegro_gl_make_texture(bmp1);

but then... what should i do so the texture mapps with the primitive?
and how do i use the GLuint allegro_gl_make_texture_ex (int flags, BITMAP* bmp, GLint internal_format)

vbovio
Member #8,283
January 2007

look around for "textured quads", and spend some time studying opengl.
I think one of the examples of allegrogl draws a textured quad..

---------------
BovioSoft

Go to: