|
[GL] Masked sprite in 16 bits. |
anto80
Member #3,230
February 2003
|
Hello all. I would like to know if it's possible to display a masked sprite in 16 bits with Allegro GL. /* the desktop is 16 bpp */ int nColDepth; GLuint tex_nb; nColDepth = 16; set_color_depth(nColDepth); allegro_gl_set(AGL_COLOR_DEPTH, nColDepth); tex_nb = allegro_gl_make_texture_ex(nFlags, bmpTex, internal_format); /* I have tried with internal_format=GL_RGBA8 and =GL_RGB8 */ - With a 16 bit desktop, and with nColDepth=16, it crashes if nFlags contains the bit AGL_TEXTURE_HAS_ALPHA or AGL_TEXTURE_MASKED. Here are the last words of Allegro.log : * Note * make_texture_ex: Preselected texture format: 0x1907, type: 0x8363 * Note * munge_bitmap: Need to perform depth conversion from 16 to 16 bpp. * Note * munge_bitmap: Flipping bitmap. * Note * munge_bitmap: Copying bitmap. * Note * munge_bitmap: Inserting alpha channel.
If i don't put any of these 2 bit-flags, it works, but obviously without alpha channel and without mask color (draw the rectangle entirely). - With a 32 bit desktop, and with nColDepth=32, all works fine, regardless of the nFlags value. You may wonder why 16 bpp, although 32 bpp works perfectly... The answer is that i want to test some other possibilities, to see how many FPS are saved this way, and if it does worth it... Thank you in advance for your help. ___________ |
Bob
Free Market Evangelist
September 2000
|
If your bitmap does not actually contain an alpha channel (which is the case for 16-bit), you probably want to use the AGL_TEXTURE_MASKED flag. AGL_TEXTURE_HAS_ALPHA is only used on 32-bit bitmaps where the alpha channel contains actual alpha values (insetad of 0, which is what Allegro typically loads there). However, the log you've pasted does not match what the code should be doing for AGL_TEXTURE_MASKED. Is this correct? -- |
anto80
Member #3,230
February 2003
|
Quote: If your bitmap does not actually contain an alpha channel (which is the case for 16-bit), you probably want to use the AGL_TEXTURE_MASKED flag. AGL_TEXTURE_HAS_ALPHA is only used on 32-bit bitmaps where the alpha channel contains actual alpha values (insetad of 0, which is what Allegro typically loads there).
I agree with you totally. I am using 16 bit bitmaps in this case, with the mask-color equals to RGB(255,0,255), and the AGL_TEXTURE_MASKED flag. Quote: However, the log you've pasted does not match what the code should be doing for AGL_TEXTURE_MASKED. Is this correct?
The log file correspond to what is described just above. Even the line "* Note * munge_bitmap: Inserting alpha channel." ___________ |
Bob
Free Market Evangelist
September 2000
|
This line can't be right: * Note * munge_bitmap: Need to perform depth conversion from 16 to 16 bpp. The code in AGL is:
As you can see, a depth of 16 should force AGL to upconvert the bitmap to 32 bits. That's not happening according to your log file. -- |
anto80
Member #3,230
February 2003
|
I can assure you i didn't altered the code nor the log file. I'll post my actual code in a few minutes so you will see. ___________ |
Bob
Free Market Evangelist
September 2000
|
In that case, please attach the source to a small program to demonstrate the problem. Also please attach the full allegro.log file. Thanks. -- |
anto80
Member #3,230
February 2003
|
Main example :
The allegro.log:
Hmm..... now that i posted it, it seems there's something to do with the line "Acceleration: Yes RGBA: 5.6.5.0 Accum: 16.16.16.16". That is to say, i think i have to change this bit arrangement [5-6-5-0] to something else with the 'A' value>0. ___________ |
Bob
Free Market Evangelist
September 2000
|
Your code does not compile. $ gcc temp.c -o temp.exe -mwindows -W -Wall -Wno-unused -O2 -ffast-math -fomit- frame-pointer -mtune=i686 -mno-cygwin -lagl -lalleg -luser32 -lgdi32 -lglu32 - lopengl32 -L/lib/mingw -lmoldname -lmsvcrt temp.c: In function `_mangled_main': temp.c:22: warning: `text_mode' is deprecated (declared at /usr/local/include/al legro/alcompat.h:153) temp.c:28: error: `nDisplayFlags' undeclared (first use in this function) temp.c:28: error: (Each undeclared identifier is reported only once temp.c:28: error: for each function it appears in.) temp.c:28: error: `DISPFLG_WINDOWED' undeclared (first use in this function) temp.c:43: error: `WINDOW_W' undeclared (first use in this function) temp.c:43: error: `WINDOW_H' undeclared (first use in this function) temp.c:54: warning: `textprintf' is deprecated (declared at /usr/local/include/a llegro/alcompat.h:175) Also, can you attach the image file you are using? Thanks. -- |
anto80
Member #3,230
February 2003
|
Sorry i had some defines in my MSVC project settings... My fault, sorry. I have updated the code. Should be correct now. Quote: Also, can you attach the image file you are using? As i said in my 2nd post, the bitmap is created internally. the code is here: BITMAP* bmp1 = create_bitmap(32, 32); clear_to_color(bmp1, makecol(255,0,255)); textprintf(bmp1, font, 0,0, makecol(0,0,255), "ab"); /* blue */
___________ |
Bob
Free Market Evangelist
September 2000
|
It works for me.
What version of AllegroGL do you have? -- |
anto80
Member #3,230
February 2003
|
AllegroGL : Latest (0.2.5CVS) OpenGL: latest drivers for my video card (updated last week). OpenGL Version: 1.3.0 - Build 4.14.10.4342 Vendor: Intel Renderer: Intel 845G
___________ |
Bob
Free Market Evangelist
September 2000
|
Quote: AllegroGL : Latest (0.2.5CVS) 0.4.0-RC4 is the latest. That said, this code in particular has not changed since. The only thing I can recommend at this point is to step through the agl_make_texture_ex() call and try and find out why it thinks it needs to do a 16->16 conversion instead of 16->32. -- |
Milan Mimica
Member #3,877
September 2003
|
Just be sure, try create_bitmap_ex(32, 32, 16) instead of create_bitmap.
-- |
anto80
Member #3,230
February 2003
|
You were right. create_bitmap_ex(32, w, h) prevents from crashing. The bitmap Thanks. ___________ |
Milan Mimica
Member #3,877
September 2003
|
I meant create_bitmap_ex(16, w, h), sorry. The create_bitmap_ex(32, w, h) prevents crashing because It creates a 32-bit bitmap and that's not what you want.
-- |
|