69 implementation |
72 implementation |
70 uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands |
73 uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands |
71 , uPhysFSLayer |
74 , uPhysFSLayer |
72 , uDebug |
75 , uDebug |
73 {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
76 {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
74 {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
77 {$IF NOT DEFINED(SDL2) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
75 |
78 |
76 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple); |
79 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple); |
77 |
80 |
78 var MaxTextureSize: LongInt; |
81 var MaxTextureSize: LongInt; |
79 {$IFDEF SDL13} |
82 {$IFDEF SDL2} |
80 SDLwindow: PSDL_Window; |
83 SDLwindow: PSDL_Window; |
81 SDLGLcontext: PSDL_GLContext; |
84 SDLGLcontext: PSDL_GLContext; |
82 {$ELSE} |
85 {$ELSE} |
83 SDLPrimSurface: PSDL_Surface; |
86 SDLPrimSurface: PSDL_Surface; |
84 {$ENDIF} |
87 {$ENDIF} |
716 {$IFDEF IPHONEOS} |
719 {$IFDEF IPHONEOS} |
717 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); |
720 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); |
718 SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); |
721 SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); |
719 {$ELSE} |
722 {$ELSE} |
720 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
723 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
721 {$IFNDEF SDL13} // vsync is default in 1.3 |
724 {$ENDIF} |
|
725 {$IFNDEF SDL2} // vsync is default in SDL2 |
722 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, LongInt((cReducedQuality and rqDesyncVBlank) = 0)); |
726 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, LongInt((cReducedQuality and rqDesyncVBlank) = 0)); |
723 {$ENDIF} |
727 {$ENDIF} |
724 {$ENDIF} |
|
725 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); // no depth buffer |
|
726 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); |
728 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); |
727 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); |
729 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); |
728 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); |
730 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); |
729 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); // no alpha channel required |
731 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); // no depth buffer |
730 SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16); // buffer has to be 16 bit only |
732 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); // no alpha channel |
731 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // try to prefer hardware rendering |
733 SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16); // buffer should be 16 |
|
734 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // prefer hw rendering |
732 end; |
735 end; |
733 |
736 |
734 {$IFDEF GL2} |
737 {$IFDEF GL2} |
735 function CompileShader(shaderFile: string; shaderType: GLenum): GLuint; |
738 function CompileShader(shaderFile: string; shaderType: GLenum): GLuint; |
736 var |
739 var |
836 end; |
839 end; |
837 |
840 |
838 {$ENDIF} |
841 {$ENDIF} |
839 |
842 |
840 procedure SetupOpenGL; |
843 procedure SetupOpenGL; |
841 //var vendor: shortstring = ''; |
844 var name: array[byte] of char; |
842 var buf: array[byte] of char; |
845 AuxBufNum: LongInt = 0; |
843 {$IFDEF PAS2C}err: GLenum;{$ENDIF} |
|
844 {$IFDEF USE_VIDEO_RECORDING}AuxBufNum: LongInt;{$ENDIF} |
|
845 tmpstr: AnsiString; |
846 tmpstr: AnsiString; |
846 tmpint: LongInt; |
847 tmpint: LongInt; |
847 tmpn: LongInt; |
848 tmpn: LongInt; |
848 begin |
849 begin |
849 buf[0]:= char(0); // avoid compiler hint |
850 |
850 AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')'); |
851 {$IFDEF SDL2} |
851 |
852 name:= SDL_GetCurrentVideoDriver(); |
|
853 {$ELSE} |
|
854 name:= SDL_VideoDriverName(name, sizeof(name)); |
|
855 {$ENDIF} |
|
856 |
|
857 AuxBufNum:= AuxBufNum; |
|
858 AddFileLog('Setting up OpenGL (using driver: ' + shortstring(name) + ')'); |
|
859 |
|
860 {$IFDEF MOBILE} |
|
861 // TODO: this function creates an opengles1.1 context |
|
862 // un-comment below and add proper logic to support opengles2.0 |
|
863 //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
|
864 //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); |
|
865 if SDLGLcontext = nil then |
|
866 SDLGLcontext:= SDL_GL_CreateContext(SDLwindow); |
|
867 SDLTry(SDLGLcontext <> nil, true); |
|
868 SDL_GL_SetSwapInterval(1); |
|
869 {$ENDIF} |
|
870 |
|
871 // get the max (h and v) size for textures that the gpu can support |
|
872 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
|
873 if MaxTextureSize <= 0 then |
|
874 begin |
|
875 MaxTextureSize:= 1024; |
|
876 AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024'); |
|
877 end |
|
878 else if (MaxTextureSize < 1024) and (MaxTextureSize >= 512) then |
|
879 begin |
|
880 cReducedQuality := cReducedQuality or rqNoBackground; |
|
881 AddFileLog('Texture size too small for backgrounds, disabling.'); |
|
882 end; |
852 {$IFDEF WEBGL} |
883 {$IFDEF WEBGL} |
853 if OpenGLSetupedBefore then |
884 if OpenGLSetupedBefore then |
854 begin |
885 begin |
855 glViewport(0, 0, cScreenWidth, cScreenHeight); |
886 glViewport(0, 0, cScreenWidth, cScreenHeight); |
856 hglMatrixMode(MATRIX_MODELVIEW); |
887 hglMatrixMode(MATRIX_MODELVIEW); |
858 hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
889 hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
859 hglTranslatef(0, -cScreenHeight / 2, 0); |
890 hglTranslatef(0, -cScreenHeight / 2, 0); |
860 exit; |
891 exit; |
861 end |
892 end |
862 OpenGLSetupedBefore := true; |
893 OpenGLSetupedBefore := true; |
863 {$ENDIF} |
894 {$ELSE} |
864 |
895 // everyone loves debugging |
865 {$IFDEF SDL13} |
|
866 // this function creates an opengles1.1 context by default on mobile devices |
|
867 // unless you un-comment this two attributes |
|
868 //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
|
869 //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); |
|
870 if SDLGLcontext = nil then |
|
871 SDLGLcontext:= SDL_GL_CreateContext(SDLwindow); |
|
872 SDLTry(SDLGLcontext <> nil, true); |
|
873 SDL_GL_SetSwapInterval(1); |
|
874 {$ENDIF} |
|
875 |
|
876 // get the max (horizontal and vertical) size for textures that the gpu can support |
|
877 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
|
878 if MaxTextureSize <= 0 then |
|
879 begin |
|
880 MaxTextureSize:= 1024; |
|
881 AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024'); |
|
882 end |
|
883 else if (MaxTextureSize < 1024) and (MaxTextureSize >= 512) then |
|
884 begin |
|
885 cReducedQuality := cReducedQuality or rqNoBackground; |
|
886 AddFileLog('Texture size too small for backgrounds, disabling.'); |
|
887 end; |
|
888 |
|
889 (* |
|
890 // find out which gpu we are using (for extension compatibility maybe?) |
896 // find out which gpu we are using (for extension compatibility maybe?) |
891 {$IFDEF IPHONEOS} |
|
892 vendor:= vendor; // avoid hint |
|
893 cGPUVendor:= gvApple; |
|
894 {$ELSE} |
|
895 vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR)))); |
|
896 if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then |
|
897 cGPUVendor:= gvNVIDIA |
|
898 else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then |
|
899 cGPUVendor:= gvATI |
|
900 else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then |
|
901 cGPUVendor:= gvIntel |
|
902 else |
|
903 AddFileLog('OpenGL Warning - unknown hardware vendor; please report'); |
|
904 {$ENDIF} |
|
905 //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two'); |
|
906 *) |
|
907 |
|
908 // everyone love debugging |
|
909 AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); |
897 AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); |
910 AddFileLog(' |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR)))); |
898 AddFileLog(' |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR)))); |
911 AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); |
899 AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); |
912 AddFileLog(' |----- Texture Size: ' + inttostr(MaxTextureSize)); |
900 AddFileLog(' |----- Texture Size: ' + inttostr(MaxTextureSize)); |
913 {$IFDEF USE_VIDEO_RECORDING} |
901 {$IFDEF USE_VIDEO_RECORDING} |
914 glGetIntegerv(GL_AUX_BUFFERS, @AuxBufNum); |
902 glGetIntegerv(GL_AUX_BUFFERS, @AuxBufNum); |
915 AddFileLog(' |----- Number of auxiliary buffers: ' + inttostr(AuxBufNum)); |
903 AddFileLog(' |----- Number of auxiliary buffers: ' + inttostr(AuxBufNum)); |
916 {$ENDIF} |
904 {$ENDIF} |
917 {$IFDEF PAS2C} |
905 {$IFNDEF PAS2C} |
918 |
|
919 // doesn't seem to print >256 chars |
|
920 AddFileLogRaw(PChar(glGetString(GL_EXTENSIONS))); |
|
921 {$ELSE} |
|
922 AddFileLog(' \----- Extensions: '); |
906 AddFileLog(' \----- Extensions: '); |
923 |
907 |
924 // fetch extentions and store them in string |
908 // fetch extentions and store them in string |
925 tmpstr := StrPas(PChar(glGetString(GL_EXTENSIONS))); |
909 tmpstr := StrPas(PChar(glGetString(GL_EXTENSIONS))); |
926 tmpn := WordCount(tmpstr, [' ']); |
910 tmpn := WordCount(tmpstr, [' ']); |
1452 begin |
1437 begin |
1453 ArgCount:= 1; |
1438 ArgCount:= 1; |
1454 PrgName:= 'hwengine'; |
1439 PrgName:= 'hwengine'; |
1455 glutInit(@ArgCount, @PrgName); |
1440 glutInit(@ArgCount, @PrgName); |
1456 glutInitWindowSize(cScreenWidth, cScreenHeight); |
1441 glutInitWindowSize(cScreenWidth, cScreenHeight); |
1457 glutCreateWindow('hedgewars (you don''t see this)'); // we don't need a window, but if this function is not called then OpenGL will not be initialized |
1442 // we do not need a window, but without this call OpenGL will not initialize |
|
1443 glutCreateWindow('hedgewars video rendering (glut hidden window)'); |
1458 glutHideWindow(); |
1444 glutHideWindow(); |
1459 glutDisplayFunc(@SwapBuffers); // we don't need a callback, but it's required for GLUT3 |
1445 // we do not need to set this callback, but it is required for GLUT3 compat |
|
1446 glutDisplayFunc(@SwapBuffers); |
1460 SetupOpenGL(); |
1447 SetupOpenGL(); |
1461 end; |
1448 end; |
1462 {$ENDIF} // SDL13 |
1449 {$ENDIF} // SDL2 |
1463 {$ENDIF} // USE_VIDEO_RECORDING |
1450 {$ENDIF} // USE_VIDEO_RECORDING |
1464 |
1451 |
1465 procedure chFullScr(var s: shortstring); |
1452 procedure chFullScr(var s: shortstring); |
1466 var flags: Longword = 0; |
1453 var flags: Longword = 0; |
1467 reinit: boolean = false; |
1454 reinit: boolean = false; |
1468 {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF} |
1455 {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF} |
1469 {$IFDEF SDL13}x, y: LongInt;{$ENDIF} |
1456 {$IFDEF SDL2}x, y: LongInt;{$ENDIF} |
1470 begin |
1457 begin |
1471 if cOnlyStats then |
1458 if cOnlyStats then |
1472 begin |
1459 begin |
1473 MaxTextureSize:= 1024; |
1460 MaxTextureSize:= 1024; |
1474 exit |
1461 exit |
1475 end; |
1462 end; |
1476 if Length(s) = 0 then |
1463 if Length(s) = 0 then |
1477 cFullScreen:= (not cFullScreen) |
1464 cFullScreen:= (not cFullScreen) |
1478 else cFullScreen:= s = '1'; |
1465 else cFullScreen:= s = '1'; |
1479 |
1466 |
1480 if cFullScreen then |
1467 if cFullScreen then |
1481 begin |
1468 begin |
1482 cScreenWidth:= cFullscreenWidth; |
1469 cScreenWidth:= cFullscreenWidth; |
1483 cScreenHeight:= cFullscreenHeight; |
1470 cScreenHeight:= cFullscreenHeight; |
1484 end |
1471 end |
1523 glTranslatef(0, -cScreenHeight / 2, 0); |
1512 glTranslatef(0, -cScreenHeight / 2, 0); |
1524 glViewport(0, 0, cScreenWidth, cScreenHeight); |
1513 glViewport(0, 0, cScreenWidth, cScreenHeight); |
1525 exit; |
1514 exit; |
1526 {$ELSE} |
1515 {$ELSE} |
1527 SetScale(cDefaultZoomLevel); |
1516 SetScale(cDefaultZoomLevel); |
1528 {$IFDEF USE_CONTEXT_RESTORE} |
1517 {$IFDEF USE_CONTEXT_RESTORE} |
1529 reinit:= true; |
1518 reinit:= true; |
1530 StoreRelease(true); |
1519 StoreRelease(true); |
1531 ResetLand; |
1520 ResetLand; |
1532 ResetWorldTex; |
1521 ResetWorldTex; |
1533 //uTextures.freeModule; //DEBUG ONLY |
1522 //uTextures.freeModule; //DEBUG ONLY |
1534 {$ENDIF} |
1523 {$ENDIF} |
1535 AddFileLog('Freeing old primary surface...'); |
1524 AddFileLog('Freeing old primary surface...'); |
1536 {$IFNDEF SDL13} |
1525 {$IFNDEF SDL2} |
1537 {$IFNDEF WEBGL} |
1526 {$IFNDEF WEBGL} |
1538 SDL_FreeSurface(SDLPrimSurface); |
1527 SDL_FreeSurface(SDLPrimSurface); |
1539 SDLPrimSurface:= nil; |
1528 SDLPrimSurface:= nil; |
1540 {$ENDIF} |
1529 {$ENDIF} |
1541 {$ENDIF} |
1530 {$ENDIF} |
1542 {$ENDIF} |
1531 {$ENDIF} |
1543 end; |
1532 end; |
1544 |
1533 |
1545 // these attributes must be set up before creating the sdl window |
1534 // these attributes must be set up before creating the sdl window |
1546 {$IFNDEF WIN32} |
1535 {$IFNDEF WIN32} |
1547 (* On a large number of testers machines, SDL default to software rendering when opengl attributes were set. |
1536 (* On a large number of testers machines, SDL default to software rendering |
1548 These attributes were "set" after CreateWindow in .15, which probably did nothing. |
1537 when opengl attributes were set. These attributes were "set" after |
1549 IMO we should rely on the gl_config defaults from SDL, and use SDL_GL_GetAttribute to possibly post warnings if any |
1538 CreateWindow in .15, which probably did nothing. |
1550 bad values are set. *) |
1539 IMO we should rely on the gl_config defaults from SDL, and use |
|
1540 SDL_GL_GetAttribute to possibly post warnings if any bad values are set. |
|
1541 *) |
1551 SetupOpenGLAttributes(); |
1542 SetupOpenGLAttributes(); |
1552 {$ENDIF} |
1543 {$ENDIF} |
1553 {$IFDEF SDL13} |
1544 {$IFDEF SDL2} |
1554 // these values in x and y make the window appear in the center |
1545 // these values in x and y make the window appear in the center |
1555 x:= SDL_WINDOWPOS_CENTERED_MASK; |
1546 x:= SDL_WINDOWPOS_CENTERED_MASK; |
1556 y:= SDL_WINDOWPOS_CENTERED_MASK; |
1547 y:= SDL_WINDOWPOS_CENTERED_MASK; |
1557 // SDL_WINDOW_RESIZABLE makes the window respond to rotation events on mobile devices |
1548 // SDL_WINDOW_RESIZABLE makes the window resizable and |
|
1549 // respond to rotation events on mobile devices |
1558 flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN or SDL_WINDOW_RESIZABLE; |
1550 flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN or SDL_WINDOW_RESIZABLE; |
1559 |
1551 |
1560 {$IFDEF MOBILE} |
1552 {$IFDEF MOBILE} |
1561 if isPhone() then |
1553 if isPhone() then |
1562 SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight'); |
1554 SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight'); |
1563 // no need for borders on mobile devices |
1555 // no need for borders on mobile devices |
1564 flags:= flags or SDL_WINDOW_BORDERLESS; |
1556 flags:= flags or SDL_WINDOW_BORDERLESS; |
1565 {$ENDIF} |
1557 {$ENDIF} |
1566 |
1558 |
|
1559 if cFullScreen then |
|
1560 flags:= flags or SDL_WINDOW_FULLSCREEN; |
|
1561 |
1567 if SDLwindow = nil then |
1562 if SDLwindow = nil then |
1568 if cFullScreen then |
1563 SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); |
1569 SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags or SDL_WINDOW_FULLSCREEN) |
|
1570 else |
|
1571 begin |
|
1572 SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); |
|
1573 end; |
|
1574 SDLTry(SDLwindow <> nil, true); |
1564 SDLTry(SDLwindow <> nil, true); |
1575 {$ELSE} |
1565 {$ELSE} |
1576 flags:= SDL_OPENGL or SDL_RESIZABLE; |
1566 flags:= SDL_OPENGL or SDL_RESIZABLE; |
1577 if cFullScreen then |
1567 if cFullScreen then |
1578 begin |
|
1579 flags:= flags or SDL_FULLSCREEN; |
1568 flags:= flags or SDL_FULLSCREEN; |
1580 end; |
|
1581 if not cOnlyStats then |
1569 if not cOnlyStats then |
1582 begin |
1570 begin |
1583 {$IFDEF WIN32} |
1571 {$IFDEF WIN32} |
1584 s:= SDL_getenv('SDL_VIDEO_CENTERED'); |
1572 s:= SDL_getenv('SDL_VIDEO_CENTERED'); |
1585 SDL_putenv('SDL_VIDEO_CENTERED=1'); |
1573 SDL_putenv('SDL_VIDEO_CENTERED=1'); |
1586 {$ENDIF} |
1574 {$ENDIF} |
1587 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, 0, flags); |
1575 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, 0, flags); |
1588 SDLTry(SDLPrimSurface <> nil, true); |
1576 SDLTry(SDLPrimSurface <> nil, true); |
1589 {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} |
1577 {$IFDEF WIN32} |
|
1578 SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s)); |
|
1579 {$ENDIF} |
1590 end; |
1580 end; |
1591 {$ENDIF} |
1581 {$ENDIF} |
1592 |
1582 |
1593 SetupOpenGL(); |
1583 SetupOpenGL(); |
1594 |
1584 |
1595 if reinit then |
1585 if reinit then |
1596 begin |
1586 begin |
1597 // clean the window from any previous content |
1587 // clean the window from any previous content |
1598 glClear(GL_COLOR_BUFFER_BIT); |
1588 glClear(GL_COLOR_BUFFER_BIT); |
1599 if SuddenDeathDmg then |
1589 if SuddenDeathDmg then |
1600 glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99) |
1590 SetSkyColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255) |
1601 else if ((cReducedQuality and rqNoBackground) = 0) then |
1591 else if ((cReducedQuality and rqNoBackground) = 0) then |
1602 glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99) |
1592 SetSkyColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255) |
1603 else |
1593 else |
1604 glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99); |
1594 SetSkyColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255); |
1605 |
1595 |
1606 // reload everything we had before |
1596 // reload everything we had before |
1607 ReloadCaptions(false); |
1597 ReloadCaptions(false); |
1608 ReloadLines; |
1598 ReloadLines; |
1609 StoreLoad(true); |
1599 StoreLoad(true); |
1610 // redraw all land |
1600 // redraw all land |
1611 UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false); |
1601 UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false); |
1612 end; |
1602 end; |
1613 end; |
1603 end; |
1614 |
1604 |
|
1605 {$IFDEF SDL2} |
|
1606 // for sdl1.2 we directly call SDL_WarpMouse() |
|
1607 // for sdl2 we provide a SDL_WarpMouse() which just calls this function |
|
1608 // this has the advantage of reducing 'uses' and 'ifdef' statements |
|
1609 // (SDLwindow is a private member of this module) |
|
1610 procedure WarpMouse(x, y: Word); inline; |
|
1611 begin |
|
1612 SDL_WarpMouseInWindow(SDLwindow, x, y); |
|
1613 end; |
|
1614 {$ENDIF} |
|
1615 |
|
1616 procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF}; |
|
1617 begin |
|
1618 if GameType = gmtRecord then |
|
1619 exit; |
|
1620 {$IFDEF SDL2} |
|
1621 SDL_GL_SwapWindow(SDLwindow); |
|
1622 {$ELSE} |
|
1623 SDL_GL_SwapBuffers(); |
|
1624 {$ENDIF} |
|
1625 end; |
|
1626 |
|
1627 procedure SetSkyColor(r, g, b: real); |
|
1628 begin |
|
1629 glClearColor(r, g, b, 0.99) |
|
1630 end; |
|
1631 |
1615 procedure initModule; |
1632 procedure initModule; |
1616 var ai: TAmmoType; |
1633 var ai: TAmmoType; |
1617 i: LongInt; |
1634 i: LongInt; |
1618 begin |
1635 begin |
1619 RegisterVariable('fullscr', @chFullScr, true); |
1636 RegisterVariable('fullscr', @chFullScr, true); |