Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Di Mär 19, 2024 09:02

Foren-Übersicht » Programmierung » OpenGL
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Autor Nachricht
 Betreff des Beitrags: OpenGL for Delphi 7 CLX
BeitragVerfasst: Mo Dez 07, 2020 11:50 
Offline
DGL Member

Registriert: Mo Dez 07, 2020 09:02
Beiträge: 1
Programmiersprache: Pascal
OpenGL for Delphi 7 CLX.
Rus:Знатоки.
Как нижеприведенный пример заставить работать в приложении CLX Delphi 7
Eng: Connoisseurs.
How to make the below example work in CLX Delphi 7 application
Code:
  1.  
  2. unit Unit1;
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, OpenGl, StdCtrls, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Timer1: TTimer;
  13.     procedure Button1Click(Sender: TObject);
  14.     procedure FormCreate(Sender: TObject);
  15.     procedure Timer1Timer(Sender: TObject);
  16.     procedure FormPaint(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.  
  20.     handleGL:HWND;
  21.     dc : HDC;
  22.     hrc: HGLRC;
  23.     ps : TPaintStruct;
  24.  
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.dfm}
  35. procedure SetDCPixelFormat (hdc : HDC);
  36.  
  37. var
  38.  
  39. pfd : TPixelFormatDescriptor;
  40.  
  41. nPixelFormat : Integer;
  42.  
  43. begin
  44.  
  45. FillChar (pfd, SizeOf (pfd), 0);
  46.  
  47. pfd.dwFlags :=PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
  48.  
  49. nPixelFormat :=ChoosePixelFormat (hdc, @pfd);
  50.  
  51. SetPixelFormat(hdc, nPixelFormat, @pfd);
  52.  
  53. end;
  54.  
  55. procedure TForm1.FormCreate(Sender: TObject);
  56. begin
  57. DC := GetDC (Handle);
  58. SetDCPixelFormat(DC);
  59. hrc := wglCreateContext(DC);
  60. wglMakeCurrent(DC, hrc);
  61. glClearColor (0.0, 0.0, 0.75, 1.0);
  62. glMatrixMode (GL_PROJECTION);
  63. glLoadIdentity;
  64. glFrustum (-1, 1, -1, 1, 2, 20);
  65. glMatrixMode (GL_MODELVIEW);
  66. glLoadIdentity;
  67. glTranslatef(0.0, 0.0, -6.0);
  68. end;
  69.  
  70.  
  71. procedure TForm1.Button1Click(Sender: TObject);
  72. begin
  73. glEnable (GL_LIGHTING);
  74.  
  75. glEnable (GL_LIGHT0);
  76.  
  77. glEnable (GL_DEPTH_TEST);
  78.  
  79. timer1.enabled:=true;
  80. end;
  81.  
  82.  
  83.  
  84. procedure TForm1.Timer1Timer(Sender: TObject);
  85. begin
  86. glRotatef(1.0, 1.0, 1.0, 1.0);
  87.  
  88. glRotatef(1.0, 1.0, 1.0, 0.0);
  89.  
  90. glRotatef(1.0, 1.0, 1.0, 1.0);
  91.  
  92. SwapBuffers(DC);
  93.  
  94. InvalidateRect(Handle, nil, False);
  95.  
  96. end;
  97.  
  98. procedure TForm1.FormPaint(Sender: TObject);
  99. var
  100. i,k:integer;
  101. begin
  102.  
  103. glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  104.  
  105. glBegin(GL_QUADS);
  106.  
  107. glNormal3f(0.0, 0.0, 1.0);
  108.  
  109. glVertex3f(1.0, 1.0, 1.0);
  110.  
  111. glVertex3f(-1.0, 1.0, 1.0);
  112.  
  113. glVertex3f(-1.0, -1.0, 1.0);
  114.  
  115. glVertex3f(1.0, -1.0, 1.0);
  116.  
  117. glEnd;
  118.  
  119. glBegin(GL_QUADS);
  120.  
  121. glNormal3f(-1.0, 0.0, 0.0);
  122.  
  123. glVertex3f(-1.0, 1.0, 1.0);
  124.  
  125. glVertex3f(-1.0, 1.0, -1.0);
  126.  
  127. glVertex3f(-1.0, -1.0, -1.0);
  128.  
  129. glVertex3f(-1.0, -1.0, 1.0);
  130.  
  131. glEnd;
  132.  
  133. glBegin(GL_QUADS);
  134.  
  135. glNormal3f(0.0, 1.0, 0.0);
  136.  
  137. glVertex3f(-1.0, 1.0, -1.0);
  138.  
  139. glVertex3f(-1.0, 1.0, 1.0);
  140.  
  141. glVertex3f(1.0, 1.0, 1.0);
  142.  
  143. glVertex3f(1.0, 1.0, -1.0);
  144.  
  145. glEnd;
  146.  
  147. glBegin(GL_QUADS);
  148.  
  149. glNormal3f(1.0, 0.0, -1.0);
  150.  
  151. glVertex3f(1.0, -1.0, -1.0);
  152.  
  153. glVertex3f(1.0, -1.0, 1.0);
  154.  
  155. glVertex3f(1.0, 1.0, 1.0);
  156.  
  157. glVertex3f(1.0, 1.0, -1.0);
  158.  
  159. glEnd;
  160.  
  161. glBegin(GL_QUADS);
  162.  
  163. glNormal3f(0.0, 0.0, -1.0);
  164.  
  165. glVertex3f(1.0, -1.0, 1.0);
  166.  
  167. glVertex3f(1.0, -1.0, -1.0);
  168.  
  169. glVertex3f(-1.0, -1.0, -1.0);
  170.  
  171. glVertex3f(-1.0, -1.0, 1.0);
  172.  
  173. glEnd;
  174. end;
  175.  
  176. end.
  177.  

RUS:
Даже простой пример ругается на ReleaseDC (Handle, dc); Да это и понятно.
Как реализовать Handle:HWND в ReleaseDC(), если в CLX property Handle: QOpenScrollViewH read GetHandle;.
Eng:
Even a simple example swears at ReleaseDC (Handle, dc); This is understandable.
How to implement Handle: HWND in ReleaseDC (), if in the CLX property Handle: QOpenScrollViewH read GetHandle ;.
Code:
  1.  
  2. nit Unit1;
  3.  
  4. interface
  5.  
  6. uses
  7.   SysUtils, Types, Classes, Variants, QTypes, QGraphics, QControls, QForms,
  8.   QDialogs, QStdCtrls, OpenGl,  QExtCtrls;
  9. type
  10.  HWND = type LongWord;
  11.  HDC = type LongWord;
  12.  BOOL = LongBool;
  13.   PPaintStruct = ^TPaintStruct;
  14.   {$EXTERNALSYM tagPAINTSTRUCT}
  15.   tagPAINTSTRUCT = packed record
  16.     hdc: HDC;
  17.     fErase: BOOL;
  18.     rcPaint: TRect;
  19.     fRestore: BOOL;
  20.     fIncUpdate: BOOL;
  21.     rgbReserved: array[0..31] of Byte;
  22.   end;
  23.   TPaintStruct = tagPAINTSTRUCT;
  24.   {$EXTERNALSYM PAINTSTRUCT}
  25.   PAINTSTRUCT = tagPAINTSTRUCT;
  26.  
  27.  
  28.  
  29.  
  30. type
  31.   TForm1 = class(TForm)
  32.     Button1: TButton;
  33.     procedure Button1Click(Sender: TObject);
  34.   private
  35.     { Private declarations }
  36.     handleGL:HWND;
  37.     dc : HDC;
  38.     hrc: HGLRC;
  39.     ps : TPaintStruct;
  40.  
  41.  
  42.   public
  43.     { Public declarations }
  44.   end;
  45. {$EXTERNALSYM FindWindow}
  46. function FindWindow(lpClassName, lpWindowName: PChar): HWND; stdcall;
  47. {$EXTERNALSYM GetDC}
  48. function GetDC(hWnd: HWND): HDC; stdcall;
  49. {$EXTERNALSYM Rectangle}
  50. function Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): BOOL; stdcall;
  51. {$EXTERNALSYM ReleaseDC}
  52. function ReleaseDC(hWnd: HWND; hDC: HDC): Integer; stdcall;
  53.  
  54. var
  55.   Form1: TForm1;
  56.  
  57.   function FindWindow; external 'user32.dll' name 'FindWindowA';
  58.   function GetDC; external 'user32.dll' name 'GetDC';
  59.   function Rectangle; external 'gdi32.dll' name 'Rectangle';
  60.   function ReleaseDC; external 'user32.dll' name 'ReleaseDC';
  61.  
  62. implementation
  63.  
  64. {$R *.xfm}
  65.  
  66. procedure TForm1.Button1Click(Sender: TObject);
  67. begin
  68. {Window}handleGL := FindWindow ('TForm1', 'Form1');
  69.   if handleGL <> 0 then
  70.   begin
  71.     dc := GetDC (handleGL);
  72.     Rectangle (dc, 10, 10, 110, 110);
  73.     ReleaseDC (HandleGL, dc);
  74.   end
  75. end;
  76.  
  77. end.
  78.  

Rus:
Ответы типа ссылки мне не нужны. Я весь интернет облазил.
В Delphi 7 VLC у меня отрисовка OpenGl нормально работает.
Проблему описал:
Даже простой пример ругается на ReleaseDC (Handle, dc);
Да это и понятно.
Как реализовать Handle:HWND в ReleaseDC(), если в CLX property Handle: QOpenScrollViewH read GetHandle;.

Нужен пример работающий в Delphi 7 CLX.

Eng:
I don't need link type answers. I covered the whole Internet.
In Delphi 7 VLC, OpenGl rendering works fine for me.
Described the problem:
Even a simple example swears at ReleaseDC (Handle, dc);
This is understandable.
How to implement Handle: HWND in ReleaseDC (), if in the CLX property Handle: QOpenScrollViewH read GetHandle;.

Need an example working in Delphi 7 CLX


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Foren-Übersicht » Programmierung » OpenGL


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 16 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.070s | 17 Queries | GZIP : On ]