DEADSOFTWARE

Added check for support NPOT textures with OpenGL ES. Legacy mode is still bugged.
[d2df-sdl.git] / src / game / g_window.pas
index 7f542509b7b9febaf98200f072db129d08de578d..b83cdad7a0a97f93a48d80f4bd0f2d95b091c13c 100644 (file)
@@ -51,11 +51,7 @@ implementation
 
 uses
 {$IFDEF WINDOWS}Windows,{$ENDIF}
-{$IFDEF USE_NANOGL}
-  nanoGL,
-{$ELSE}
-  GL, GLExt,
-{$ENDIF}
+{$INCLUDE ../nogl/noGLuses.inc}
 {$IFDEF ENABLE_HOLMES}
   g_holmes, sdlcarcass, fui_ctls,
 {$ENDIF}
@@ -98,9 +94,15 @@ begin
   if (h_Wnd <> nil) then SDL_DestroyWindow(h_Wnd);
   if (h_GL <> nil) and (not preserveGL) then
   begin
+
 {$IFDEF USE_NANOGL}
     nanoGL_Destroy;
-{$ENDIF USE_NANOGL}
+{$ENDIF}
+
+{$IFDEF USE_NOGL}
+    nogl_Quit;
+{$ENDIF}
+
     SDL_GL_DeleteContext(h_GL);
   end;
   h_Wnd := nil;
@@ -564,6 +566,9 @@ begin
     e_WriteLog('nanoGL initialization error', TMsgType.Fatal);
     exit;
   end;
+{$ENDIF}
+{$IFDEF USE_NOGL}
+  nogl_Init;
 {$ENDIF}
   {$IFDEF ENABLE_HOLMES}
     if (assigned(oglInitCB)) then oglInitCB();
@@ -819,7 +824,7 @@ end;
 procedure InitOpenGL ();
 begin
 {$IF not DEFINED(HEADLESS)}
-  {$IFDEF USE_NANOGL}
+  {$IFDEF USE_GLES1}
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);    
@@ -1006,15 +1011,16 @@ begin
   e_LogWritefln('stencil buffer size: %s', [ltmp]);
   gwin_has_stencil := (ltmp > 0);
 
-  if not glHasExtension('GL_ARB_texture_non_power_of_two') then
+  if glHasExtension('GL_ARB_texture_non_power_of_two') or
+     glHasExtension('GL_OES_texture_npot') then
   begin
-    e_WriteLog('NPOT textures: NO', TMsgType.Warning);
-    glLegacyNPOT := true;
+    e_WriteLog('NPOT textures: YES', TMsgType.Notify);
+    glLegacyNPOT := false;
   end
   else
   begin
-    e_WriteLog('NPOT textures: YES', TMsgType.Notify);
-    glLegacyNPOT := false;
+    e_WriteLog('NPOT textures: NO', TMsgType.Warning);
+    glLegacyNPOT := true;
   end;
   gwin_dump_extensions := false;
 {$ENDIF}