Dissapearing vector

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?


Kris Asick

I recommend you post the code relating to this problem.

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


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.


It works until this point:

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

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;


From this point on, no vector graphics will appear.

Kris Asick

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


Also, use code tags when you post it.


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()
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;
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);
24 //sprite sheet
25 imageSelect = load_bitmap("images/sheet.bmp", NULL);
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);
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));
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);


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

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


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:


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

this was the fix. Thank you


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

Thread #590630. Printed from Allegro.cc