Thema: Delphi Eigene TglColor Klasse

Einzelnen Beitrag anzeigen

Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#2

Re: Eigene TglColor Klasse

  Alt 31. Mär 2007, 12:08
Also das umwandeln eines TColor-Farbwerts ($AABBGGRR) in OpenGL-Farbwerte ist nicht schwer.

Delphi-Quellcode:
type
  TABGR=record
    A, B, G, R: Byte;
  end;

  PABGR=^TABGR;

  TglColor=record
    R, G, B, A: Single;
  end;

//...

function ColorToGlColor(AColor: TColor): TglColor;
var abgr: PABGR;
begin
  abgr:=PABGR(@AColor);
  Result.A:=abgr.A/255;
  Result.B:=abgr.B/255;
  Result.G:=abgr.G/255;
  Result.R:=abgr.R/255;
end;
Die Farbe glGreen u.a. kannst du als Konstante nehmen:
Delphi-Quellcode:
const
  glBlack: TglColor=(R: 0; G: 0; B: 0; A: 1);
  glRed: TglColor=(R: 1; G: 0; B: 0; A: 1);
  glGreen: TglColor=(R: 0; G: 1; B: 0; A: 1);
  glBlue: TglColor=(R: 0; G: 0; B: 1; A: 1);
  glWhite: TglColor=(R: 1; G: 1; B: 1; A: 1);
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat