0% found this document useful (0 votes)
36 views4 pages

Додаток 3

The document is a Delphi unit that defines a form for OpenGL rendering. It includes procedures for creating and destroying the OpenGL context, as well as painting a circle and coordinate axes with arrows. The rendering is done using OpenGL functions to draw shapes and lines on the form.

Uploaded by

Pro STOY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

Додаток 3

The document is a Delphi unit that defines a form for OpenGL rendering. It includes procedures for creating and destroying the OpenGL context, as well as painting a circle and coordinate axes with arrows. The rendering is done using OpenGL functions to draw shapes and lines on the form.

Uploaded by

Pro STOY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

unit Unit1;

interface

uses

Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,

Vcl.Controls, Vcl.Forms, Vcl.Dialogs, StdCtrls, ExtCtrls, opengl;

type

TForm1 = class(TForm)

procedure FormCreate(Sender: TObject);

procedure FormDestroy(Sender: TObject);

procedure The_FormPaint(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

hrc: HGLRC;

end;

var

Form1: TForm1;

x:double ;

y:double;

Fi:double;

implementation

{$R *.dfm}

procedure SetDCPixelFOrmat (hdc: HDC);

var pfd: TPixelFormatDescriptor;

nPixelFormat: integer;
begin

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

nPixelFormat:=ChoosePixelFormat(hdc, @pfd);

SetPixelFormat(hdc, nPixelFormat, @pfd);

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

SetDCPixelFormat(Canvas.Handle);

hrc:=wglCreateContext(Canvas.Handle);

end;

procedure TForm1.The_FormPaint (Sender: TObject);

begin

wglMakeCurrent(Canvas.Handle, hrc);

{коло}

glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();

glScaled(0.5, 1, 0.5);

glEnable(GL_LINE_SMOOTH);

glEnable(GL_LINE_STIPPLE);

glColor3d(1, 0, 0);

glLineStipple(2, $FFFF);

glLineWidth(1);

glBegin(GL_LINE_LOOP);

Fi:=0;

while Fi<=2*Pi do begin

glVertex2d(cos(Fi), sin(Fi));

Fi:=Fi+Pi/100;

end;

glEnd;
{стрілки}

glColor3d(1, 1, 1);

glLineWidth(1);

glDisable(GL_LINE_STIPPLE);

glBegin(GL_LINES);

glVertex2d(1, 0);

glVertex2d(0.8, 0.1);

glVertex2d(1, 0);

glVertex2d(0.8, -0.1);

glVertex2d(0, 1);

glVertex2d(-0.07, 0.67);

glVertex2d(0, 1);

glVertex2d(0.07, 0.67);

glEnd;

{ось кординат}

glColor3d(1, 1, 1);

glBegin(GL_LINES);

glVertex2d(0, -1);

glVertex2d(0, 1);

glVertex2d(-1, -0);

glVertex2d(1, 0);

glEnd;

glpopMatrix();
wglMakeCurrent(0, 0);

end;

procedure TForm1.FormDestroy(Sender: TObject);

begin

wglDeleteContext(hrc);

end;

end.

You might also like