AL_OpenGL

Top  Previous  Next

 

(*  StOpenGl  Delphi 5 komponens

 

   TCustomControl descendant OpenGL component for fast graphic

 

   Windowed kontrol, OpenGl tulajdonságokkal

   grafika megjelenitésére.

 

   By: Agócs László StellaSOFT

*)

 

unit AL_OpenGl;

 

interface

 

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, ExtCtrls,

Forms, Dialogs, OpenGL, NewGeom, ClipBrd, Math, JPeg;

 

type

TSzin = record

   R,G,B : double;

   width : integer;

end;

 

TShadeModel = (smFlat,smSmooth);

 

TChangeWindow    = procedure(Sender: TObject; Cent: TPoint2D;  Zoom: Double) of object;

 

TALBaseOpenGL = class(TCustomControl)

private

   FClearColor   : TColor;

   FZoom     : extended;

   FCentrum: TPoint2d;

   FShadeModel: TShadeModel;

   FCentralCross: boolean;

   FRotAngle: double;

   FChangeWindow: TChangeWindow;

   FOnPaint: TNotifyEvent;

   procedure WMEraseBkGnd(var Message:TWMEraseBkGnd); message WM_ERASEBKGND;

   procedure WMPaint(var Msg: TWMPaint); message WM_PAINT;

   procedure WMSize(var Msg: TWMSize); message WM_SIZE;

   Procedure CMChildkey( Var msg: TCMChildKey ); message CM_CHILDKEY;

   procedure CMMouseEnter(var msg: TMessage); message CM_MOUSEENTER;

   procedure CMMouseLeave(var msg: TMessage); message CM_MOUSELEAVE;

   procedure SetClearColor(const Value: TColor);

   procedure SetZoom(const Value: extended);

   procedure SetCentrum(const Value: TPoint2d);

   procedure SetShadeModel(const Value: TShadeModel);

   procedure SetCentralCross(const Value: boolean);

   function GetCanvas: TCanvas;

   procedure SetRotAngle(const Value: double);

protected

   OpenGL_OK: boolean;           // OpenGL initialized

   procedure StartOpengl;

   procedure SetDCPixelFormat;

   procedure MouseDown(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer); override;

   procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;

   procedure MouseUp(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer); override;

   function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;

     MousePos: TPoint): Boolean; override;

   function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;

   function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;

   procedure KeyDown(var Key: Word;Shift: TShiftState); override;

   procedure KeyPress(var Key: Char); override;

   procedure DblClick;  override;

public

   DC: HDC;

   hrc : HGLRC;

   BackBMP: TBitmap;      // For drawing in back

   OrtoLeft,OrtoRight,OrtoBottom,OrtoTop: double;

   origin,movept,oldmovept: TPoint;

   SelRect : TRect;

   rSIN,rCOS : double;    // sin and cos of RotAngle;

   constructor Create(AOwner: TComponent); override;

   destructor Destroy; override;

//    procedure Paint; override;

   procedure ReDraw;

   procedure Demo;

   procedure DrawCentralCross;

   procedure CopyToClipboard;

 

   // Coordinate functions

   function XToW(x: integer): double;

   function YToW(y: integer): double;

   function XToS(x: double): integer;

   function YToS(y: double): integer;

   function WToS(p: TPoint2d): TPoint;

   function SToW(p: TPoint): TPoint2d;

 

   function GetWorkArea:TRect2d;

   function GetTotalMapArea:TRect2d;

 

   procedure MoveWindow(x, y: double);

   procedure ShiftWindow(x, y: double);

 

   // Drawing primitives

   procedure glRectangle(p1,p2,p3,p4: TPoint2d);  overload;

   procedure glRectangle(p: TPoint2d; a,b: double); overload;

   procedure glCircle(u,v,r: double);

   procedure glPrint(text : string);

 

   procedure SBI;         // Save the current bitmap to BackBMP

   procedure LBI;         // Load the current bitmap from BackBMP

 

   // Texture rutins

//    function CreateTexture(Texture: String): cardinal;

//    function LoadGLTextures: boolean;

 

   property Canvas        : TCanvas  read GetCanvas;

   property Centrum       : TPoint2d read FCentrum write SetCentrum;

published

   property CentralCross  : boolean   read FCentralCross write SetCentralCross;

   Property ClearColor    : TColor    read FClearColor write SetClearColor;

   property RotAngle      : double    read FRotAngle write SetRotAngle;

   property ShadeModel    : TShadeModel read FShadeModel write SetShadeModel;

   property Zoom          : extended  read FZoom write SetZoom;

   property OnPaint       : TNotifyEvent read FOnPaint write FOnPaint;

   property OnChangeWindow: TChangeWindow read FChangeWindow write FChangeWindow;

end;

 

TALOpenGL = class(TALBaseOpenGL)

private

public

   procedure Paint; override;

published

   property OnPaint;

   property CentralCross;

   Property ClearColor;

   property RotAngle;

   property ShadeModel;

   property Zoom;

   property OnChangeWindow;

   property Align;

   property Enabled;

   property OnClick;

   property OnDockDrop;

   property OnDockOver;

   property OnEnter;

   property OnExit;

   property OnGetSiteInfo;

   property OnKeyDown;

   property OnKeyPress;

   property OnKeyUp;

   property OnMouseDown;

   property OnMouseMove;

   property OnMouseUp;

   property OnMouseWheel;

   property OnMouseWheelDown;

   property OnMouseWheelUp;

   property OnResize;

   property OnUnDock;

end;

 

 

 

procedure Register;

function ColorToSzin(c:TColor):TSzin;

 

implementation

 

procedure Register;

begin

RegisterComponents('AL', [TALOpenGl]);

end;

 

constructor TALBaseOpenGL.Create(AOwner: TComponent);

begin

inherited Create(AOwner);

OpenGL_OK      := False;

BackBMP        := TBitmap.Create;

width          := 200;

height         := 200;

OrtoLeft       := -100;

OrtoRight      := 100;

OrtoBottom     := -100;

OrtoTop        := 100;

fClearColor    := clBlack;

FCentralCross  := True;

FCentrum       := Point2d(0,0);

FZoom          := 2.0;

FShadeModel    := smSmooth;

FRotAngle      := 0;

DoubleBuffered := True;

TabStop        := True;

end;

 

destructor TALBaseOpenGL.Destroy;

begin

Try

BackBMP.Free;

wglMakeCurrent(0, 0);

wglDeleteContext(hrc);

inherited Destroy;

except

end;

end;

 

procedure TALBaseOpenGL.StartOpengl;

begin

Try

DC := GetDC(Handle);

 

SetDCPixelFormat;

hrc := wglCreateContext(DC);

wglMakeCurrent(DC, hrc);

 

glShadeModel(GL_SMOOTH);

glEnable(GL_TEXTURE_2D);

glEnable(GL_ALPHA_TEST);

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_COLOR,GL_SRC_COLOR);

 

glMatrixMode(GL_PROJECTION);

glViewport(0, 0, Width, Height);

 

OpenGL_OK  := True;

ClearColor := fClearColor;

except

OpenGL_OK  := False;

Application.MessageBox('OpenGL cannot initialised!','OpenGl Error',IDOK);

end;

end;

 

procedure TALBaseOpenGL.SetDCPixelFormat;

var

nPixelFormat: Integer;

pfd: TPixelFormatDescriptor;

begin

FillChar(pfd, SizeOf(pfd), 0);

 

with pfd do begin

   nSize     := sizeof(pfd);

   nVersion  := 1;

   dwFlags   := PFD_DRAW_TO_WINDOW or

                PFD_SUPPORT_OPENGL or

                PFD_DOUBLEBUFFER;

   iPixelType:= PFD_TYPE_RGBA;

   cColorBits:= 16;

   cDepthBits:= 16;

   iLayerType:= PFD_MAIN_PLANE;

end;

 

nPixelFormat := ChoosePixelFormat(DC, @pfd);

SetPixelFormat(DC, nPixelFormat, @pfd);

end;

 

(*

procedure TALBaseOpenGL.Paint;

var

ps : TPaintStruct;

begin

If Assigned(FOnPaint) then

    FOnPaint(Self);

end;

*)

 

procedure TALBaseOpenGL.ReDraw;

begin

if not OpenGL_OK then StartOpengl;

    glViewport(0,0,width ,height);

    glMatrixMode(GL_PROJECTION);

    glLoadIdentity;

    gluOrtho2D(OrtoLeft, OrtoRight, OrtoBottom, OrtoTop);

    glMatrixMode(GL_MODELVIEW);

    glDrawBuffer(GL_BACK);

glClear (GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT);

Paint;

end;

 

procedure TALBaseOpenGL.Demo;

begin

     glBegin(GL_POLYGON);

       glColor3d(1.0,0.0,0.0);

       glVertex2d(-30.0,-30.0);

 

       glColor3d(0.0,1.0,0.0);

       glVertex2d(30.0,-30.0);

 

       glColor3d(0.0,0.0,1.0);

       glVertex2d(30.0,30.0);

 

       glColor3d(1.0,1.0,1.0);

       glVertex2d(-30.0,30.0);

    glEnd;

    glBegin(GL_POLYGON);

       glColor4d(1.0,0.0,0.0,1.0);

       glVertex2d(0.0,-30.0);

 

       glColor4d(0.0,0.0,1.0,1.0);

       glVertex2d(30.0,0.0);

 

       glColor4d(1.0,1.0,0.0,1.0);

       glVertex2d(10.0,10.0);

 

       glColor4d(1.0,0.0,1.0,1.0);

       glVertex2d(0.0,30.0);

 

       glColor4d(0.0,0.5,1.0,1.0);

       glVertex2d(-10.0,10.0);

 

       glColor4d(5.0,0.5,0.0,1.0);

       glVertex2d(-30.0,0.0);

    glEnd;

       //INNEN LESZ A KIRAJZOLAS

    glFlush;

end;

 

procedure TALBaseOpenGL.WMPaint(var Msg: TWMPaint);

begin

ReDraw;

end;

 

procedure TALBaseOpenGL.SetClearColor(const Value: TColor);

Var szin: TSzin;

begin

FClearColor := Value;

If not OpenGL_OK then exit;

szin:=ColorToSzin(Value);

glClearcolor(szin.R,szin.G,szin.B,0);

glClear (GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT);

invalidate;

end;

 

procedure TALBaseOpenGL.MouseDown(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer);

begin

origin:=Point(x,y);

oldmovept:=origin;

inherited MouseDown(Button, Shift, X, Height-Y);

end;

 

procedure TALBaseOpenGL.MouseMove(Shift: TShiftState; X, Y: Integer);

var

dx,dy: GLDouble;

S: string;

begin

MovePt:=Point(x,y);

 

{ Moving graphic with pressed left mouse button }

IF Shift=[ssLeft] then

begin

   // Pontosítani kell a képleteken !!!!!!!!

   if RotAngle=0 then begin

      dx := (oldMovePt.x-MovePt.x)/FZoom;

      dy := (oldMovePt.y-MovePt.y)/FZoom;

      Centrum := Point2d(FCentrum.x+dx,FCentrum.y-dy);

   end else begin

      dx := (Width/2)+(oldMovePt.x-MovePt.x);

      dy := (Height/2)-(oldMovePt.y-MovePt.y);

      Centrum := SToW(Point(Round(dx),Round(dy)));

//    ShiftWindow(dx,dy);

   end;

end;

 

{ Magnifying graphic with pressed right mouse button }

IF Shift=[ssRight] then

begin

   if oldMovePt.y<>MovePt.y then

      if oldMovePt.y>MovePt.y then

         Zoom := Zoom*1.1

      else

         Zoom := Zoom*0.9;

end;

 

oldMovePt := MovePt;

 

inherited MouseMove(Shift,x,Height-y);

end;

 

procedure TALBaseOpenGL.MouseUp(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer);

begin

Inherited MouseUp(Button,Shift,X, Y);

end;

 

procedure TALBaseOpenGL.KeyDown(var Key: Word;Shift: TShiftState);

var zFactor: double;

begin

if Shift=[ssCtrl] then zFactor:=1.1

else zFactor:=2;

Case Key of

VK_ADD     : begin Zoom:=zFactor*Zoom;end;

VK_SUBTRACT: begin Zoom:=1/zFactor*Zoom;end;

VK_SPACE   : RotAngle := 0;

end;

inherited KeyDown(Key,Shift);

end;

 

procedure TALBaseOpenGL.KeyPress(var Key: Char);

begin

Case Key of

'K','k' : CentralCross:=not CentralCross;

^C : CopyToClipboard;

'L','l' : RotAngle := FRotAngle+1;

'R','r' : RotAngle := FRotAngle-1;

'F','f' : RotAngle := FRotAngle+1;

end;

inherited KeyPress(Key);

end;

 

function ColorToSzin(c:TColor):TSzin;

begin

With Result do begin

R:=GetRValue(c)/255;

G:=GetGValue(c)/255;

B:=GetBValue(c)/255;

end;

end;

 

procedure TALBaseOpenGL.SetZoom(const Value: extended);

var wx,hx: GLDouble;

begin

//  IF Value>16000 then FZoom:=16000 else

FZoom := Value;

if OpenGL_OK then

Try

wx := (Width/2)/FZoom;

hx := (Height/2)/FZoom;

OrtoLeft   := FCentrum.x - wx;

OrtoRight  := FCentrum.x + wx;

OrtoBottom := FCentrum.y - hx;

OrtoTop    := FCentrum.y + hx;

If Assigned(FChangeWindow) then FChangeWindow(Self,FCentrum,FZoom);

invalidate;

EXCEPT

end;

end;

 

procedure TALBaseOpenGL.CMChildkey(var msg: TCMChildKey);

var dx,dy: integer;

   k:integer;

begin

k:=16;

dx := 0; dy:=0;

msg.result := 1; // declares key as handled

Case msg.charcode of

   VK_ADD     : Zoom:=2*Zoom;

   VK_SUBTRACT: Zoom:=0.5*Zoom;

   VK_LEFT    : dx:=-k;

   VK_RIGHT   : dx:=k;

   VK_UP      : dy:=-k;

   VK_DOWN    : dy:=k;

Else

   msg.result:= 0;

   inherited;

End;

if (dx<>0) or (dy<>0) then

    ShiftWindow(dx,dy);

end;

 

procedure TALBaseOpenGL.WMSize(var Msg: TWMSize);

var w,h: GLDouble;

   wx,hx: GLDouble;

begin

Try

w  := Msg.Width;

h  := Msg.Height;

wx := (w/2)/FZoom;

hx := (h/2)/FZoom;

OrtoLeft   := FCentrum.x - wx;

OrtoRight  := FCentrum.x + wx;

OrtoBottom := FCentrum.y - hx;

OrtoTop    := FCentrum.y + hx;

BackBMP.Width := Msg.Width;

BackBMP.height := Msg.Height;

ReDraw;

except

end;

end;

 

procedure TALBaseOpenGL.SetCentrum(const Value: TPoint2d);

var wx,hx: GLDouble;

begin

FCentrum := Value;

wx := (Width/2)/FZoom;

hx := (Height/2)/FZoom;

OrtoLeft   := Value.x - wx;

OrtoRight  := Value.x + wx;

OrtoBottom := Value.y - hx;

OrtoTop    := Value.y + hx;

ReDraw;

If Assigned(FChangeWindow) then FChangeWindow(Self,FCentrum,FZoom);

end;

 

procedure TALBaseOpenGL.SetShadeModel(const Value: TShadeModel);

begin

if OpenGL_OK then

Try

FShadeModel := Value;

Case Value of

smFlat   : glShadeModel(GL_FLAT);

smSmooth : glShadeModel(GL_SMOOTH);

end;

invalidate;

except

end;

end;

 

procedure TALBaseOpenGL.SetCentralCross(const Value: boolean);

begin

FCentralCross := Value;

invalidate;

end;

 

procedure TALBaseOpenGL.DrawCentralCross;

var atlo: double;

begin

    atlo := RelDist2D(FCentrum,Point2d(OrtoRight,OrtoTop));

       glLineWidth(1);

       glBegin(GL_LINES);

         glColor3d(1.0,0.0,0.0);

         glVertex2d(FCentrum.x,OrtoTop);

         glVertex2d(FCentrum.x,OrtoBottom);

         glVertex2d(OrtoLeft,FCentrum.y);

         glVertex2d(OrtoRight,FCentrum.y);

       glEnd;

end;

 

function TALBaseOpenGL.SToW(p: TPoint): TPoint2d;

begin

Result := Point2d(XToW(p.x),YToW(p.y));

if FRotAngle<>0 then

RelRotate2D(Result,FCentrum,DegToRad(-FRotAngle));

end;

 

function TALBaseOpenGL.WToS(p: TPoint2d): TPoint;

begin

if FRotAngle<>0 then

RelRotate2D(p,FCentrum,DegToRad(FRotAngle));

Result := Point(XToS(p.x),YToS(p.y));

end;

 

function TALBaseOpenGL.XToS(x: double): integer;

var asp: double;

begin

asp := Width/Height;

Result := Trunc(asp*Width/2+(x-FCentrum.x)*FZoom);

end;

 

function TALBaseOpenGL.YToS(y: double): integer;

//var asp: double;

begin

//  asp := Width/Height;

Result := Trunc((Height/2+(y-FCentrum.y)*FZoom));

end;

 

function TALBaseOpenGL.XToW(x: integer): double;

begin

Result := FCentrum.x+(x-Width/2)/FZoom;

end;

 

function TALBaseOpenGL.YToW(y: integer): double;

begin

Result := FCentrum.y+(y-Height/2)/FZoom;

end;

 

procedure TALBaseOpenGL.MoveWindow(x, y: double);

begin

Centrum := Point2d(Centrum.x-x,Centrum.y-y);

end;

 

procedure TALBaseOpenGL.ShiftWindow(x, y: double);

var dx,dy : double;

begin

//  Centrum := Point2d(FCentrum.x+(x/FZoom),FCentrum.y+(y/FZoom));

   dx := (Width/2)+x;

   dy := (Height/2)-y;

   Centrum := SToW(Point(Round(dx),Round(dy)));

end;

 

procedure TALBaseOpenGL.DblClick;

begin

Centrum := SToW(Point(Origin.x,Height-Origin.y));

inherited;

end;

 

function TALBaseOpenGL.GetTotalMapArea: TRect2d;

begin

end;

 

function TALBaseOpenGL.GetWorkArea: TRect2d;

begin

With Result do begin

      x1:=OrtoLeft;

      x2:=OrtoRight;

      y1:=OrtoBottom;

      y2:=OrtoTop;

end;

end;

 

procedure TALBaseOpenGL.CMMouseEnter(var msg: TMessage);

begin

TabStop:=True;

Setfocus;

end;

 

procedure TALBaseOpenGL.CMMouseLeave(var msg: TMessage);

begin

TabStop:=False;

end;

 

function TALBaseOpenGL.DoMouseWheel(Shift: TShiftState;

WheelDelta: Integer; MousePos: TPoint): Boolean;

begin

Result := inherited DoMouseWheel(Shift, WheelDelta, MousePos);

if Focused then

if WheelDelta<0 then Zoom:=0.9*Zoom  else Zoom:=1.1*Zoom;

end;

 

function TALBaseOpenGL.DoMouseWheelDown(Shift: TShiftState;

MousePos: TPoint): Boolean;

begin

Result := inherited DoMouseWheelDown(Shift, MousePos);

end;

 

function TALBaseOpenGL.DoMouseWheelUp(Shift: TShiftState;

MousePos: TPoint): Boolean;

begin

Result := inherited DoMouseWheelUp(Shift, MousePos);

end;

 

function TALBaseOpenGL.GetCanvas: TCanvas;

begin

Result := inherited Canvas;

end;

 

procedure TALBaseOpenGL.WMEraseBkGnd(var Message: TWMEraseBkGnd);

begin

Message.Result := 1

end;

 

procedure TALBaseOpenGL.SBI;

begin

StretchBlt(BackBMP.Canvas.Handle,0,0,width,Height,

            Canvas.handle,0,0,width,Height,SRCCOPY)

end;

 

procedure TALBaseOpenGL.LBI;

begin

StretchBlt(Canvas.Handle,0,0,width,Height,

            BackBMP.Canvas.handle,0,0,width,Height,SRCCOPY)

end;

 

procedure TALBaseOpenGL.SetRotAngle(const Value: double);

begin

FRotAngle := Value; //CorrectAngle(Value);

rSIN := SIN(DegToRad(FRotAngle)); rCOS := COS(DegToRad(FRotAngle));

invalidate;

end;

 

procedure TALBaseOpenGL.glCircle(u, v, r: double);

var i: integer;

begin

glBegin(GL_LINE_STRIP);

   For i:=0 to 360 do

       glVertex2d(u+r*cos(DegToRad(i)),v+r*sin(DegToRad(i)));

glEnd;

end;

 

procedure TALBaseOpenGL.glRectangle(p1, p2, p3, p4: TPoint2d);

begin

glBegin(GL_LINES);

   glVertex2d(p1.x,p1.y);

   glVertex2d(p2.x,p2.y);

   glVertex2d(p3.x,p3.y);

   glVertex2d(p4.x,p4.y);

glEnd;

end;

 

procedure TALBaseOpenGL.glRectangle(p: TPoint2d; a, b: double);

begin

glBegin(GL_LINE_STRIP);

   glVertex2d(p.x-a/2,p.y+b/2);

   glVertex2d(p.x+a/2,p.y+b/2);

   glVertex2d(p.x+a/2,p.y-b/2);

   glVertex2d(p.x-a/2,p.y-b/2);

   glVertex2d(p.x-a/2,p.y+b/2);

glEnd;

end;

 

procedure TALBaseOpenGL.glPrint(text: string);

begin

 

end;

 

procedure DrawText(x,y:glFloat; s:string);

var i:integer;

begin

glpushmatrix;

gldisable(GL_DEPTH_TEST);

glRasterPos2f(x, y);

for i := 1 to length(s) do begin

//    glutBitmapCharacter(1,ord(s[i]));

end;

glEnable(GL_DEPTH_TEST);

glpopmatrix;

end;

 

 

 

procedure TALBaseOpenGL.CopyToClipboard;

begin

SBI;

Clipboard.Assign(BackBMP);

end;

 

(*

function TALBaseOpenGL.CreateTexture(Texture : String): cardinal;

var

bitmap: TBitmap;

Picture:TJpegImage;

BMInfo : TBitmapInfo;

I,ImageSize : Integer;

Temp : Byte;

MemDC : HDC;

Tex: PPixelArray;

begin

glGenTextures(1, @Result);

glBindTexture(GL_TEXTURE_2D, Result);

Picture:=TJpegImage.Create;

Picture.LoadFromFile('Texture.jpg');

 

Bitmap:=TBitMap.Create;

BitMap.Assign(Picture);

with BMinfo.bmiHeader do begin

   FillChar (BMInfo, SizeOf(BMInfo), 0);

   biSize := sizeof (TBitmapInfoHeader);

   biBitCount := 24;

   biWidth := Bitmap.Width;

   biHeight := Bitmap.Height;

   ImageSize := biWidth * biHeight;

   biPlanes := 1;

   biCompression := BI_RGB;

 

   MemDC := CreateCompatibleDC (0);

   GetMem (Tex, ImageSize *3);

       try

     GetDIBits (MemDC, Bitmap.Handle, 0, biHeight, Tex, BMInfo, DIB_RGB_COLORS);

     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);

     glTexImage2d(GL_TEXTURE_2D, 0, 3, biwidth, biheight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, tex);

     For I := 0 to ImageSize - 1 do begin

         Temp := tex [I * 3];

         tex [I * 3] := tex [I * 3 + 2];

         tex [I * 3 + 2] := Temp;

     end;

    finally

     DeleteDC (MemDC);

     Bitmap.Free;

     Picture.Free;

     freemem(tex);

  end;

end;

end;

 

function TALBaseOpenGL.LoadGLTextures : boolean;

begin

Texture:=CreateTexture('Texture.jpg');

LoadGLTextures := True;

end;

*)

{ TALOpenGL }

 

procedure TALOpenGL.Paint;

begin

glClear(GL_COLOR_BUFFER_BIT);

Demo;

If componentstate=[csDesigning] then Demo

else begin

    glPushMatrix;

    If Assigned(FOnPaint) then FOnPaint(Self);

    glPopMatrix;

end;

if FCentralCross then DrawCentralCross;

end;

 

initialization

InitOpenGL;

end.