Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » how to display file_select_ex on a BITMAP

This thread is locked; no one can reply to it. rss feed Print
how to display file_select_ex on a BITMAP
raja peter
Member #7,835
October 2006

hi,

Sorry for repeating this question.

I want to display the file choosing element using file_select_ex on a bitmap that is refreshed indefinitely until a user selection.

When i using it, it comes in a new blank window. Pls help.

luv,

raja

CGamesPlay
Member #2,559
July 2002
avatar

Show your current code, please.

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

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

raja peter
Member #7,835
October 2006

sorry for the delay. I had to go.

char fname[480]= "C:/Dir";
while(1)
{

draw_sprite(screen, buffer, 0, 0);
draw_sprite(buffer, opening,0,0);

// some other images here

ret = file_select_ex("Please pick a file", fname, "PCX;GIF", PATH_MAX, 200, 100);
if(ret)
{
// some function calls
break;
}
// some other code


}

luv,

raja

LennyLen
Member #5,313
December 2004
avatar

Try swapping the order of these two lines:

draw_sprite(screen, buffer, 0, 0);
draw_sprite(buffer, opening,0,0);

At the moment, you're blitting the buffer to the screen before you blit your sprite to the buffer.

edit:

Oh, and for compatibilty reasons, you shouldn't used fixed pathnames like "c:/dir".

Matthew Dalrymple
Member #7,922
October 2006
avatar

Can you please expand on what's happening in your program.

Quote:

When i using it, it comes in a new blank window. Pls help.

Do you mean your screen is just blank, or the File select menu is blank?
Right now from my knowledge you are drawing a blank buffer onto the screen, then drawing a blank opening bitmap onto buffer. (Both which will draw nothing to the screen)

=-----===-----===-----=
I like signatures that only the signer would understand. Inside jokes are always the best, because they exclude everyone else.

raja peter
Member #7,835
October 2006

a blank screen (black background) with only file select box appears also it does not enable the particular element to choose drives(c: ,d:, etc).

I think the drawing on the buffer is the bone of contention. I draw a image on the whole screen and then put the file selection box on it (that image is refreshed infinitely). Here "opening" is that image. it is of full screen size(800,600).

I'm probably confused with the images. I usually draw a full screen image on the screen as u can see in code. Then draw other images on the buffer like

draw_sprite(buffer, classic, 180, 230);

I display the file select box after the above statement.

luv,

raja

Matthew Dalrymple
Member #7,922
October 2006
avatar

Try what LennyLen suggested and see what happens. About the path names, changing char fname[480]= "C:/Dir"; to char fname[480]= ""; will give you your current directory. From there you can use relative pathnames to get to your resource folder. This way you can pack up and move your project without having to fix fname.
Example: char fname[480]= "resources\\";
Also suggesting you use backslashes instead of your forward slash method. As I believe forward slashes are a Windows only directory method.

EDIT: Ohh tag before your tag :-P

=-----===-----===-----=
I like signatures that only the signer would understand. Inside jokes are always the best, because they exclude everyone else.

LennyLen
Member #5,313
December 2004
avatar

Quote:

I think the drawing on the buffer is the bone of contention. I draw a image on the whole screen and then put the file selection box on it (that image is refreshed infinitely). Here "opening" is that image. it is of full screen size(800,600).

Well, as both Matthew and I have already pointed out, this actually isn't what you are doing. Or rather you are doing it incorrectly.

edit: It seems Matthew and I are playing tag. ;)

raja peter
Member #7,835
October 2006

ok len,

I'll try what u've said. I've got another doubt.

How to display variable sized windows.

luv,

raja

Kitty Cat
Member #2,815
October 2002
avatar

file_select and file_select_ex are blocking. You can't put them on top of animated backgrounds since the function won't return until a selection is made.

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

LennyLen
Member #5,313
December 2004
avatar

Quote:

Also suggesting you use backslashes instead of your forward slash method. As I believe forward slashes are a Windows only directory method.

Better still, use fix_filename_slashes(), to convert filenames to the correct format on all platforms supported by Allegro.

edit: Oh, and it's DOS/Windows that use backslashes.

Quote:

How to display variable sized windows.

This isn't possible using Allegro alone, and you won't be able to find a cross-platform method of doing it (to my knowledge).

raja peter
Member #7,835
October 2006

len,

what is openGL? Is it more sophisticated than allegro in doing things.

luv,

raja

Matthew Dalrymple
Member #7,922
October 2006
avatar

Is this the jist of what you're trying to do?
Draws the selected image to the screen, and then asks for a new one?

1int ret;
2BITMAP* buffer;
3buffer = create_bitmap(640, 480);
4BITMAP* opening;
5PALETTE palette;
6char fname[480]= "resources/";
7while(1)
8{
9 ret = file_select_ex("Please pick a file", fname, "BMP", PATH_MAX, 200, 100);
10 if(ret)
11 {
12 opening = load_bitmap(fname, palette);
13 }
14 else
15 {
16 break;
17 }
18 draw_sprite(buffer, opening, 0, 0);
19 draw_sprite(screen, buffer, 0, 0);
20}

=-----===-----===-----=
I like signatures that only the signer would understand. Inside jokes are always the best, because they exclude everyone else.

LennyLen
Member #5,313
December 2004
avatar

Quote:

what is openGL?

OpenGL is a cross-platform graphics API. It's mainly used for 3D graphics, but can be used for 2D as well.

Quote:

Is it more sophisticated than allegro in doing things.

I've never used it myself, but I really doubt it has functions like file_select_ex(). OpenLayer, which is an extension to Allegro that exposes OGL possibly does though.

23yrold3yrold
Member #1,134
March 2001
avatar

OpenGL is graphics only, and pretty complicated. Stick with Allegro for now.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

raja peter
Member #7,835
October 2006

Matthew,

it is not that "opening" is the image to be loaded.

But, it is full screen image(800*600) that is drawn on the screen buffer.

file_select box is to be drawn on that image.

when the file_select returns, I'll use another bitmap to load the selected image.

I think u understand the problem in my code now.

luv,

raja

Go to: