Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Dissapearing vector

Credits go to CGamesPlay, HoHo, and Kris Asick for helping out!
This thread is locked; no one can reply to it. rss feed Print
Dissapearing vector
InfiniteLoop
Member #8,434
March 2007

Hello All!

I am currently writing a game that uses a double buffering system. It is a tile game and as such, I have tiles of bitmaps with a vector (hline, vline) grid. This works fine and dandy, except when I open my options menu. The options menu is a seperate class that recieves the buffer that I was using for my double buffering system to use as a background. After I pass the buffer (that may or may not be the problem) I can no longer see any of my vector graphics. I have tested this by drawing a big rect and before the options menu it appears, during and after the otpions menu it doesn't. Is there some form of incompatability that I am just not aware of?

Thanks

Kris Asick
Member #1,424
July 2001

I recommend you post the code relating to this problem.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

HoHo
Member #4,534
April 2004
avatar

Without code it is kind of difficult to understand what might be the problem.
Please post the code that deals is revelant to the menu switching.

__________
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

InfiniteLoop
Member #8,434
March 2007

It works until this point:

menu = new CMenu(filename, challenge, buffer);
int ret = menu->loop();
if(ret == OK)
{
cleanUp();

setupGame(menu->getChallenge());
setupBitmap(menu->getFile());
}
delete menu;
menu = NULL;

This is the constructor of my CMenu class:

CMenu::CMenu(string name, int chal, BITMAP *back)
{
background = back;
challenge = chal;
file = name;
state = LOOP;

init();
}

From this point on, no vector graphics will appear.

Kris Asick
Member #1,424
July 2001

Probably something to do with CMenu::Init(), but you should show the code for your bitmap tile class as well.

Or, if you don't mind, you should attach all of your code into a ZIP/RAR file and post that.

You'd be surprised how completely unrelated a problem can be to where it occurs.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

CGamesPlay
Member #2,559
July 2002
avatar

Also, use code tags when you post it.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

InfiniteLoop
Member #8,434
March 2007

Here is my CMenu::init() function. If there is a problem, I assume that it is here. The only different thing about this is the use of alpha blending for effect, maybe I need to turn alpha mode off afterwards?

1void CMenu::init()
2{
3 //bitmap init
4 okButton = NULL;
5 cancelButton = NULL;
6 imageText = NULL;
7 challengeText = NULL;
8 optionSquare = NULL;
9 optionsBack = NULL;
10 buffer = NULL;
11 imageHighlight = NULL;
12 easyText = NULL;
13 mediumText = NULL;
14 hardText = NULL;
15 
16 okButton = load_bitmap("images/okButton.bmp", NULL);
17 cancelButton = load_bitmap("images/cancelButton.bmp", NULL);
18 imageText = load_bitmap("images/imageText.bmp", NULL);
19 challengeText = load_bitmap("images/challengeText.bmp", NULL);
20 easyText = load_bitmap("images/challengeText.bmp", NULL);
21 mediumText = load_bitmap("images/challengeText.bmp", NULL);
22 hardText = load_bitmap("images/challengeText.bmp", NULL);
23 
24 //sprite sheet
25 imageSelect = load_bitmap("images/sheet.bmp", NULL);
26 
27 buffer = create_bitmap(SCREEN_W, SCREEN_H);
28 optionsBack = create_bitmap(SCREEN_W, SCREEN_H);
29 optionSquare = create_bitmap(SCREEN_W - 10, 200);
30 BITMAP *alpha = create_bitmap(SCREEN_W, SCREEN_H);
31 imageHighlight = create_bitmap(130, 130);
32 
33 //initialize them
34 clear_bitmap(buffer);
35 clear_to_color(alpha, makecol(200, 200, 200));
36 clear_to_color(optionSquare, makecol(82, 120, 189));
37 clear_to_color(imageHighlight, makecol(25, 25, 25));
38 
39 //prep options for trans
40 int x, y, c, a;
41 //set the alpha channel blend values
42 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
43 set_write_alpha_blender();
44 //blend the two bitmap alpha channels
45 for (y=0; y<alpha->h; y++) {
46 for (x=0; x<alpha->w; x++) {
47 //grab the pixel color
48 c = getpixel(alpha, x, y);
49 a = getr(c) + getg(c) + getb(c);
50 //find the middle alpha value
51 a = MID(0, a/2-128, 255);
52 //copy the alpha-enabled pixel to the sprite
53 putpixel(optionsBack, x, y, a);
54 }
55 }
56 destroy_bitmap(alpha);
57}

CGamesPlay
Member #2,559
July 2002
avatar

You haven't posted a single line of code that has anything to do with vectors.

[append]
But yeah, drawing_mode needs to be called again with DRAW_MODE_SOLID.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

InfiniteLoop
Member #8,434
March 2007

Quote:

You haven't posted a single line of code that has anything to do with vectors.

Irrelevant. Me writing a line of code to draw a vector graphic will do nothing to show that it does not show up.

At any rate:

Quote:

But yeah, drawing_mode needs to be called again with DRAW_MODE_SOLID.

this was the fix. Thank you

CGamesPlay
Member #2,559
July 2002
avatar

Oh, my mistake. I thought "vector" referred to the STL container class, not the grid. But it's fixed :)

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Go to: