Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » AllegroGL and BITMAP

This thread is locked; no one can reply to it. rss feed Print
AllegroGL and BITMAP
mscava
Member #6,815
January 2006
avatar

I'm playing a bit with AllegroGL. And I'm confused with one thing...

BITMAP* bmp = create_video_bitmap( 64, 64 );
GLuint texture = allegro_gl_make_texture( bmp );

What exactly get's done by allegro_gl_make_texture? Can I call destroy_bitmap( bmp ) now, because texture was sent to GPU? Do I even need to call create_video_bitmap? What would changed if I called create_bitmap?

vbovio
Member #8,283
January 2007

allegro_gl_make_texture will create a texture from your bitmap, it does some checking though, try looking at the source to see it (..\alleggl-0.4.0\src\texture.c), but basically does that. I'm almost sure it is safe to destry your bitmap afterwards, and yes, you can use create_bitmap.

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

Archon
Member #4,195
January 2004
avatar

Quote:

What would changed if I called create_bitmap?

I thought that using create_bitmap was the norm? Theres no real point (AFAIK) on using video bitmaps just to make an OpenGL texture.

Quote:

Can I call destroy_bitmap( bmp ) now, because texture was sent to GPU?

Yes - it is not needed anymore.

Mr. Big
Member #6,196
September 2005

As mentioned above, using video bitmaps is pointless in your case, and the bitmaps are safe to delete after they're sent to the graphics card...

mscava
Member #6,815
January 2006
avatar

Thanks. I've found it out in the source that BITMAP must be memory. Well and I'm trying to create some kind of Bitmap class where I'd merge AllegroGL and Allegro... The only problem is that the memory for Bitmap will be allocated twice, becuase when I want to edit the texture I'll have to draw onto Allegro's one and create GL texture again... But at least I'm not confused now.. Thanks

Milan Mimica
Member #3,877
September 2003
avatar

When the display driver is GFX_OPENGL, create_video_bitmap() creates a BITMAP* built upon a OpenGL texture. Drawing such a BITMAP* to the 'screen' BITMAP* will be extremely fast (well, in theory). The only thing is that this wrapper thing is still unfinished and only blit(), masked_blit(), draw_sprite() and draw_trans_sprite() are available.
No point merging AllegroGL and Allegro since AllegroGL does it already, or at least it tries.

mscava
Member #6,815
January 2006
avatar

Quote:

When the display driver is GFX_OPENGL, create_video_bitmap() creates a BITMAP* built upon a OpenGL texture. Drawing such a BITMAP* to the 'screen' BITMAP* will be extremely fast (well, in theory). The only thing is that this wrapper thing is still unfinished and only blit(), masked_blit(), draw_sprite() and draw_trans_sprite() are available.
No point merging AllegroGL and Allegro since AllegroGL does it already, or at least it tries.

Nice to know... I'll try to look on it a bit!

Milan Mimica
Member #3,877
September 2003
avatar

src/videovtb.c and src/glvtable.c

Get it from the SVN because there were some changes.

Go to: