3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Automatic resizing panels function
[Re: Orange Brat]
#44471
09/01/06 10:59
09/01/06 10:59
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
pnl_temp.filter = (screen_size.x != HUD_reference.x);
Yeah, that works on the fly, because its a boolean operation. Uhm, or simplier explained: (screen_size.x != HUD_reference.x) returns only 1 or 0, so, these are also the only values .filter accepts.
The reason for this line, is, btw, that even when I scale it with 1 for both axis', it is blurry with filter=on. So, I simply turn it off and it is sharp as hell.
EDIT: you can do such things with every boolean property (=flags). But you can't assign them directly. You can use e.g.
boolean = sign(boolean); or boolean = (boolean == 1);
(this doesnt count for vars, there you can assign like every variable)
booleans (operations) are really useful, they are shortening the code a lot.
Last edited by HeelX; 09/01/06 11:07.
|
|
|
Re: Automatic resizing panels function
[Re: HeelX]
#44472
09/02/06 01:10
09/02/06 01:10
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP

Senior Expert
|
OP

Senior Expert
Joined: Aug 2000
Posts: 7,490
|
That explains it. Thanks. All right, here's what I'm going to call the "final" version of the automatic resizing panel function. I can't really take credit for it, given it's so much shorter and elegant than my initial version(which is long because of the per video_mode checks and some sloppy, early code). Anyway, this combines eleroux's basic function with a little bit of Heelx's. I tested it...it works. I created a black panel at 1600x1200 and set a pox_x/pos_y of 200 in the panel declaration. After switching video_modes, the panel was resized and was in the exact same spot on the screen for every resolution after calling the funcion(in this case a simple pause screen). The bad news about doing it this way is that the video memory usage is going to be large if you use a lot of large bitmaps. That 1600x1200 black panel was around 8MB when active. My fullscreen filmgrain effect(from another contribution) clocks in at around 49MB(6 1600x1200 PCX files). I don't know enough about bitmap formats and memory consumption, so perhaps using a different format(like DDS) would reduce the mem hit. Code:
panel* pnl; var maxRes[2] = 1600, 1200; //0 = represents your maximum supported X; 1 = represents your maxiumum supported Y
function panelRefresh(panel) { pnl = panel; var tempScale[2];
if(pnl) { tempScale[0] = pnl.scale_x; //store current panel's X scale tempScale[1] = pnl.scale_y; //store current panel's Y scale
//Scaling pnl.scale_x = (screen_size.x / maxRes.x); pnl.scale_y = (screen_size.y / maxRes.y); //Modify position: tempScale[0] = pnl.scale_x / tempScale[0]; tempScale[1] = pnl.scale_y / tempScale[1]; //Apply modification pnl.pos_x *= tempScale[0]; pnl.pos_y *= tempScale[1];
//Switch the filter flag off if the current resolution = maxRex.x pnl.filter = (screen_size.x != maxRes.x); } }
function scaleAllPanels() //panel names are examples. Change to reflect your own naming convention. { panelRefresh(pause); panelRefresh(loadMenu); panelRefresh(saveMenu); panelRefresh(gameSavingScreen); panelRefresh(mainMenu); panelRefresh(credits); panelRefresh(filmGrain); panelRefresh(blackPanel); .. .. .. ..etc.. }
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: Automatic resizing panels function
[Re: Orange Brat]
#44474
09/02/06 09:11
09/02/06 09:11
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Quote:
The bad news about doing it this way is that the video memory usage is going to be large if you use a lot of large bitmaps. That 1600x1200 black panel was around 8MB when active. My fullscreen filmgrain effect(from another contribution) clocks in at around 49MB(6 1600x1200 PCX files).
Of course! A captured 1024x768 screen makes ~3,4 MB more or less, that is very much, indeed.
I don't know how you do your effect, but it could be worth it when you dont adapt it on the current screenresolution but on a bitmap that is smaller so that you work on it and later you scale it. 49MB for an effect with 6 1600x1200 files is a waste of memory! Can I have a look at that other contribution because I dont get the clue what are you talking about.
|
|
|
Re: Automatic resizing panels function
[Re: HeelX]
#44475
09/02/06 09:35
09/02/06 09:35
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP

Senior Expert
|
OP

Senior Expert
Joined: Aug 2000
Posts: 7,490
|
Here's the thread: http://www.coniserver.net/ubbthreads/showflat.php?Cat=&Board=UBB3&Number=499869That code in the thread is almost identically to what is below, except it included the resizing locally, and the new version includes an experimental flickering alpha effect. I use the new panelRefresh from this thread, now. I actually used to use 6 640x480 panels and scaled up. The memory hit was much lower, however it didn't look as nice at higher resolutions because of pixelation. I only recently changed to 1600x1200 bitmaps for it. I may change back to the lower resolution, though. I don't think I ever used the filter flag with it, because I was using it before we had a filter flag and never bothered to use it. I think I'll test it out with the smaller images and see what it looks like with filter turned on. If you've played the Silent Hill games, you'll be familiar with what this is for. It adds subtle filmgrain appearance to the view. It rapidly switches from bitmap to bitmap and it makes it look like an old movie. It can also be done via shader, but I remember the version used in 3DGS game project "The Kid" slowing down the framerate quite a bit compared to the old school method below(which The Kid also used as an alternative and resulted in better fps, plus I thought it looked better). Code:
panel filmGrainPanel { layer = 200; pos_x = 0; pos_y = 0; flags = overlay,filter; }
var grainFlag; var grainToggle = 1; bmap grain1 = <grain1.tga>; bmap grain2 = <grain2.tga>; bmap grain3 = <grain3.tga>; bmap grain4 = <grain4.tga>; bmap grain5 = <grain5.tga>; bmap grain6 = <grain6.tga>;
function filmGrain() { panelRefresh(filmGrainPanel); grainFlag = 1; while(grainToggle == 1) { filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 20, 100); filmGrainPanel.bmap = grain1; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off; filmGrainPanel.bmap = grain2; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off; filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 30, 70); filmGrainPanel.bmap = grain3; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off; filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 30, 90); filmGrainPanel.bmap = grain4; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off; filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 30, 60); filmGrainPanel.bmap = grain5; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off; filmGrainPanel.bmap = grain6; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off; } filmGrainPanel.visible = off; bmap_purge(grain1); bmap_purge(grain2); bmap_purge(grain3); bmap_purge(grain4); bmap_purge(grain5); bmap_purge(grain6); grainFlag = 0; }
EDIT: Reducing to 640x480 reduced it to around 6MB. Using TGAs instead of PCX doubled it to 12MB but looks much better when scaled, so 6 640x480 TGA files for the effect. It requires an IF check in the panelRefresh to accomodate the reduced resolution(since the baseline is 1600x1200). Since, this effect is a series of noise screens, I can get away with scaling up and maintaining quality: Code:
if(pnl == filmGrainPanel) { pnl.scale_x = screen_size.x / 640; pnl.scale_y = screen_size.y / 480; } else { pnl.scale_x = screen_size.x / maxRes.x; pnl.scale_y = screen_size.y / maxRes.y; }
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: Automatic resizing panels function
[Re: HeelX]
#44477
09/16/07 20:40
09/16/07 20:40
|
Joined: Sep 2007
Posts: 36 Spain
Bahamut
Newbie
|
Newbie
Joined: Sep 2007
Posts: 36
Spain
|
So... is it viable to use this panel resicing script from Orange Brat? Did you "HeelX" have a new version of it?
Working in a RPG
|
|
|
Re: Automatic resizing panels function
[Re: HeelX]
#44479
09/17/07 01:38
09/17/07 01:38
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
Expert
|
Expert
Joined: Feb 2006
Posts: 2,185
|
actually all you need is a function that sets a panel to resize according to the screensize / the size of the panel like this:
panel* pan;
function resize_panel(pnl, scale_) { pan = pnl; pan.scale_x = screen_size.x / pan.size_x + scale_; pan.scale_y = screen_size.y / pan.size_y + scale_; }
you'd use it like this:
resize_panel(panel_name, 0.2);
and if you use it in a while loop, or update it every time the video mode changes, then it will always be the size of the screen. to center a panel is just as easy. you'd use negative values for a smaller panel, or could use 0 for a fullscreen panel...
Last edited by Manslayer101; 09/17/07 01:41.
- aka Manslayer101
|
|
|
|