|
This thread is locked; no one can reply to it. |
1
2
|
masked_blit(); problem |
Jon Ray
Member #5,340
December 2004
|
I've been trying to get masked_blit to work and having problem as shown in the screenshots. {"name":"591204","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/9\/79cfdd4324691597e95b7cb2e6b14fec.jpg","w":646,"h":512,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/9\/79cfdd4324691597e95b7cb2e6b14fec"} The 1st image is all blit(...); My transparent color is (255, 0, 255). |
kazzmir
Member #1,786
December 2001
|
Uh, I'm not sure whats going on. What color depth are the pictures? What color depth are you setting when you start allegro( set_color_depth )? Are you loading the pictures before you call set_gfx_mode ? |
Jon Ray
Member #5,340
December 2004
|
set_color_depth(32); And I am setting it before I call int ret = set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0); And I load the graphics after this setup. In fact the icons that are loading are the same for those using blut() and those using masked_blit() |
kazzmir
Member #1,786
December 2001
|
Can you attach the original sprites themselves? What version of Allegro are you using? Can you paste the exact code you used when you call blit and masked_blit? |
Jon Ray
Member #5,340
December 2004
|
I've attached the 24bit tank.bmp icon created in MS Paint. As for my blit / masked_blit code..(buffer is my backbuffer which writes to the screen, same buffer that is used for blit(), which works fine.) void drawPlayer() { if(Player.alive) { int x = Player.x; int y = Player.y; if(MASKED) masked_blit(player_bmp, buffer, 0, 0, x, y, PLAYER_SIZE, PLAYER_SIZE); else blit(player_bmp, buffer, 0, 0, x, y, PLAYER_SIZE, PLAYER_SIZE); } } EDIT: I'm using Allegro 4.2 |
Dennis
Member #1,090
July 2003
|
You have (255, 0, 128)rgb on that tank bitmap. Also for masked_blit to work, the source and the target bitmap have to have the same color depth, though if you load the bitmap after setting the gfx mode it should be automatically converted to the set color depth. If it still doesn't work after changing the (not quite)bright pink to (255, 0, 255)rgb, try saving your sprites in 32bpp. --- 0xDB | @dennisbusch_de --- |
Kitty Cat
Member #2,815
October 2002
|
The loaded images have a different color depth than the buffer. Make sure you load/create them all after setting the gfx mode (which you do after setting the color depth). -- |
ImLeftFooted
Member #3,935
October 2003
|
Whys your project called Week 5? |
Jon Ray
Member #5,340
December 2004
|
The only image that didn't have a 255, 0, 255 background was the one I picked to post here. Glad I found that error. I changed the background for the tank image to 255, 0, 255 and still no go. I also have a background that loads when Masking is turned on. It appears something is forcing my color depth to go 256-pal mode from the look of the background. Also to note, each image is loaded from a 24-bit BMP that is not animated. Is it still required to use create the images after loading? If so, how would I create a static image from one that is been loaded and to ensure the 24 - 36 bit colors are retained? I call it Week 5, because I'm making a game a week in class. This project has already been completed and turned in. But, I need to clear up my masking problem for future projects, which will heavily depend upon masked sprites. |
Evert
Member #794
November 2000
|
Post the smallest code sample the duplicates the problem and we'll tell you what's wrong with it. |
Jon Ray
Member #5,340
December 2004
|
Here is my game setup function.
This is how I'm loading the player bitmap player_bmp = load_bitmap("gfx/tank.bmp", NULL); And this is the code that draws the player to the screen void drawPlayer() { if(Player.alive) { int x = Player.x; int y = Player.y; if(MASKED) masked_blit(player_bmp, buffer, 0, 0, x, y, PLAYER_SIZE, PLAYER_SIZE); else blit(player_bmp, buffer, 0, 0, x, y, PLAYER_SIZE, PLAYER_SIZE); } } Keep in mind that the MASKED is a #define that makes it easier to turn masking on/off. |
Evert
Member #794
November 2000
|
That isn't the smallest code sample. |
Kris Asick
Member #1,424
July 2001
|
When you boot up your graphics mode, add a textout or textprintf line to show you the results of a get_color_depth() call. It sounds to me that your computer doesn't like 24-Bit or 32-Bit graphics modes. (Which can sometimes be caused by incorrect video or monitor drivers.) In 8-bit mode, the background colour needs to be palette entry 0, which would be one way to explain why the magic pink isn't disappearing. Also, if it isn't liking 24-Bit or 32-Bit colour, try running the program in a window and you may have better luck. EDIT: Oh wait... you are, aren't you? Maybe you should try full-screen then... EDIT: Waitaminute... I think I recognize this problem. I believe masked_blit() requires that the bitmaps and the screen be the same colour depth... the images look as though you're trying to blit 32-Bit data onto an 8 or 16-bit surface. Is your desktop colour depth set to 8 or 16-Bit? --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Jon Ray
Member #5,340
December 2004
|
I've ensured all graphics I'm using are set to 24bit RGB color mode. The effects on the star background are not there originally as it should be blended better as a 24bit color image. This caused me to think even though I'm setting the color mode its not taking it. I've tested the binary on 2 other computers and all of them come up with the same 2nd image when I use masked_blit(); I'll give you textout idea a try and see what I get. I just added the textout and it comes back as 24 mode, however, still getting the same issue. 24bit mode is also what I'm setting it at. In addition, I noticed from reading around that there may be a problem with using backbuffer with masked_blit. Has anyone else heard of this issue? |
Kris Asick
Member #1,424
July 2001
|
Does draw_sprite() do the same thing as masked_blit() when you use it instead? (The two functions are almost identical in functionality.) --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Thomas Fjellstrom
Member #476
June 2000
|
Nope. draw_sprite doesn't do any magical conversions of the source bitmap. -- |
Jon Ray
Member #5,340
December 2004
|
As an update, I was testing out various things and decided to set it to 8-bit 256-pal mode. I also took the non-animated sprite and converted it to an 8bit image with 0 for the masking. Surprisingly, the masking worked fine, however, the image itself was still distorted. Someone suggested I try to set color to 32bit and use TGA instead of BMP. I'm going to give this a try later tonight. Just wanted to mention the 8bit test in case this clues anyone in to what my problem may be. It really seems like something is force me into 8bit PAL mode, but I have set everything to 24bit / 32bit and pass NULL for the PAL info. |
Evert
Member #794
November 2000
|
How's that small test program coming along that we can run to duplicate the problem? |
Jon Ray
Member #5,340
December 2004
|
Ok Mr. Evert, I've gotten around to making a Test program and got it working, but the masking is not. As you can see, the problem is still there. It should be the tank icon over a green field. Everything is grey. {"name":"591229","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/7\/676c9e9f40766c305cc403d79f7c0f5e.png","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/7\/676c9e9f40766c305cc403d79f7c0f5e"} 591230
|
Kitty Cat
Member #2,815
October 2002
|
Quote:
I said: Make sure you load/create them all after setting the gfx mode
-- |
Evert
Member #794
November 2000
|
There, see? Didn't take long, did it? Quote: Ok Mr. Evert, Watch it. |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: Watch it. Low self esteem, or do you just not like being called Mr.? -- |
kentl
Member #2,905
November 2002
|
Is Mr an insult these days? |
William Labbett
Member #4,486
March 2004
|
#define BLACK makecol(0,0,0)
Is it okay to call allegro functions before allegro_init() ?
|
Thomas Fjellstrom
Member #476
June 2000
|
Functions placed in macros aren't called until the macro is used. Think of the preprocessor as a big search and replace engine. The compiler only sees what happens after the search and replace takes place. So "BLACK" gets translated into makecol(0,0,0) where ever its used, before it hits the compiler, thus, the compiler only sees a bunch of makecol calls. edit, but to answer your question, generally no, things wont work if allegro hasn't been initialized. -- |
|
1
2
|