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

Aktuelle Zeit: Di Mai 28, 2024 19:30

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



Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Mehrere OpenGL-Fenster
BeitragVerfasst: Sa Aug 10, 2002 15:28 
Hi,
ich hab mir ne Panel-Komponente mit zusätzlichen OpenGL-Funktionen gemacht, so dass ich das Panel nur noch auf das Form setzen brauch und die ganze Initialisierung vergessen kann. Kann ich jetzt mehrere Panel auf ein Form setzen und mit wglMakeCurrent zwischen den einzelnen Szenen in den verschiedenen Panels hin und her springen, oder gibt das Probleme?

Danke,
PentiumRaser


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Mehrere OpenGL-Fenster
BeitragVerfasst: Sa Aug 10, 2002 16:32 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 31, 2002 19:41
Beiträge: 1278
Wohnort: Bäretswil (Schweiz)
Programmiersprache: Pascal
Müsste funktionieren. :)

Jedes Panel muss einfach einen eigenen <span style='color:green'>HGLRC</span> haben.

_________________
OpenGL


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Mehrere OpenGL-Fenster
BeitragVerfasst: Sa Aug 10, 2002 16:52 
Ok, zwei fenster funktionieren, aber drei oder mehr nicht, warum?
Außerdem kann ich irgendwie nicht richtig hin und her springen, kann mir jemand helfen?

PentiumRaser


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Aug 10, 2002 17:15 
Offline
Fels i.d. Brandung
Benutzeravatar

Registriert: Sa Mai 04, 2002 19:48
Beiträge: 3827
Wohnort: Tespe (nahe Hamburg)
Bin mir nicht 100% sicher, was im Hintergrund abgeht, allerdings stell ich mir vor, dass die Grafikkarte beim hin und herschalten wohl doch recht beansprucht wird, vor allem wenn der Kontex neui erstellt wird. IMAO hat Sebo bereits damit etwas gemacht, ich´habe sowas bisher nicht ´gebraucht.

Was genau versuchst Du damit zu machen? Vielleicht gibt es ja auch einen elganteren Weg?

_________________
"Light travels faster than sound. This is why some people appear bright, before you can hear them speak..."


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Mehrere OpenGL-Fenster
BeitragVerfasst: Sa Aug 10, 2002 18:52 
Hi,
ich erstell den Kontext ja nur für jedes Panel einmal beim start, und dann will
ich per MakeCurrent zwischen den Kontexts wechseln.
Meine Idee war, das man dann ein grafisches Control macht, bei dem sich zum Beispiel die Schrift um die X-Achse dreht, wenn man den Mauszeiger über dem Control bewegt.

PentiumRaser


Nach oben
  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Aug 11, 2002 07:37 
Offline
Fels i.d. Brandung
Benutzeravatar

Registriert: Sa Mai 04, 2002 19:48
Beiträge: 3827
Wohnort: Tespe (nahe Hamburg)
Schreib Sebo mal an, IMAO hat er sich bisher damti am meisten befaßt. Vielleicht weiß er ne Lösung ;) Leider schon länger nicht mehr on, werde ihn sonst aucvh anschreiben ;)

_________________
"Light travels faster than sound. This is why some people appear bright, before you can hear them speak..."


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Aug 13, 2002 14:57 
Offline
DGL Member
Benutzeravatar

Registriert: Di Mai 14, 2002 21:07
Beiträge: 70
Wohnort: Heilbronn/Neckar
Sorry, der Router hier hat gesponnen :)

Also.. Wenn du für jedes Panel einen eigenen Kontext machst, müsste es eigentlich funktionieren.
Das wichtige ist, dass das Rendern immer nacheinander erfolgt.
Also:
Panel1
wglmakeCurrent...
Panel2
wglMakeCurrent...
usw...

Allerdings ist wglMakeCurrent relativ langsam, was schon bei 4 Ansichten zum Einfrieren des Computers führen kann...

Viel kann ich dir jetzt nicht helfen,da ich ja keinen Source habe :/
Aber du kannst dir mal die glWindow Komponente von Jason Allen runterladen, das dürfte genau das sein was du verwendest :) Ein Sample ist auch dabei... Ansonsten wie gesagt, Source wär nicht schlecht ;)

_________________
<a href='http://aefgames.thechaoscompany.net/' target='_blank'>Artificial Electronic Faction</a>


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Aug 14, 2002 21:03 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 31, 2002 19:41
Beiträge: 1278
Wohnort: Bäretswil (Schweiz)
Programmiersprache: Pascal
Ein Beispiel mit 3 Fenstern und 3 Threads.
Code:
  1. unit Unit1;
  2.  
  3.  
  4.  
  5. interface
  6.  
  7.  
  8.  
  9. uses
  10.  
  11.  &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  12.  
  13.  &nbsp;Dialogs, StdCtrls, ExtCtrls, OpenGL;
  14.  
  15.  
  16.  
  17. type
  18.  
  19.  &nbsp;TForm1 = class(TForm)
  20.  
  21.  &nbsp; &nbsp;Button1: TButton;
  22.  
  23.  &nbsp; &nbsp;Button2: TButton;
  24.  
  25.  &nbsp; &nbsp;Button3: TButton;
  26.  
  27.  &nbsp; &nbsp;Panel1: TPanel;
  28.  
  29.  &nbsp; &nbsp;Panel2: TPanel;
  30.  
  31.  &nbsp; &nbsp;Panel3: TPanel;
  32.  
  33.  &nbsp; &nbsp;procedure Button1Click(Sender: TObject);
  34.  
  35.  &nbsp; &nbsp;procedure FormCreate(Sender: TObject);
  36.  
  37.  &nbsp; &nbsp;procedure FormDestroy(Sender: TObject);
  38.  
  39.  &nbsp; &nbsp;procedure Button2Click(Sender: TObject);
  40.  
  41.  &nbsp; &nbsp;procedure Button3Click(Sender: TObject);
  42.  
  43.  &nbsp;private
  44.  
  45.  &nbsp; &nbsp;hrc1, hrc2, hrc3 : HGLRC;
  46.  
  47.  &nbsp; &nbsp;dc1, dc2, dc3 &nbsp; &nbsp;: hdc;
  48.  
  49.  &nbsp; &nbsp;procedure SetDCPixelFormat(Handle : HDC);
  50.  
  51.  &nbsp;public
  52.  
  53.  &nbsp;end;
  54.  
  55.  
  56.  
  57. type
  58.  
  59.  &nbsp;TFillMemoDemo = class(TThread)
  60.  
  61.  &nbsp;private
  62.  
  63.  &nbsp; &nbsp;Fwinkel : Single;
  64.  
  65.  &nbsp; &nbsp;Fdc &nbsp;: hdc;
  66.  
  67.  &nbsp; &nbsp;Fhrc : HGLRC;
  68.  
  69.  &nbsp; &nbsp;FData &nbsp;: string;
  70.  
  71.  &nbsp; &nbsp;FDelay : integer;
  72.  
  73.  &nbsp; &nbsp;procedure DrawScene;
  74.  
  75.  &nbsp;protected
  76.  
  77.  &nbsp; &nbsp;procedure Execute; override;
  78.  
  79.  &nbsp; &nbsp;procedure FillMemo;
  80.  
  81.  &nbsp;public
  82.  
  83.  &nbsp; &nbsp;constructor Create(
  84.  
  85.  &nbsp; &nbsp; &nbsp;const pdc &nbsp; : hdc;
  86.  
  87.  &nbsp; &nbsp; &nbsp;const phrc &nbsp;: HGLRC;
  88.  
  89.  &nbsp; &nbsp; &nbsp;const p_iDelay : integer);
  90.  
  91.  &nbsp;end;
  92.  
  93.  
  94.  
  95. var
  96.  
  97.  &nbsp;Form1: TForm1;
  98.  
  99.  &nbsp;MyThread1, MyThread2, MyThread3 : TFillMemoDemo;
  100.  
  101.  
  102.  
  103. implementation
  104.  
  105.  
  106.  
  107. {$R *.dfm}
  108.  
  109.  
  110.  
  111. procedure TForm1.SetDCPixelFormat(Handle: HDC);
  112.  
  113. var
  114.  
  115.  &nbsp;pfd: TPixelFormatDescriptor;
  116.  
  117.  &nbsp;nPixelFormat: Integer;
  118.  
  119. begin
  120.  
  121.  &nbsp;FillChar(pfd, SizeOf(pfd), 0);
  122.  
  123.  &nbsp;with pfd do begin
  124.  
  125.  &nbsp; &nbsp;nSize &nbsp; &nbsp; := sizeof(pfd); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Size of this structure
  126.  
  127.  &nbsp; &nbsp;nVersion &nbsp;:= 1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Version number
  128.  
  129.  &nbsp; &nbsp;dwFlags &nbsp; := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER; &nbsp;// Flags
  130.  
  131.  &nbsp; &nbsp;iPixelType:= PFD_TYPE_RGBA; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // RGBA pixel values
  132.  
  133.  &nbsp; &nbsp;cColorBits:= 24; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 24-bit color
  134.  
  135.  &nbsp; &nbsp;cDepthBits:= 32; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 32-bit depth buffer
  136.  
  137.  &nbsp; &nbsp;iLayerType:= PFD_MAIN_PLANE; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Layer type
  138.  
  139.  &nbsp;end;
  140.  
  141.  &nbsp;nPixelFormat := ChoosePixelFormat(Handle, @pfd);
  142.  
  143.  &nbsp;SetPixelFormat(Handle, nPixelFormat, @pfd);
  144.  
  145. end;
  146.  
  147.  
  148.  
  149. constructor TFillMemoDemo.Create;
  150.  
  151. begin
  152.  
  153.  &nbsp;inherited Create(False);
  154.  
  155.  &nbsp;Fwinkel &nbsp; &nbsp; &nbsp; &nbsp; := 0;
  156.  
  157.  &nbsp;Fdc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := pdc;
  158.  
  159.  &nbsp;Fhrc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= Phrc;
  160.  
  161.  &nbsp;FDelay &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= p_iDelay;
  162.  
  163.  &nbsp;FreeOnTerminate := true;
  164.  
  165.  &nbsp;Priority &nbsp; &nbsp; &nbsp; &nbsp;:= tpNormal;
  166.  
  167. end;
  168.  
  169.  
  170.  
  171. procedure TFillMemoDemo.DrawScene;
  172.  
  173. begin
  174.  
  175.  &nbsp;glLoadIdentity;
  176.  
  177.  &nbsp;glRotatef(Fwinkel, 0, 0, 1);
  178.  
  179.  &nbsp;glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  180.  
  181.  &nbsp;glBegin(GL_TRIANGLES);
  182.  
  183.  &nbsp; &nbsp;glColor3f(1.0, 0, 0);
  184.  
  185.  &nbsp; &nbsp;glVerTex2f(-0.5, -0.5);
  186.  
  187.  &nbsp; &nbsp;glColor3f(0, 1.0, 0);
  188.  
  189.  &nbsp; &nbsp;glVerTex2f(0.5, -0.5);
  190.  
  191.  &nbsp; &nbsp;glColor3f(0, 0, 1.0);
  192.  
  193.  &nbsp; &nbsp;glVerTex2f(-0, 0.5);
  194.  
  195.  &nbsp;glEnd;
  196.  
  197.  &nbsp;SwapBuffers(fDC);
  198.  
  199. end;
  200.  
  201.  
  202.  
  203. procedure TFillMemoDemo.FillMemo;
  204.  
  205. begin
  206.  
  207.  &nbsp;FWinkel := FWinkel + 2;
  208.  
  209.  &nbsp;if FWinkel >= 360 then FWinkel := 0;
  210.  
  211.  &nbsp;wglMakeCurrent(fdc, fhrc);
  212.  
  213.  &nbsp;DrawScene;
  214.  
  215.  &nbsp;wglMakeCurrent(0, 0);
  216.  
  217. end;
  218.  
  219.  
  220.  
  221. procedure TFillMemoDemo.Execute;
  222.  
  223. begin
  224.  
  225.  &nbsp;while not Terminated do
  226.  
  227.  &nbsp;begin
  228.  
  229.  &nbsp; &nbsp;Synchronize(FillMemo);
  230.  
  231.  &nbsp; &nbsp;Sleep(FDelay);
  232.  
  233.  &nbsp;end;
  234.  
  235. end;
  236.  
  237.  
  238.  
  239. procedure TForm1.Button1Click(Sender: TObject);
  240.  
  241. begin
  242.  
  243.  &nbsp;if Button1.Caption = 'Stop' then begin
  244.  
  245.  &nbsp; &nbsp;MyThread1.Terminate;
  246.  
  247.  &nbsp; &nbsp;Button1.Caption := 'Start';
  248.  
  249.  &nbsp;end else begin
  250.  
  251.  &nbsp; &nbsp;MyThread1 := TFillMemoDemo.Create(dc1, hrc1, 10);
  252.  
  253.  &nbsp; &nbsp;Button1.Caption := 'Stop';
  254.  
  255.  &nbsp;end;
  256.  
  257. end;
  258.  
  259.  
  260.  
  261. procedure TForm1.Button2Click(Sender: TObject);
  262.  
  263. begin
  264.  
  265.  &nbsp;if Button2.Caption = 'Stop' then begin
  266.  
  267.  &nbsp; &nbsp;MyThread2.Terminate;
  268.  
  269.  &nbsp; &nbsp;Button2.Caption := 'Start';
  270.  
  271.  &nbsp;end else begin
  272.  
  273.  &nbsp; &nbsp;MyThread2 := TFillMemoDemo.Create(dc2, hrc2, &nbsp;100);
  274.  
  275.  &nbsp; &nbsp;Button2.Caption := 'Stop';
  276.  
  277.  &nbsp;end;
  278.  
  279. end;
  280.  
  281.  
  282.  
  283. procedure TForm1.Button3Click(Sender: TObject);
  284.  
  285. begin
  286.  
  287.  &nbsp;if Button3.Caption = 'Stop' then begin
  288.  
  289.  &nbsp; &nbsp;MyThread3.Terminate;
  290.  
  291.  &nbsp; &nbsp;Button3.Caption := 'Start';
  292.  
  293.  &nbsp;end else begin
  294.  
  295.  &nbsp; &nbsp;MyThread3 := TFillMemoDemo.Create(dc3, hrc3, 500);
  296.  
  297.  &nbsp; &nbsp;Button3.Caption := 'Stop';
  298.  
  299.  &nbsp;end;
  300.  
  301. end;
  302.  
  303.  
  304.  
  305. procedure TForm1.FormCreate(Sender: TObject);
  306.  
  307. begin
  308.  
  309.  &nbsp;Button1.Caption := 'Start';
  310.  
  311.  &nbsp;Button2.Caption := 'Start';
  312.  
  313.  &nbsp;Button3.Caption := 'Start';
  314.  
  315.  &nbsp;dc1 := GetDC(Panel1.Handle);
  316.  
  317.  &nbsp;dc2 := GetDC(Panel2.Handle);
  318.  
  319.  &nbsp;dc3 := GetDC(Panel3.Handle);
  320.  
  321.  &nbsp;SetDCPixelFormat(dc1);
  322.  
  323.  &nbsp;SetDCPixelFormat(dc2);
  324.  
  325.  &nbsp;SetDCPixelFormat(dc3);
  326.  
  327.  &nbsp;hrc1 := wglCreateContext(dc1);
  328.  
  329.  &nbsp;hrc2 := wglCreateContext(dc2);
  330.  
  331.  &nbsp;hrc3 := wglCreateContext(dc3);
  332.  
  333. end;
  334.  
  335.  
  336.  
  337. procedure TForm1.FormDestroy(Sender: TObject);
  338.  
  339. begin
  340.  
  341.  &nbsp;wglDeleteContext(hrc1);
  342.  
  343.  &nbsp;wglDeleteContext(hrc2);
  344.  
  345.  &nbsp;wglDeleteContext(hrc3);
  346.  
  347. end;
  348.  
  349.  
  350.  
  351. end.
:D

_________________
OpenGL


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


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 3 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.009s | 14 Queries | GZIP : On ]