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.
Show your current code, please.
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
}
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".
Can you please expand on what's happening in your program.
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)
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.
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 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.
ok len,
I'll try what u've said. I've got another doubt.
How to display variable sized windows.
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.
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.
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).
len,
what is openGL? Is it more sophisticated than allegro in doing things.
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?
| 1 | int ret; |
| 2 | BITMAP* buffer; |
| 3 | buffer = create_bitmap(640, 480); |
| 4 | BITMAP* opening; |
| 5 | PALETTE palette; |
| 6 | char fname[480]= "resources/"; |
| 7 | while(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 | } |
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.
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.
OpenGL is graphics only, and pretty complicated. Stick with Allegro for now.
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.