All,
I'll try to be brief and if you need code I can send the files. There is too much going on to single out a single section.
In short, I wrote a simple "concentration" match game. Mainly to use a mouse which I've never written for. As ideas came to me I added and patched onto the original game. Once running fair my grandson asked if I could go full screen. You may remember that post. I managed to include a choice of screen sizes and have the blocks / cards change proportionally so I didn't have to rewrite a bunch of size cards.
Things went well. I made it so you could choose a screen size, with largest being 1600 x 900. At this size I still have the window title bar. Still my grandson pointed out it wasn't full screen. (1900x1080) So I decided for a trial I'd work with FULLSCREEN. The program goes full screen however the content doesn't. I need the width and height to use in calculating the proportional drawing of the cards. I also use it to calculate mouse position in relation to the cards.
In any case I tried working with DISPLAY_MODE. It will give me the number of screen modes along with their height x width. I minus 2 from max count of screen modes and use that H x W. It works fine. Not quite tall enough to cover screen but close.
I said all of this to ask, if I'm just setting display size in the same manner as with 320x200 / 640x480/ 800x600 etc, then why does the window control disappear like with full screen? I grab the screen modes. Use the largest height and width. Calculate like normal and set the screen to the height and width as before. I just don't have a window bar now. Was just curious.
Thanks
OK I thought maybe the function for choosing screen size might help. How I use the numbers later really doesn't matter. Here is where the screen size is set.
You need to set the flags for fullscreen vs windowed when creating a new display.
al_set_new_display_flags()
Thanks Daniel I think I see the reason behind what you are saying. I was just playing around and shaving 80 to 100 off the 1080 (largest screen height picked up by DISPLAY_MODE) and seen the title bar is there, it's just not visible at 1080. The upper left hand corner of the window viewing area starts at 0,0, not the window itself.
I'm guessing the if you don't specify windowed as you indicated, the screen height and width, must represent the area within the window and not include the window attributes themselves. I only use the X in the title block but it would probably be the same with scroll bars and menus if you used them.
Just thinking out loud. Thanks Again.
Yes, if you make it too big, the title bar will go off screen.
You can use ALLEGRO_FULLSCREEN_WINDOW as the graphics mode, and just scale the graphics to match that.
I use this code to scale my drawing so that it fills the screen without changing the aspect ratio:
Thanks torhu,
My original attempts with FULLSCREEN (and WINDOW) did change the program screen as expected. However, the program itself didn't scale to match.
If I set the screen size to a specific / numeric size I could get the program to scale proportionally. The issue came with the mouse position in relation to the cards/blocks on screen. When the mouse button was pressed to flip the card, the card was no longer in the original location or size. I figured out a way to scale the mouse by put in an offset based on screen size.
I think your solution will make that a lot easier. I'll read up on transforming I haven't used it before. Or clipping for that matter. Thanks again.
The issue came with the mouse position in relation to the cards/blocks on screen. When the mouse button was pressed to flip the card, the card was no longer in the original location or size. I figured out a way to scale the mouse by put in an offset based on screen size.
I haven't tried using mouse input with this way of scaling, but I assume it would just be something like this:
ALLEGRO_TRANSFORM inverse_trans; float unscaled_x, unscaled_y; al_copy_transform(&inverse_trans, &drawing_trans); al_invert_transform(&inverse_trans); al_transform_coordinates(&inverse_trans, &unscaled_x, &unscaled_y);
APPEND:
Need to set x and y to the coordinates from the mouse event first, of course.
Thanks torhu,
Again, I really need to investigate TRANSFORM. I'm going to look it over today.
Meanwhile here is the short of what I am doing. The opening screen is set at 640x480. It has Play & Quit buttons. For simplicity sake, lets say upper left of Play is 50,50 and lower right is 100,100. The Quit button is at 50,120 by 100,170.
When the screen is set to a different size, say 800x600, and I do a al_draw_scaled_bitmap, the buttons are no longer at those coordinates. When the mouse button is pressed, & I look to see if it's between 50,50 x 100,100, nothing happens.
What I do is (ht_percentage = screen height / buffer height) & the same for width. The ht_percentage and wd_percentage are multiplied by the original 50,50 x 100,100. This give me the new location of the buttons. I do this as well for the card locations in the game.
I'm sure there is a better way of doing this but I couldn't find it.
Thanks again for the insight.
Ace, the gist of what you are doing is applying world transformations.
When you place your button at 50,50 that is world space. When you make your display larger than normal, that is screen space. You need a way to translate from screen space to world space and back.
In this case all you had to do was scale and unscale the mouse for the button coordinates.
I hope this makes it a little clearer.
That is clearer Edgar, and sounds a lot simpler. I'll look into it. I do scale the buffer, make sense there would be an option to do this for the mouse.
You just create a transform to move from world to screen coordinates. Then you invert that transform and apply it to your mouse coordinates to get their position on the world.