Browse Source

* set correct aspect ratios for standard vga resolutions (although they
are probably no longer correct when running in a window on a higher
resolutions, because everything's now 4:3 I guess) (mantis #5190)
* fixed aspect ratio logic for circle/ellipse (only circle gets adjusted)
(mantis #5190)
* clear window to black when initing graphics mode on Mac OS X

git-svn-id: trunk@8373 -

Jonas Maebe 18 years ago
parent
commit
2f98eaeb0a

+ 7 - 7
packages/extra/graph/go32v2/graph.pp

@@ -2242,7 +2242,7 @@ const CrtAddress: word = 0;
          mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisual320;
          mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisual320;
          mode.SetActivePage := {$ifdef fpc}@{$endif}SetActive320;
          mode.SetActivePage := {$ifdef fpc}@{$endif}SetActive320;
          mode.InitMode := {$ifdef fpc}@{$endif}Init320;
          mode.InitMode := {$ifdef fpc}@{$endif}Init320;
-         mode.XAspect := 10000;
+         mode.XAspect := 8333;
          mode.YAspect := 10000;
          mode.YAspect := 10000;
          AddMode(mode);
          AddMode(mode);
 
 
@@ -2266,7 +2266,7 @@ const CrtAddress: word = 0;
          mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualX;
          mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualX;
          mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveX;
          mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveX;
          mode.InitMode := {$ifdef fpc}@{$endif}InitModeX;
          mode.InitMode := {$ifdef fpc}@{$endif}InitModeX;
-         mode.XAspect := 10000;
+         mode.XAspect := 8333;
          mode.YAspect := 10000;
          mode.YAspect := 10000;
          AddMode(mode);
          AddMode(mode);
 
 
@@ -2292,7 +2292,7 @@ const CrtAddress: word = 0;
          mode.HLine := {$ifdef fpc}@{$endif}HLine16;
          mode.HLine := {$ifdef fpc}@{$endif}HLine16;
          mode.VLine := {$ifdef fpc}@{$endif}VLine16;
          mode.VLine := {$ifdef fpc}@{$endif}VLine16;
          mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
          mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
-         mode.XAspect := 10000;
+         mode.XAspect := 4500;
          mode.YAspect := 10000;
          mode.YAspect := 10000;
          AddMode(mode);
          AddMode(mode);
 
 
@@ -2318,7 +2318,7 @@ const CrtAddress: word = 0;
          mode.HLine := {$ifdef fpc}@{$endif}HLine16;
          mode.HLine := {$ifdef fpc}@{$endif}HLine16;
          mode.VLine := {$ifdef fpc}@{$endif}VLine16;
          mode.VLine := {$ifdef fpc}@{$endif}VLine16;
          mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
          mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
-         mode.XAspect := 10000;
+         mode.XAspect := 7750;
          mode.YAspect := 10000;
          mode.YAspect := 10000;
          AddMode(mode);
          AddMode(mode);
 
 
@@ -2396,7 +2396,7 @@ const CrtAddress: word = 0;
              mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x32k;
              mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x32k;
              mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
              mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
              mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
              mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.XAspect := 10000;
+             mode.XAspect := 8333;
              mode.YAspect := 10000;
              mode.YAspect := 10000;
              AddMode(mode);
              AddMode(mode);
            end;
            end;
@@ -2422,7 +2422,7 @@ const CrtAddress: word = 0;
              mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x64k;
              mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x64k;
              mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
              mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
              mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
              mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.XAspect := 10000;
+             mode.XAspect := 8333;
              mode.YAspect := 10000;
              mode.YAspect := 10000;
              AddMode(mode);
              AddMode(mode);
            end;
            end;
@@ -2454,7 +2454,7 @@ const CrtAddress: word = 0;
              mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
              mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
              mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
              mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
              mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
              mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
-             mode.XAspect := 10000;
+             mode.XAspect := 8333;
              mode.YAspect := 10000;
              mode.YAspect := 10000;
              AddMode(mode);
              AddMode(mode);
            end;
            end;

+ 3 - 5
packages/extra/graph/inc/graph.inc

@@ -681,9 +681,6 @@ var
        { restore line thickness }
        { restore line thickness }
        LineInfo.Thickness := OldLineWidth;
        LineInfo.Thickness := OldLineWidth;
      End;
      End;
-   { Adjust for screen aspect ratio }
-   XRadius:=(longint(XRadius)*10000) div XAspect;
-   YRadius:=(longint(YRadius)*10000) div YAspect;
    If xradius = 0 then inc(xradius);
    If xradius = 0 then inc(xradius);
    if yradius = 0 then inc(yradius);
    if yradius = 0 then inc(yradius);
    { check for an ellipse with negligable x and y radius }
    { check for an ellipse with negligable x and y radius }
@@ -1398,7 +1395,8 @@ end;
              OldWriteMode := CurrentWriteMode;
              OldWriteMode := CurrentWriteMode;
              CurrentWriteMode := CopyPut;
              CurrentWriteMode := CopyPut;
        end;
        end;
-     InternalEllipse(X,Y,Radius,Radius,0,360,{$ifdef fpc}@{$endif}DummyPatternLine);
+     { Adjust for screen aspect ratio }
+     InternalEllipse(X,Y,Radius,(longint(Radius)*XAspect) div YAspect,0,360,{$ifdef fpc}@{$endif}DummyPatternLine);
      if LineInfo.Thickness = Normwidth then
      if LineInfo.Thickness = Normwidth then
          CurrentWriteMode := OldWriteMode;
          CurrentWriteMode := OldWriteMode;
      { restore arc information }
      { restore arc information }
@@ -1818,7 +1816,7 @@ end;
      { normal write mode }
      { normal write mode }
      CurrentWriteMode := CopyPut;
      CurrentWriteMode := CopyPut;
 
 
-     { Schriftart einstellen }
+     { set font style }
      CurrentTextInfo.font := DefaultFont;
      CurrentTextInfo.font := DefaultFont;
      CurrentTextInfo.direction:=HorizDir;
      CurrentTextInfo.direction:=HorizDir;
      CurrentTextInfo.charsize:=1;
      CurrentTextInfo.charsize:=1;

+ 15 - 1
packages/extra/graph/macosx/graph.pp

@@ -832,7 +832,12 @@ begin
     InitColors(maxcolor);
     InitColors(maxcolor);
 
 
   CGContextSetLineWidth(offscreen,1.0);
   CGContextSetLineWidth(offscreen,1.0);
-  
+
+  { start with a black background }
+  CGContextSetRGBStrokeColor(offscreen,0.0,0.0,0.0,1);
+  CGContextFillRect(offscreen,CGRectMake(0,0,MaxX+1,MaxY+1));
+  HIViewSetNeedsDisplay(graphHIView, true);
+
   ShowWindow (myMainWindow);  
   ShowWindow (myMainWindow);  
 
 
 {
 {
@@ -965,6 +970,15 @@ end;
            MaxX:=640-1;
            MaxX:=640-1;
            // same for MaxY
            // same for MaxY
            MaxY:=480-1;
            MaxY:=480-1;
+           YAspect:=10000;
+           if ((MaxX+1)*35=(MaxY+1)*64) then
+             XAspect:=7750
+           else if ((MaxX+1)*20=(MaxY+1)*64) then
+             XAspect:=4500
+           else if ((MaxX+1)*40=(MaxY+1)*64) then
+             XAspect:=8333
+           else { assume 4:3 }
+             XAspect:=10000;
            MaxColor := 256;
            MaxColor := 256;
            PaletteSize := MaxColor;
            PaletteSize := MaxColor;
            HardwarePages := 0;
            HardwarePages := 0;

+ 8 - 2
packages/extra/graph/sdlgraph/sdlgraph.pp

@@ -583,8 +583,14 @@ mode: TModeInfo;
     mode.SetRGBPalette := {$ifdef fpc}@{$endif}sdlgraph_SetRGBpalette;
     mode.SetRGBPalette := {$ifdef fpc}@{$endif}sdlgraph_SetRGBpalette;
     mode.GetRGBPalette := {$ifdef fpc}@{$endif}sdlgraph_GetRGBpalette;
     mode.GetRGBPalette := {$ifdef fpc}@{$endif}sdlgraph_GetRGBpalette;
     //mode.InternalEllipse := {$ifdef fpc}@{$endif}sdlgraph_InternalEllipse;
     //mode.InternalEllipse := {$ifdef fpc}@{$endif}sdlgraph_InternalEllipse;
-    mode.XAspect := 10000;
-    mode.YAspect := 10000;
+    if ((mode.MaxX+1)*35=(mode.MaxY+1)*64) then
+      mode.XAspect:=7750
+    else if ((mode.MaxX+1)*20=(mode.MaxY+1)*64) then
+      mode.XAspect:=4500
+    else if ((mode.MaxX+1)*40=(mode.MaxY+1)*64) then
+      mode.XAspect:=8333
+    else { assume 4:3 }
+      mode.XAspect:=10000;
     //mode.HLine:={$ifdef fpc}@{$endif}sdlgraph_HLine;
     //mode.HLine:={$ifdef fpc}@{$endif}sdlgraph_HLine;
     //mode.VLine:={$ifdef fpc}@{$endif}sdlgraph_VLine;
     //mode.VLine:={$ifdef fpc}@{$endif}sdlgraph_VLine;
     //mode.Line:={$ifdef fpc}@{$endif}sdlgraph_line;
     //mode.Line:={$ifdef fpc}@{$endif}sdlgraph_line;

+ 9 - 0
packages/extra/graph/unix/graph.pp

@@ -546,6 +546,15 @@ end;
            MaxX:=ModeInfo.Width-1;
            MaxX:=ModeInfo.Width-1;
            // same for MaxY
            // same for MaxY
            MaxY:=ModeInfo.Height-1;
            MaxY:=ModeInfo.Height-1;
+           YAspect:=10000;
+           if ((MaxX+1)*35=(MaxY+1)*64) then
+             XAspect:=7750
+           else if ((MaxX+1)*20=(MaxY+1)*64) then
+             XAspect:=4500
+           else if ((MaxX+1)*40=(MaxY+1)*64) then
+             XAspect:=8333
+           else { assume 4:3 }
+             XAspect:=10000;
            MaxColor := ModeInfo.colors;
            MaxColor := ModeInfo.colors;
            PaletteSize := MaxColor;
            PaletteSize := MaxColor;
            HardwarePages := 0;
            HardwarePages := 0;

+ 3 - 3
packages/extra/graph/win32/graph.pp

@@ -2004,7 +2004,7 @@ function queryadapterinfo : pmodeinfo;
           mode.MaxX := 639;
           mode.MaxX := 639;
           mode.MaxY := 199;
           mode.MaxY := 199;
           SetupWin32GUIDefault;
           SetupWin32GUIDefault;
-          mode.XAspect := 10000;
+          mode.XAspect := 4500;
           mode.YAspect := 10000;
           mode.YAspect := 10000;
           AddMode(mode);
           AddMode(mode);
        end;
        end;
@@ -2021,7 +2021,7 @@ function queryadapterinfo : pmodeinfo;
           mode.MaxX := 639;
           mode.MaxX := 639;
           mode.MaxY := 349;
           mode.MaxY := 349;
           SetupWin32GUIDefault;
           SetupWin32GUIDefault;
-          mode.XAspect := 10000;
+          mode.XAspect := 7750;
           mode.YAspect := 10000;
           mode.YAspect := 10000;
           AddMode(mode);
           AddMode(mode);
        end;
        end;
@@ -2038,7 +2038,7 @@ function queryadapterinfo : pmodeinfo;
           mode.MaxX := 639;
           mode.MaxX := 639;
           mode.MaxY := 399;
           mode.MaxY := 399;
           SetupWin32GUIDefault;
           SetupWin32GUIDefault;
-          mode.XAspect := 10000;
+          mode.XAspect := 8333;
           mode.YAspect := 10000;
           mode.YAspect := 10000;
           AddMode(mode);
           AddMode(mode);
        end;
        end;