Ratio
Moderator: Moderators
So I guess you calculate the render area in application and then pass parameters down to the platform-function. Can you post some code-snippets showing how you've tried to solve it? The screen shot looks nice!
Yes it would be cool if the zge-runtime only included the components needed for the current game in ZDesigner. That would make it easier to have more components and not bother about every components kb-size. I have an idea how that can be achieved but I haven't had the time to see if it is realistic yet. That topic needs a separate investigation-thread in the future.
Yes it would be cool if the zge-runtime only included the components needed for the current game in ZDesigner. That would make it easier to have more components and not bother about every components kb-size. I have an idea how that can be achieved but I haven't had the time to see if it is realistic yet. That topic needs a separate investigation-thread in the future.
Hi Ville,
The calculations where actually done in Renderer.pas, but I probably need to move them to ZApplication.pas in order to get everything to frmEditor.pas as well ( this is where I'm having most difficulties ). Anyway, here's the Init snippet.
As far as modular development concerned, I only get as far as thinking you'd need a component register, and a "mother" component object you can extend individual component classes from ( moved from their catagory.pas to individual files ). Then you'd either need to parse through a project to see what methods are used, or let the user consciously enable / disable individual components before making them available for use in the Editor.
Anyway, future indeed
K
The calculations where actually done in Renderer.pas, but I probably need to move them to ZApplication.pas in order to get everything to frmEditor.pas as well ( this is where I'm having most difficulties ). Anyway, here's the Init snippet.
Code: Select all
procedure InitRenderer(Width,Height : integer; Ratio : single);
var
ViewportX : integer;
ViewportY : integer;
ViewportWidth : integer;
ViewportHeight : integer;
begin
if(Width/Height > Ratio)then
begin
ViewportWidth := Trunc(Height*Ratio);
ViewportHeight := Height;
ViewportX := Trunc((Width-Height*Ratio)/2);
ViewportY := 0;
end
else
begin
ViewportWidth := Width;
ViewportHeight := Trunc(Width/Ratio);
ViewportX := 0;
ViewportY := Trunc((Height-Width/Ratio)/2);
end;
glViewport(ViewportX, ViewportY, ViewportWidth, ViewportHeight);
end;
Anyway, future indeed
K
That looks pretty manageable! I've only used glViewport with the full screen area before.
1. What is the name and type of the property that the user will set?
2. What is the default value of this property, and what will the user do if he wants the current behavior (use full resolution as render area).
1. What is the name and type of the property that the user will set?
2. What is the default value of this property, and what will the user do if he wants the current behavior (use full resolution as render area).
Hi Ville,
From ZApplication.pas
But perhaps ViewportRatio or CameraRatio would be better then just Ratio. And I could insert a if Ratio == 0 then just use the full window / screen resolution.
K
From ZApplication.pas
Code: Select all
TZApplication = class(TZComponent)
public
Ratio,FOV,ClipNear,ClipFar : single;
List.AddProperty({$IFNDEF MINIMAL}'Ratio',{$ENDIF}integer(@Ratio) - integer(Self), zptFloat);
List.GetLast.DefaultValue.FloatValue := 4/3;
K
"ViewportRatio" sounds good. Or is there another term for this? I want to be sure we use the correct terminology and minimize the risk of confusion with other "ratios".Kjell wrote:But perhaps ViewportRatio or CameraRatio would be better then just Ratio. And I could insert a if Ratio == 0 then just use the full window / screen resolution.K
And a zero value (which should be default for backwards compatibility) for the old behavior is good too!
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
Hi jph,
The main reason for implementing this is that no matter what ScreenRatio you'll run a application in, that the active rendering region ( Viewport ) can always be the same ratio. Right now ( 1.9.0 ) the extremes lie at 4/3 and 1.6, which means that the person running in a ScreenRatio of 1.6 can see a significantly wider portion of your game compared to 4/3 .. and with that maybe even stuff that you never meant to have visible to begin with.
K
The main reason for implementing this is that no matter what ScreenRatio you'll run a application in, that the active rendering region ( Viewport ) can always be the same ratio. Right now ( 1.9.0 ) the extremes lie at 4/3 and 1.6, which means that the person running in a ScreenRatio of 1.6 can see a significantly wider portion of your game compared to 4/3 .. and with that maybe even stuff that you never meant to have visible to begin with.
K
Suggestion:
Two new properties on application:
ViewportRatio dropdown (Use full window, Custom, 4:3, 16:9)
"Use full window" is the default and gives the current zge 1.9.0 behavior of rendering to the full window.
CustomViewportRatio numeric value, used when ViewportRatio is "Custom".
Will that be generic enough and still easy to use? I can make this change if you want to concentrate on your joystick feature Kjell
Two new properties on application:
ViewportRatio dropdown (Use full window, Custom, 4:3, 16:9)
"Use full window" is the default and gives the current zge 1.9.0 behavior of rendering to the full window.
CustomViewportRatio numeric value, used when ViewportRatio is "Custom".
Will that be generic enough and still easy to use? I can make this change if you want to concentrate on your joystick feature Kjell