OpenGL Tutorial/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: OpenGL Tutorial/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## OpenGL Tutorial | |
| 2 | + | ||
| 3 | + | ### Modernes OpenGL ( ab Version 3.3 ) | |
| 4 | + | ||
| 5 | + | Da ich mein Tutorial nicht zweigleisig erstellen will, verlinke ich es. ;-) | |
| 6 | + | ||
| 7 | + | - [Lazarus OpenGL 3.3 - Tutorial](https://wiki.delphigl.com/index.php/Lazarus_-_OpenGL_3.3_Tutorial)- (deutsch) (extern) | |
| 8 | + | ||
| 9 | + | ### Beispiel in OpenGL ( veraltet ) | |
| 10 | + | ||
| 11 | + | Einfaches Beispiel welches ein Dreieck zeichnet. | |
| 12 | + | ||
| 13 | + | ``` pascal | |
| 14 | + | unit unit1; | |
| 15 | + | ||
| 16 | + | {$mode objfpc}{$H+} | |
| 17 | + | ||
| 18 | + | interface | |
| 19 | + | ||
| 20 | + | uses | |
| 21 | + | Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, | |
| 22 | + | ExtCtrls, OpenGLContext, gl; | |
| 23 | + | ||
| 24 | + | type | |
| 25 | + | TForm1 = class(TForm) | |
| 26 | + | Timer1: TTimer; | |
| 27 | + | procedure FormCreate(Sender: TObject); | |
| 28 | + | procedure Timer1Timer(Sender: TObject); | |
| 29 | + | private | |
| 30 | + | oglControl: TOpenGLControl; // Kontext für OpenGL | |
| 31 | + | end; | |
| 32 | + | ||
| 33 | + | var | |
| 34 | + | Form1: TForm1; | |
| 35 | + | ||
| 36 | + | implementation | |
| 37 | + | ||
| 38 | + | procedure TForm1.Timer1Timer(Sender: TObject); | |
| 39 | + | begin | |
| 40 | + | // Hintergrundfarbe | |
| 41 | + | glClearColor(0.8, 0.5, 0.3, 1.0); | |
| 42 | + | ||
| 43 | + | // Zeichenbuffer löschen | |
| 44 | + | glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); | |
| 45 | + | glEnable(GL_DEPTH_TEST); | |
| 46 | + | ||
| 47 | + | // Projectionsmatrix aktivieren | |
| 48 | + | glMatrixMode(GL_PROJECTION); | |
| 49 | + | glLoadIdentity; // Matrix zurücksetzten ( Einheitsmatrix ) | |
| 50 | + | // Hier kann die ProjectionsMatrix manipuliert werden. | |
| 51 | + | ||
| 52 | + | // Modelmatrix aktivieren | |
| 53 | + | glMatrixMode(GL_MODELVIEW); | |
| 54 | + | glLoadIdentity; | |
| 55 | + | ||
| 56 | + | // Dreieck drehen ( Winkel ist in Grad.) | |
| 57 | + | glRotatef(5.0, 0.0, 0.0, 1.0); | |
| 58 | + | ||
| 59 | + | // Zeichnet ein einfache Dreieck | |
| 60 | + | glBegin(GL_TRIANGLES); | |
| 61 | + | glColor3f(0.8, 0.0, 0.0); | |
| 62 | + | glVertex3f(0, 0.8, 0.0); | |
| 63 | + | glColor3f(0.0, 0.8, 0.0); | |
| 64 | + | glVertex3f(-0.8, -0.8, 0.0); | |
| 65 | + | glColor3f(0.0, 0.0, 0.8); | |
| 66 | + | glVertex3f(0.8, -0.8, 0.0); | |
| 67 | + | glEnd(); | |
| 68 | + | ||
| 69 | + | oglControl.SwapBuffers; | |
| 70 | + | end; | |
| 71 | + | ||
| 72 | + | procedure TForm1.FormCreate(Sender: TObject); | |
| 73 | + | begin | |
| 74 | + | Timer1.Interval := 40; | |
| 75 | + | ||
| 76 | + | // OpenGL Kontext erzeugen | |
| 77 | + | oglControl := TOpenGLControl.Create(Self); | |
| 78 | + | ||
| 79 | + | // Kontext auf Form-Client anpassen | |
| 80 | + | oglControl.Align := alClient; | |
| 81 | + | ||
| 82 | + | // Kontext mit Form verbinden. | |
| 83 | + | oglControl.Parent := Self; | |
| 84 | + | ||
| 85 | + | // Automatische Grössenanpassung | |
| 86 | + | oglControl.AutoResizeViewport := True; | |
| 87 | + | end; | |
| 88 | + | ||
| 89 | + | initialization | |
| 90 | + | ||
| 91 | + | {$I unit1.lrs} | |
| 92 | + | ||
| 93 | + | end. | |
| 94 | + | ``` | |
| 95 | + | ||
| 96 | + | --- | |
| 97 | + | *From the Free Pascal wiki, page "OpenGL Tutorial/de", as it stood on 2019-06-16 after a change by Mathias, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 98 | + | Category: Code | |
| 99 | + | Category: Graphics | |
| 100 | + | Category: OpenGL | |
| 101 | + | Category: Tutorials |
