Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro gui -problem

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Allegro gui -problem
pawel559 pawel559
Member #8,319
February 2007
avatar

Hi
I want to use at the same time gui and page flipping.
But I have only one of them at the same time.
Is posible to use gui and page flipping together ?
How can I do that ?

CGamesPlay
Member #2,559
July 2002
avatar

You can call this function with your currently active bitmap:gui_set_screen(page1);

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

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

pawel559 pawel559
Member #8,319
February 2007
avatar

Nothing change.
This is my code:

#include <iostream>
#include <allegro.h>
#include <winalleg.h>

/***************************************/
BITMAP *buffer;
BITMAP *page1, *page2;
BITMAP *active_page;
/***************************************/
//SURFACE class
class SURFACE{
public:
BITMAP *surface;
bool rysuj;

void loadimage(char* name);
void free();
void draw(int x,int y,int w,int h,int a,int b);
void TransparentDraw(int x,int y,int w,int h,int a,int b);
};
void SURFACE::loadimage(char* name)
{
rysuj=true;
surface = load_bitmap(name, NULL);
}
void SURFACE::free()
{
destroy_bitmap(surface);
}
void SURFACE::draw(int x,int y,int w,int h,int a,int b)
{

if(rysuj==true){blit(surface, active_page, a, b, x,y, w, h);}

}
void SURFACE::TransparentDraw(int x,int y,int w,int h,int a,int b)
{
if(rysuj==true){masked_blit(surface,active_page,a,b,x,y,w,h);}

}
//////////////////////////////////////////////
SURFACE image;

DIALOG the_dialog[] =
{
{ d_button_proc, 160, 40, 160, 20, 0, 0, 't', 0, 0, 0, (void*)"&Toggle Me!", (void*) NULL, (void*)NULL }

};
int main(void)
{

//init allegro
allegro_init();

install_timer();
install_keyboard();
install_mouse();
install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,"");

set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT, 800,600,0,0);
set_palette(desktop_palette);

/* now create two video memory bitmaps for the page flipping */
page1 = create_video_bitmap(SCREEN_W, SCREEN_H);
page2 = create_video_bitmap(SCREEN_W, SCREEN_H);
active_page = page2;
clear_keybuf();

///////////////

image.loadimage("a.bmp");

gui_fg_color = makecol(0, 0, 0);
gui_mg_color = makecol(128, 128, 128);
gui_bg_color = makecol(200, 240, 200);
set_dialog_color(the_dialog, gui_fg_color, gui_bg_color);
the_dialog[0].bg = makecol(255, 255, 255);
position_dialog(the_dialog, 200, 2);

while(true)
{

// clear_bitmap(active_page);
/////////////////////

do_dialog(the_dialog, -1);
image.draw(0,0,100,100,0,0);
///////////////////
show_video_bitmap(active_page);
gui_set_screen(active_page);
if (active_page == page1)
active_page = page2;
else
active_page = page1;

if(key[KEY_ESC])break;

// }
}

image.free();
destroy_bitmap(page1);
destroy_bitmap(page2);
return 0;
}
END_OF_MAIN()

CGamesPlay
Member #2,559
July 2002
avatar

You set the gui screen to the bitmap on the screen. Don't do that. Set it to the back page, the same one that you do all your drawing to.

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

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

Kitty Cat
Member #2,815
October 2002
avatar

And do_dialog is blocking. It won't return until the dialog is closed.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

pawel559 pawel559
Member #8,319
February 2007
avatar

I am not very good speak english ,and I don't understandt evrythink.
Can you improve my code ?

CGamesPlay
Member #2,559
July 2002
avatar

I said to do this:

show_video_bitmap(active_page);
if (active_page == page1)
    active_page = page2;
else
    active_page = page1;
gui_set_screen(active_page);

KittyCat says to not use do_dialog and instead use these functions. You need to figure out how to use them yourself:

DIALOG_PLAYER *player = init_dialog(the_dialog, -1);

if(!update_dialog(player))
{
    // Do something with the dialog data
    shutdown_dialog(player);
}

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

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

pawel559 pawel559
Member #8,319
February 2007
avatar

Now I have other problem ,just look at that http://emugames.cba.pl/file.7z

CGamesPlay
Member #2,559
July 2002
avatar

Err, no. I don't have 7z, so I won't even speculate as to whether you gave a description of the problem.

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

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

pawel559 pawel559
Member #8,319
February 2007
avatar

Now the dialog is flashing.
Is this normal ?

Kitty Cat
Member #2,815
October 2002
avatar

Yes, because the dialog only draws once (on whichever bitmap was active at the time) until something makes it draw again. If you're not using a double buffer, you can call:
dialog_message
with MSG_DRAW right before update_dialog.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

pawel559 pawel559
Member #8,319
February 2007
avatar

It is work ! :D
You are the best.
:)

CGamesPlay
Member #2,559
July 2002
avatar

You're welcome, but be warned! We expect to see a completed game from you, with screenshots, soon! :)

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

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

pawel559 pawel559
Member #8,319
February 2007
avatar

I have one more question .
When I set editbox height nothing change.
Is the height in the editbox const ?
Why ?

My code:
{d_edit_proc ,100, 20, 400, 500, 10, 10,0,0,0,0,(void*)the_string, (void*)NULL, (void*)NULL }

CGamesPlay
Member #2,559
July 2002
avatar

The height of the font is constant. You have to make a bigger font yourself :-/

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

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

pawel559 pawel559
Member #8,319
February 2007
avatar

Do you now any other GUI libary for allegro which can do that ?
I was using allegro gui ,because I need a EDITBOX for my game.

CGamesPlay
Member #2,559
July 2002
avatar

Well if you find a program called "ttf2pcx" on the net and use that to make a font that Allegro can read, you can make fonts as big as you like.

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

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

miran
Member #2,407
June 2002

Quote:

Do you now any other GUI libary for allegro which can do that ?

Plug! ;D

Third link in my sig. :)

--
sig used to be here

pawel559 pawel559
Member #8,319
February 2007
avatar

I am using GCC compiler and I tried instal a MASkinG but I have some problems in build libary.
Is on the web a "MASkinG.a" for download ?

CGamesPlay
Member #2,559
July 2002
avatar

You need to post the specific problems that you had.

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

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

pawel559 pawel559
Member #8,319
February 2007
avatar

In the console I see "Makefiles configured.Now go to the src directory and run 'make' and 'make install' ". But when I go to src directory there isn't any exe files which can be run .:P

CGamesPlay
Member #2,559
July 2002
avatar

:P

Stay in the command prompt and run "make" and then run "make install". "Run" means "type in and then press enter" ;)

"make" is a program that comes with your compiler, it's used for automating the build process. Your IDE makes the Makefiles for you, so you don't have to.

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

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

pawel559 pawel559
Member #8,319
February 2007
avatar

when I run make.exe in the command line I see "*** No targets. Stop." .

Kauhiz
Member #4,798
July 2004

You're running it from the correct directory? And just run "make", not "make.exe"

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

pawel559 pawel559
Member #8,319
February 2007
avatar

I try run make ,and the result was the same.
The directory is correct.

 1   2 


Go to: