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

Aktuelle Zeit: Fr Jul 18, 2025 00:14

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



Ein neues Thema erstellen Auf das Thema antworten  [ 9 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Fullscreen mit dglOpenGL
BeitragVerfasst: Mo Okt 04, 2004 13:42 
Offline
DGL Member

Registriert: So Okt 12, 2003 14:53
Beiträge: 74
Hi

Erstmal Sorry für die blöde Frage, aber ich finde leider nirgends infos darüber, wie man mit der dglOpenGL (die neuste) ein Fullscreen Mode einstellt.
Ich initialisiere das ganze Fenster zeugs so:

Code:
  1. InitOpenGL;
  2. // Gerätekontext holen
  3. DC := GetDC(Form1.Handle);
  4. // Renderkontext erstellen (32 Bit Farbtiefe, 24 Bit Tiefenpuffer, Doublebuffering)
  5. RC := CreateRenderingContext(DC, [opDoubleBuffered], 32, 24, 0, 0, 0, 0);
  6. // Erstellten Renderkontext aktivieren
  7. ActivateRenderingContext(DC, RC);


Das Tutorial hier auf der Seite bezieht sich ja auf eine andere OpenGL Unit.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Okt 04, 2004 13:47 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7810
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
Im DGL-SDK gabs ne Unit namens Fullscreen.pas. Die wird unter anderem in den Templates verwendet. Kannst dir ja einfach so ein Template ziehen und dann die Unit daraus nehmen.

Die Unit wurde von jemanden hier ausm Forum geschrieben. (Weiß jetzt nicht wers war :oops: )

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Okt 04, 2004 14:23 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Dez 28, 2002 11:13
Beiträge: 2244
Im Wesentlichen muß man einfach den Rahmen des Fensters entfernen (BorderStyle:=bsNone) und das Fenster genau an die Bildschirmgröße anpassen. Wenn man eine anderer Auflösung haben möchte, kann man die vorher mit ChangeDisplaySettings umstellen.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Okt 04, 2004 19:27 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Aug 28, 2002 19:27
Beiträge: 568
Wohnort: Chemnitz / Sachsen
@flash, naja wer wirds denn gewesen sein?? der große meister natürlich !!!!!!!

SOS !!!!!

_________________
Aktuelles Projekt :
www.PicPlace.de


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Okt 04, 2004 19:53 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Helios_GL.pas

Note: Opengl15 is dglOpenGL v1.4 renamed to OpenGL15
Note2: LaunchHelios is called after glcreatewnd, launchhelios shows the window and makes it fullscreen(if the user wants it to) when u have everything setup

Code:
  1.  
  2. unit Helios_GL;
  3.  
  4. interface
  5.  
  6. function glCreateWnd : Boolean;
  7. procedure glKillWnd(Fullscreen : Boolean);
  8. Procedure LaunchHelios;
  9. Procedure ChangeToFullScreen;
  10.  
  11. implementation
  12.  
  13. Uses Windows,Messages,Sysutils,OpenGL15, Helios_Global, Helios_Engine, Helios_CvarSystem,
  14.   Helios_Types;
  15.  
  16. Procedure CheckExtensions;
  17. begin
  18. ChangeCVar('Cg_MultiTexture',BoolToStr(GL_ARB_multitexture));
  19. end;
  20.  
  21. function WndProc(hWnd: HWND; Msg: UINT;  wParam: WPARAM;  lParam: LPARAM): LRESULT; stdcall;
  22. begin
  23.   result := 0;
  24.   if not Loaded then begin
  25.     Result := DefWindowProc(hWnd, Msg, wParam, lParam);    // Default result if nothing happens
  26.     exit;
  27.   end;
  28.  
  29.   case (Msg) of
  30.     WM_CREATE:
  31.       begin
  32.         // Insert stuff you want executed when the program starts
  33.       end;
  34.     WM_CLOSE:
  35.       begin
  36.         PostQuitMessage(0);
  37.         Result := 0
  38.       end;
  39.     WM_KEYDOWN:       // Set the pressed key (wparam) to equal true so we can check if its pressed
  40.       begin
  41. //      cons.AddMsg(inttostr(wParam));
  42.         keys[wParam] := True;
  43.         lastKeyPress := GetTickCount;
  44.         Result := 0;
  45.       end;
  46.     WM_KEYUP:         // Set the released key (wparam) to equal false so we can check if its pressed
  47.       begin
  48.         keys[wParam] := False;
  49.         Result := 0;
  50.       end;
  51.     WM_SIZE:          // Resize the window with the new width and height
  52.       begin
  53.         glResizeWnd(LOWORD(lParam),HIWORD(lParam));
  54.         Result := 0;
  55.       end;
  56.     WM_TIMER :                     // Add code here for all timers to be used.
  57.       begin
  58. //
  59.       end;
  60.     WM_RBUTTONDOWN :                                                    // If we hit the right mouse button
  61.       begin
  62. //
  63.       end;
  64.     WM_LBUTTONDOWN:                             // If we hit the left mouse button
  65.       begin
  66. //
  67.       end;
  68.     else
  69.       Result := DefWindowProc(hWnd, Msg, wParam, lParam);    // Default result if nothing happens
  70.   end;
  71. end;
  72.  
  73. procedure glKillWnd(Fullscreen : Boolean);
  74. begin
  75. OpenGLRunning := False;
  76.   if Fullscreen then begin            // Change back to non fullscreen
  77.     Q3levelLoaded := false;
  78.     ChangeDisplaySettings(devmode(nil^), 0);
  79.     ShowCursor(True);
  80.   end;
  81.  
  82.   // Makes current rendering context not current, and releases the device
  83.   // context that is used by the rendering context.
  84.   if (not wglMakeCurrent(h_DC, 0)) then
  85.     MessageBox(0, 'Release of DC and RC failed!', 'Error', MB_OK or MB_ICONERROR);
  86.  
  87.   // Attempts to delete the rendering context
  88.   if (not wglDeleteContext(h_RC)) then begin
  89.     MessageBox(0, 'Release of rendering context failed!', 'Error', MB_OK or MB_ICONERROR);
  90.     h_RC := 0;
  91.   end;
  92.  
  93.   // Attemps to release the device context
  94.   if ((h_DC > 0) and (ReleaseDC(h_Wnd, h_DC) = 0)) then begin
  95.     MessageBox(0, 'Release of device context failed!', 'Error', MB_OK or MB_ICONERROR);
  96.     h_DC := 0;
  97.   end;
  98.  
  99.   // Attempts to destroy the window
  100.   if ((h_Wnd <> 0) and (not DestroyWindow(h_Wnd))) then begin
  101.     MessageBox(0, 'Unable to destroy window!', 'Error', MB_OK or MB_ICONERROR);
  102.     h_Wnd := 0;
  103.   end;
  104.  
  105.   // Attempts to unregister the window class
  106.   if (not UnRegisterClass('OpenGL', hInstance)) then begin
  107.     MessageBox(0, 'Unable to unregister window class!', 'Error', MB_OK or MB_ICONERROR);
  108.     hInstance := 0;
  109.   end;
  110. end;
  111.  
  112. function glCreateWnd : Boolean;
  113. var
  114.   wndClass : TWndClass;         // Window class
  115.   dwStyle : DWORD;              // Window styles
  116.   dwExStyle : DWORD;            // Extended window styles
  117.   PixelFormat : GLuint;         // Settings for the OpenGL rendering
  118.   h_Instance : HINST;           // Current instance
  119.   pfd : TPIXELFORMATDESCRIPTOR;  // Settings for the OpenGL window
  120. begin
  121.   InitOpenGL;
  122.   SCREEN_WIDTH := HeliosSettings.Width;
  123.   SCREEN_HEIGHT := HeliosSettings.Height;
  124.  
  125.   AddToConsole('--- Creating Window ---');
  126.  
  127.   h_Instance := GetModuleHandle(nil);       //Grab An Instance For Our Window
  128.   ZeroMemory(@wndClass, SizeOf(wndClass));  // Clear the window class structure
  129.  
  130.   with wndClass do  begin                  // Set up the window class
  131.     style         := CS_HREDRAW or    // Redraws entire window if length changes
  132.                      CS_VREDRAW or    // Redraws entire window if height changes
  133.                      CS_OWNDC;        // Unique device context for the window
  134.     lpfnWndProc   := @WndProc;        // Set the window procedure to our func WndProc
  135.     hInstance     := h_Instance;
  136.     hCursor       := LoadCursor(0, IDC_ARROW);
  137.     hIcon         := LoadIcon(hInstance, 'MAINICON');
  138.     lpszClassName := 'OpenGL';
  139.   end;
  140.  
  141.   if (RegisterClass(wndClass) = 0) then  begin// Attemp to register the window class
  142.     AddToConsole('Failed to register the window class!');
  143.     Result := False;
  144.     Exit
  145.   end;
  146.  
  147.   AddToConsole('Registered Class...');
  148.  
  149.   //ChangeToFullScreen;
  150.  
  151.   // If we are still in fullscreen then
  152.   if (HeliosSettings.Fullscreen) then begin
  153.     dwStyle := WS_POPUP or                // Creates a popup window
  154.                WS_CLIPCHILDREN            // Doesn't draw within child windows
  155.                or WS_CLIPSIBLINGS;        // Doesn't draw within sibling windows
  156.     dwExStyle := 0;         // Top level window
  157.     //ShowCursor(false);                    // Turn of the cursor (gets in the way)
  158.   end
  159.   else begin
  160.        dwStyle := WS_OVERLAPPEDWINDOW or     // Creates an overlapping window
  161.                WS_CLIPCHILDREN or         // Doesn't draw within child windows
  162.                WS_CLIPSIBLINGS;           // Doesn't draw within sibling windows
  163.  
  164.     dwExStyle := WS_EX_APPWINDOW or       // Top level window
  165.                  WS_EX_WINDOWEDGE;        // Border with a raised edge
  166.     //ShowCursor(false);                    // Turn of the cursor (gets in the way)
  167.   end;
  168.  
  169.   // Attempt to create the actual window
  170.   h_Wnd := CreateWindowEx(dwExStyle,      // Extended window styles
  171.                           'OpenGL',       // Class name
  172.                           WND_TITLE,      // Window title (caption)
  173.                           dwStyle,        // Window styles
  174.                           0, 0,           // Window position
  175.                           HeliosSettings.Width, HeliosSettings.Height,  // Size of window
  176.                           0,              // No parent window
  177.                           0,              // No menu
  178.                           h_Instance,     // Instance
  179.                           nil);           // Pass nothing to WM_CREATE
  180.   if h_Wnd = 0 then begin
  181.     AddToConsole('Unable to create window!');
  182.     glKillWnd(False);                // Undo all the settings we've changed
  183.     Result := False;
  184.     Exit;
  185.   end;
  186.  
  187.   Loaded := True;
  188.  
  189.   AddToConsole('Window Created...');
  190.   AddToConsole('');
  191.   AddToConsole('--- Initalizing OpenGL ---');
  192.   // Try to get a device context
  193.   h_DC := GetDC(h_Wnd);
  194.   if (h_DC = 0) then begin
  195.     AddToConsole('Unable to get a device context!');
  196.     glKillWnd(False);
  197.     Result := False;
  198.     Exit;
  199.   end;
  200.  
  201.   AddToConsole('Got DC...');
  202.  
  203.   // Settings for the OpenGL window
  204.   with pfd do begin
  205.     nSize           := SizeOf(TPIXELFORMATDESCRIPTOR); // Size Of This Pixel Format Descriptor
  206.     nVersion        := 1;                    // The version of this data structure
  207.     dwFlags         := PFD_DRAW_TO_WINDOW    // Buffer supports drawing to window
  208.                        or PFD_SUPPORT_OPENGL // Buffer supports OpenGL drawing
  209.                        or PFD_DOUBLEBUFFER;  // Supports double buffering
  210.     iPixelType      := PFD_TYPE_RGBA;        // RGBA color format
  211.     cColorBits      := HeliosSettings.PixelDepth;           // OpenGL color depth
  212. //    cRedBits        := 0;                    // Number of red bitplanes
  213. //    cRedShift       := 0;                    // Shift count for red bitplanes
  214. //    cGreenBits      := 0;                    // Number of green bitplanes
  215. //    cGreenShift     := 0;                    // Shift count for green bitplanes
  216. //    cBlueBits       := 0;                    // Number of blue bitplanes
  217. //    cBlueShift      := 0;                    // Shift count for blue bitplanes
  218. //    cAlphaBits      := 0;                    // Not supported
  219. //    cAlphaShift     := 0;                    // Not supported
  220. //    cAccumBits      := 0;                    // No accumulation buffer
  221. //    cAccumRedBits   := 0;                    // Number of red bits in a-buffer
  222. //    cAccumGreenBits := 0;                    // Number of green bits in a-buffer
  223. //    cAccumBlueBits  := 0;                    // Number of blue bits in a-buffer
  224. //    cAccumAlphaBits := 0;                    // Number of alpha bits in a-buffer
  225.     cDepthBits      := HeliosSettings.TextureDepth;           // Specifies the depth of the depth buffer
  226.     cStencilBits    := HeliosSettings.StencilDepth ;                    // Turn off stencil buffer
  227. //    cAuxBuffers     := 0;                    // Not supported
  228.     iLayerType      := PFD_MAIN_PLANE;       // Ignored
  229. //    bReserved       := 0;                    // Number of overlay and underlay planes
  230. //    dwLayerMask     := 0;                    // Ignored
  231. //    dwVisibleMask   := 0;                    // Transparent color of underlay plane
  232. //    dwDamageMask    := 0;                     // Ignored
  233.   end;
  234.  
  235.   // Attempts to find the pixel format supported by a device context that is the best match to a given pixel format specification.
  236.   PixelFormat := ChoosePixelFormat(h_DC, @pfd);
  237.   if (PixelFormat = 0) then begin
  238.     AddToConsole('Unable to find a suitable pixel format');
  239.     glKillWnd(False);
  240.     Result := False;
  241.     Exit;
  242.   end;
  243.  
  244.   AddToConsole('Pixel Format ' + inttostr(PixelFormat) + ' Chosen');
  245.  
  246.   // Sets the specified device context's pixel format to the format specified by the PixelFormat.
  247.   if (not SetPixelFormat(h_DC, PixelFormat, @pfd)) then begin
  248.     AddToConsole('Unable to set the pixel format');
  249.     glKillWnd(False);
  250.     Result := False;
  251.     Exit;
  252.   end;
  253.  
  254.   AddToConsole('Pixel Format Set...');
  255.  
  256.   // Create a OpenGL rendering context
  257.   h_RC := wglCreateContext(h_DC);
  258.   if (h_RC = 0) then begin
  259.     AddToConsole('Unable to create an OpenGL rendering context');
  260.     glKillWnd(False);
  261.     Result := False;
  262.     Exit;
  263.   end;
  264.  
  265.   AddToConsole('OpenGL Rendering Context Created...');
  266.  
  267.   // Makes the specified OpenGL rendering context the calling thread's current rendering context
  268.   if (not wglMakeCurrent(h_DC, h_RC)) then begin
  269.     AddToConsole('Unable to activate OpenGL rendering context');
  270.     glKillWnd(False);
  271.     Result := False;
  272.     Exit;
  273.   end;
  274.   ActivateRenderingContext(h_DC, h_RC);
  275.  
  276.   AddToConsole('OpenGL Rendering Context Activated...');
  277.  
  278.   ReadExtensions;
  279.   ReadImplementationProperties;
  280.   CheckExtensions;
  281.   if GL_EXT_compiled_vertex_array then begin
  282.     LockingAvailable := true;
  283.  //   LockArrays := true;
  284.   end
  285.   else
  286.   LockArrays := False;
  287.  
  288.   // Ensure the OpenGL window is resized properly
  289.   glResizeWnd(HeliosSettings.Width, HeliosSettings.Height); // DOV !!!!!
  290.  
  291.   AddToConsole('Finished');
  292.   AddToConsole('');
  293.  
  294.   Result := True;
  295. end;
  296.  
  297. Procedure ChangeToFullScreen;
  298. var
  299. dmScreenSettings : DEVMODE;   // Screen settings (fullscreen, etc...)
  300. begin
  301.  
  302. // Change to fullscreen if so desired
  303.   if HeliosSettings.Fullscreen then begin
  304.     ZeroMemory(@dmScreenSettings, SizeOf(dmScreenSettings));
  305.     with dmScreenSettings do begin              // Set parameters for the screen setting
  306.       dmSize       := SizeOf(dmScreenSettings);
  307.       dmPelsWidth  := SCREEN_WIDTH;                    // Window width
  308.       dmPelsHeight := SCREEN_HEIGHT;                   // Window height
  309.       dmBitsPerPel := HeliosSettings.PixelDepth;               // Window color depth
  310.       dmFields     := DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL;
  311.     end;
  312.  
  313.     // Try to change screen mode to fullscreen
  314.     if (ChangeDisplaySettings(dmScreenSettings, CDS_FULLSCREEN) = DISP_CHANGE_FAILED) then begin
  315.       AddToConsole('Unable to switch to fullscreen!');
  316.       HeliosSettings.Fullscreen := False;
  317.     end;
  318.   end;
  319.  
  320. end;
  321.  
  322. Procedure LaunchHelios;
  323. begin
  324.  
  325. AddToConsole('');
  326. AddToConsole('Launching Helios...');
  327.  
  328. ShowCursor(false);
  329. ChangeToFullScreen;
  330. ShowWindow(h_Wnd, SW_SHOW);
  331. glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT);    // Clear The Screen And The Depth Buffer
  332. glClearColor(BGColor.X, BGColor.Y, BGColor.Z, 1.0);
  333. SwapBuffers(h_dc);
  334. SetForegroundWindow(h_Wnd);
  335. SetFocus(h_Wnd);
  336. SwapBuffers(h_dc);
  337.  
  338. SetCursorPos(SCREEN_WIDTH SHR 1, SCREEN_HEIGHT SHR 1); // Set the cursor to the middle, so it doesn't alter the view on the first frame!
  339.  
  340.  
  341. OpenGLRunning := True;
  342.  
  343. end;
  344.  
  345. end.
  346.  

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Okt 04, 2004 21:53 
Offline
Fels i.d. Brandung
Benutzeravatar

Registriert: Sa Mai 04, 2002 19:48
Beiträge: 3830
Wohnort: Tespe (nahe Hamburg)
Wie bereits indirekt gesagt wurde. OpenGL bietet keine Möglichkeit eines Fullscreens. Man muss auf eine entsprechende API des Systems zurückgreifen und das Fenster entsprechend präperieren. ChangeDisplaySettings für die WinAPI oder dem entsprechenden Flags (z.B. bei SDL). Bei Delphic VCL-Tutorials solltest Du entsprechende Beispiele für die WinAPI finden.

_________________
"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 Okt 05, 2004 13:35 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7810
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
Soll die UFullscreen nicht benutzt werden oder wieso sagt von euch niemand was dazu? :?

Oder war meine Ausführungen so vollständig und doll? 8) :lol:

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Okt 06, 2004 14:55 
Offline
DGL Member

Registriert: So Okt 12, 2003 14:53
Beiträge: 74
THX für die Antwort. Sorry das ich so lange nicht geantwortet habe. Ich habs jetzt mit der Fullscreen Unit gemacht.

Ich dachte ehrlich gesagt bis jetzt immer das diese Fullscreen Methode von OpenGL, bzw DirectX kommt :oops:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Okt 06, 2004 15:14 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 14, 2004 18:56
Beiträge: 804
Wohnort: GER/OBB/TÖL-WOR/Greiling
Ganz einfach gehts auch mit dem opengl1.5-template, das es hier zum donwnloaden gibt.

DArin ist unter anderem die prozedur

Code:
  1.  
  2. procedure TGLForm.GoToFullScreen(pWidth, pHeight, pBPP, pFrequency : Word);
  3. var
  4.  dmScreenSettings : DevMode;
  5. begin
  6. // Fenster vor Vollbild vorbereiten
  7. WindowState := wsMaximized;
  8. BorderStyle := bsNone;
  9. ZeroMemory(@dmScreenSettings, SizeOf(dmScreenSettings));
  10. with dmScreenSettings do
  11.  begin
  12.  dmSize              := SizeOf(dmScreenSettings);
  13.  dmPelsWidth         := pWidth;                    // Breite
  14.  dmPelsHeight        := pHeight;                   // Höhe
  15.  dmBitsPerPel        := pBPP;                      // Farbtiefe
  16.  dmDisplayFrequency  := pFrequency;                // Bildwiederholfrequenz
  17.  dmFields            := DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL or DM_DISPLAYFREQUENCY;
  18.  end;
  19. if (ChangeDisplaySettings(dmScreenSettings, CDS_FULLSCREEN) = DISP_CHANGE_FAILED) then
  20.  begin
  21.  MessageBox(0, 'Konnte Vollbildmodus nicht aktivieren!', 'Error', MB_OK or MB_ICONERROR);
  22.  exit
  23.  end;
  24.  
  25. FullScreenConsequences(pWidth,pHeight);
  26. end;
  27.  


die fullscreenconsequences sind von mir, kannst du rauslöschen.[/quote]

_________________
Bild

"User Error. Replace User and hit Continue."


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


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 5 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 ]