19 {$INCLUDE "options.inc"} |
19 {$INCLUDE "options.inc"} |
20 {$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF} |
20 {$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF} |
21 |
21 |
22 unit uStore; |
22 unit uStore; |
23 interface |
23 interface |
24 uses SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat; |
24 uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat; |
25 |
25 |
26 procedure initModule; |
26 procedure initModule; |
27 procedure freeModule; |
27 procedure freeModule; |
28 |
28 |
29 procedure StoreLoad(reload: boolean); |
29 procedure StoreLoad(reload: boolean); |
30 procedure StoreRelease(reload: boolean); |
30 procedure StoreRelease(reload: boolean); |
31 procedure RenderHealth(var Hedgehog: THedgehog); |
31 procedure RenderHealth(var Hedgehog: THedgehog); |
32 procedure AddProgress; |
32 procedure AddProgress; |
33 procedure FinishProgress; |
33 procedure FinishProgress; |
34 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
34 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
|
35 |
|
36 // loads an image from the game's data files |
|
37 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
|
38 // like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path |
|
39 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
|
40 // like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded |
|
41 function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
|
42 |
35 procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring); |
43 procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring); |
36 procedure SetupOpenGL; |
44 procedure SetupOpenGL; |
37 procedure SetScale(f: GLfloat); |
45 procedure SetScale(f: GLfloat); |
38 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
46 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
39 procedure RenderWeaponTooltip(atype: TAmmoType); |
47 procedure RenderWeaponTooltip(atype: TAmmoType); |
40 procedure ShowWeaponTooltip(x, y: LongInt); |
48 procedure ShowWeaponTooltip(x, y: LongInt); |
41 procedure FreeWeaponTooltip; |
49 procedure FreeWeaponTooltip; |
42 procedure MakeCrossHairs; |
50 procedure MakeCrossHairs; |
|
51 {$IFDEF USE_VIDEO_RECORDING} |
|
52 procedure InitOffscreenOpenGL; |
|
53 {$ENDIF} |
43 |
54 |
44 procedure WarpMouse(x, y: Word); inline; |
55 procedure WarpMouse(x, y: Word); inline; |
45 procedure SwapBuffers; inline; |
56 procedure SwapBuffers; inline; |
46 |
57 |
47 implementation |
58 implementation |
48 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, |
59 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, |
49 uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}; |
60 uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
|
61 {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
50 |
62 |
51 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple); |
63 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple); |
52 |
64 |
53 var MaxTextureSize: LongInt; |
65 var MaxTextureSize: LongInt; |
54 {$IFDEF SDL13} |
66 {$IFDEF SDL13} |
194 Flag:= 'cpu' |
204 Flag:= 'cpu' |
195 end |
205 end |
196 else if (Flag = 'cpu') or (Flag = 'cpu_plain') then |
206 else if (Flag = 'cpu') or (Flag = 'cpu_plain') then |
197 Flag:= 'hedgewars'; |
207 Flag:= 'hedgewars'; |
198 |
208 |
199 flagsurf:= LoadImage(UserPathz[ptFlags] + '/' + Flag, ifNone); |
209 flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone); |
200 if flagsurf = nil then |
|
201 flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone); |
|
202 if flagsurf = nil then |
|
203 flagsurf:= LoadImage(UserPathz[ptFlags] + '/hedgewars', ifNone); |
|
204 if flagsurf = nil then |
|
205 flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); |
|
206 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
210 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
207 |
211 |
208 case maxLevel of |
212 case maxLevel of |
209 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); |
213 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); |
210 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); |
214 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); |
285 if TeamsArray[t] <> nil then |
287 if TeamsArray[t] <> nil then |
286 with TeamsArray[t]^ do |
288 with TeamsArray[t]^ do |
287 begin |
289 begin |
288 if GraveName = '' then |
290 if GraveName = '' then |
289 GraveName:= 'Statue'; |
291 GraveName:= 'Statue'; |
290 texsurf:= LoadImage(UserPathz[ptGraves] + '/' + GraveName, ifTransparent); |
292 texsurf:= LoadDataImageAltFile(ptGraves, GraveName, 'Statue', ifCritical or ifTransparent); |
291 if texsurf = nil then |
|
292 texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, ifTransparent); |
|
293 if texsurf = nil then |
|
294 texsurf:= LoadImage(UserPathz[ptGraves] + '/Statue', ifTransparent); |
|
295 if texsurf = nil then |
|
296 texsurf:= LoadImage(Pathz[ptGraves] + '/Statue', ifCritical or ifTransparent); |
|
297 GraveTex:= Surface2Tex(texsurf, false); |
293 GraveTex:= Surface2Tex(texsurf, false); |
298 SDL_FreeSurface(texsurf) |
294 SDL_FreeSurface(texsurf) |
299 end |
295 end |
300 end; |
296 end; |
301 |
297 |
336 (((cReducedQuality and rqPlainSplash) = 0) or ((not (ii in [sprSplash, sprDroplet, sprSDSplash, sprSDDroplet])))) and |
332 (((cReducedQuality and rqPlainSplash) = 0) or ((not (ii in [sprSplash, sprDroplet, sprSDSplash, sprSDDroplet])))) and |
337 (((cReducedQuality and rqKillFlakes) = 0) or (Theme = 'Snow') or (Theme = 'Christmas') or ((not (ii in [sprFlake, sprSDFlake])))) and |
333 (((cReducedQuality and rqKillFlakes) = 0) or (Theme = 'Snow') or (Theme = 'Christmas') or ((not (ii in [sprFlake, sprSDFlake])))) and |
338 ((cCloudsNumber > 0) or (ii <> sprCloud)) and |
334 ((cCloudsNumber > 0) or (ii <> sprCloud)) and |
339 ((vobCount > 0) or (ii <> sprFlake)) then |
335 ((vobCount > 0) or (ii <> sprFlake)) then |
340 begin |
336 begin |
341 if AltPath = ptNone then |
337 if reload then |
342 if ii in [sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, sprChunk] then // FIXME: hack |
338 tmpsurf:= Surface |
343 begin |
|
344 if not reload then |
|
345 begin |
|
346 tmpsurf:= LoadImage(UserPathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
|
347 if tmpsurf = nil then |
|
348 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent) |
|
349 end |
|
350 else |
|
351 tmpsurf:= Surface |
|
352 end |
|
353 else |
|
354 begin |
|
355 if not reload then |
|
356 begin |
|
357 tmpsurf:= LoadImage(UserPathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
|
358 if tmpsurf = nil then |
|
359 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical) |
|
360 end |
|
361 else |
|
362 tmpsurf:= Surface |
|
363 end |
|
364 else |
339 else |
365 begin |
340 begin |
366 if not reload then |
341 imflags := (ifAlpha or ifTransparent); |
367 begin |
342 |
368 tmpsurf:= LoadImage(UserPathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
343 // these sprites are optional |
369 if tmpsurf = nil then |
344 if not (ii in [sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, sprChunk]) then // FIXME: hack |
370 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
345 imflags := (imflags or ifCritical); |
371 if tmpsurf = nil then |
346 |
372 tmpsurf:= LoadImage(UserPathz[AltPath] + '/' + FileName, ifAlpha or ifTransparent); |
347 // load the image |
373 if tmpsurf = nil then |
348 tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags) |
374 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent) |
|
375 end |
|
376 else |
|
377 tmpsurf:= Surface |
|
378 end; |
349 end; |
379 |
350 |
380 if tmpsurf <> nil then |
351 if tmpsurf <> nil then |
381 begin |
352 begin |
382 if getImageDimensions then |
353 if getImageDimensions then |
465 |
434 |
466 if not reload then |
435 if not reload then |
467 AddProgress; |
436 AddProgress; |
468 IMG_Quit(); |
437 IMG_Quit(); |
469 end; |
438 end; |
|
439 |
|
440 {$IF NOT DEFINED(S3D_DISABLED) OR DEFINED(USE_VIDEO_RECORDING)} |
|
441 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
|
442 begin |
|
443 glGenFramebuffersEXT(1, @frame); |
|
444 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
|
445 glGenRenderbuffersEXT(1, @depth); |
|
446 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth); |
|
447 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); |
|
448 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth); |
|
449 glGenTextures(1, @tex); |
|
450 glBindTexture(GL_TEXTURE_2D, tex); |
|
451 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); |
|
452 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
453 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
454 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); |
|
455 end; |
|
456 |
|
457 procedure DeleteFramebuffer(var frame, depth, tex: GLuint); |
|
458 begin |
|
459 glDeleteTextures(1, @tex); |
|
460 glDeleteRenderbuffersEXT(1, @depth); |
|
461 glDeleteFramebuffersEXT(1, @frame); |
|
462 end; |
|
463 {$ENDIF} |
470 |
464 |
471 procedure StoreRelease(reload: boolean); |
465 procedure StoreRelease(reload: boolean); |
472 var ii: TSprite; |
466 var ii: TSprite; |
473 ai: TAmmoType; |
467 ai: TAmmoType; |
474 i, t: LongInt; |
468 i, t: LongInt; |
539 FreeTexture(TeamsArray[t]^.Hedgehogs[i].HatTex); |
533 FreeTexture(TeamsArray[t]^.Hedgehogs[i].HatTex); |
540 TeamsArray[t]^.Hedgehogs[i].HatTex:= nil; |
534 TeamsArray[t]^.Hedgehogs[i].HatTex:= nil; |
541 end; |
535 end; |
542 end; |
536 end; |
543 end; |
537 end; |
|
538 {$IFDEF USE_VIDEO_RECORDING} |
|
539 if defaultFrame <> 0 then |
|
540 DeleteFramebuffer(defaultFrame, depthv, texv); |
|
541 {$ENDIF} |
544 {$IFNDEF S3D_DISABLED} |
542 {$IFNDEF S3D_DISABLED} |
545 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
543 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
546 begin |
544 begin |
547 glDeleteTextures(1, @texl); |
545 DeleteFramebuffer(framel, depthl, texl); |
548 glDeleteRenderbuffersEXT(1, @depthl); |
546 DeleteFramebuffer(framer, depthr, texr); |
549 glDeleteFramebuffersEXT(1, @framel); |
|
550 glDeleteTextures(1, @texr); |
|
551 glDeleteRenderbuffersEXT(1, @depthr); |
|
552 glDeleteFramebuffersEXT(1, @framer) |
|
553 end |
547 end |
554 {$ENDIF} |
548 {$ENDIF} |
555 end; |
549 end; |
556 |
550 |
557 |
551 |
596 WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
590 WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
597 |
591 |
598 LoadImage:= tmpsurf //Result |
592 LoadImage:= tmpsurf //Result |
599 end; |
593 end; |
600 |
594 |
|
595 |
|
596 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
|
597 var tmpsurf: PSDL_Surface; |
|
598 begin |
|
599 // check for file in user dir (never critical) |
|
600 tmpsurf:= LoadImage(UserPathz[path] + '/' + filename, imageFlags and (not ifCritical)); |
|
601 |
|
602 // if unsuccessful check data dir |
|
603 if (tmpsurf = nil) then |
|
604 tmpsurf:= LoadImage(Pathz[path] + '/' + filename, imageFlags); |
|
605 |
|
606 LoadDataImage:= tmpsurf; |
|
607 end; |
|
608 |
|
609 |
|
610 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
|
611 var tmpsurf: PSDL_Surface; |
|
612 begin |
|
613 // if there is no alternative path, just forward and return result |
|
614 if (altPath = ptNone) then |
|
615 exit(LoadDataImage(path, filename, imageFlags)); |
|
616 |
|
617 // since we have a fallback path this search isn't critical yet |
|
618 tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical)); |
|
619 |
|
620 // if image still not found try alternative path |
|
621 if (tmpsurf = nil) then |
|
622 tmpsurf:= LoadDataImage(altPath, filename, imageFlags); |
|
623 |
|
624 LoadDataImageAltPath:= tmpsurf; |
|
625 end; |
|
626 |
|
627 function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
|
628 var tmpsurf: PSDL_Surface; |
|
629 begin |
|
630 // if there is no alternative filename, just forward and return result |
|
631 if (altFile = '') then |
|
632 exit(LoadDataImage(path, filename, imageFlags)); |
|
633 |
|
634 // since we have a fallback filename this search isn't critical yet |
|
635 tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical)); |
|
636 |
|
637 // if image still not found try alternative filename |
|
638 if (tmpsurf = nil) then |
|
639 tmpsurf:= LoadDataImage(path, altFile, imageFlags); |
|
640 |
|
641 LoadDataImageAltFile:= tmpsurf; |
|
642 end; |
|
643 |
601 procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring); |
644 procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring); |
602 var texsurf: PSDL_Surface; |
645 var texsurf: PSDL_Surface; |
603 begin |
646 begin |
604 texsurf:= LoadImage(UserPathz[ptHats] + '/' + newHat, ifNone); |
647 texsurf:= LoadDataImage(ptHats, newHat, ifNone); |
605 if texsurf = nil then |
|
606 texsurf:= LoadImage(Pathz[ptHats] + '/' + newHat, ifNone); |
|
607 |
648 |
608 // only do something if the hat could be loaded |
649 // only do something if the hat could be loaded |
609 if texsurf <> nil then |
650 if texsurf <> nil then |
610 begin |
651 begin |
611 // free the mem of any previously assigned texture |
652 // free the mem of any previously assigned texture |
707 // everyone love debugging |
754 // everyone love debugging |
708 AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); |
755 AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); |
709 AddFileLog(' |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR)))); |
756 AddFileLog(' |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR)))); |
710 AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); |
757 AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); |
711 AddFileLog(' |----- Texture Size: ' + inttostr(MaxTextureSize)); |
758 AddFileLog(' |----- Texture Size: ' + inttostr(MaxTextureSize)); |
712 AddFileLog(' \----- Extensions: ' + shortstring(pchar(glGetString(GL_EXTENSIONS)))); |
759 {$IFDEF USE_VIDEO_RECORDING} |
713 //TODO: don't have the Extensions line trimmed but slipt it into multiple lines |
760 glGetIntegerv(GL_AUX_BUFFERS, @AuxBufNum); |
|
761 AddFileLog(' |----- Number of auxiliary buffers: ' + inttostr(AuxBufNum)); |
|
762 {$ENDIF} |
|
763 AddFileLog(' \----- Extensions: '); |
|
764 {$IFNDEF PAS2C} |
|
765 // fetch extentions and store them in string |
|
766 tmpstr := StrPas(PChar(glGetString(GL_EXTENSIONS))); |
|
767 tmpn := WordCount(tmpstr, [' ']); |
|
768 tmpint := 1; |
|
769 |
|
770 repeat |
|
771 begin |
|
772 // print up to 3 extentions per row |
|
773 // ExtractWord will return empty string if index out of range |
|
774 AddFileLog(TrimRight( |
|
775 ExtractWord(tmpint, tmpstr, [' ']) + ' ' + |
|
776 ExtractWord(tmpint+1, tmpstr, [' ']) + ' ' + |
|
777 ExtractWord(tmpint+2, tmpstr, [' ']) |
|
778 )); |
|
779 tmpint := tmpint + 3; |
|
780 end; |
|
781 until (tmpint > tmpn); |
|
782 {$ELSE} |
|
783 // doesn't seem to print >256 chars |
|
784 AddFileLogRaw(PChar(glGetString(GL_EXTENSIONS))); |
|
785 {$ENDIF} |
|
786 AddFileLog(''); |
|
787 |
|
788 defaultFrame:= 0; |
|
789 {$IFDEF USE_VIDEO_RECORDING} |
|
790 if GameType = gmtRecord then |
|
791 begin |
|
792 if glLoadExtension('GL_EXT_framebuffer_object') then |
|
793 begin |
|
794 CreateFramebuffer(defaultFrame, depthv, texv); |
|
795 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame); |
|
796 AddFileLog('Using framebuffer for video recording.'); |
|
797 end |
|
798 else if AuxBufNum > 0 then |
|
799 begin |
|
800 glDrawBuffer(GL_AUX0); |
|
801 glReadBuffer(GL_AUX0); |
|
802 AddFileLog('Using auxiliary buffer for video recording.'); |
|
803 end |
|
804 else |
|
805 begin |
|
806 glDrawBuffer(GL_BACK); |
|
807 glReadBuffer(GL_BACK); |
|
808 AddFileLog('Warning: off-screen rendering is not supported; using back buffer but it may not work.'); |
|
809 end; |
|
810 end; |
|
811 {$ENDIF} |
714 |
812 |
715 {$IFNDEF S3D_DISABLED} |
813 {$IFNDEF S3D_DISABLED} |
716 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
814 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
717 begin |
815 begin |
718 // prepare left and right frame buffers and associated textures |
816 // prepare left and right frame buffers and associated textures |
719 if glLoadExtension('GL_EXT_framebuffer_object') then |
817 if glLoadExtension('GL_EXT_framebuffer_object') then |
720 begin |
818 begin |
721 // left |
819 CreateFramebuffer(framel, depthl, texl); |
722 glGenFramebuffersEXT(1, @framel); |
820 CreateFramebuffer(framer, depthr, texr); |
723 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel); |
|
724 glGenRenderbuffersEXT(1, @depthl); |
|
725 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthl); |
|
726 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); |
|
727 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthl); |
|
728 glGenTextures(1, @texl); |
|
729 glBindTexture(GL_TEXTURE_2D, texl); |
|
730 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); |
|
731 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
732 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
733 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texl, 0); |
|
734 |
|
735 // right |
|
736 glGenFramebuffersEXT(1, @framer); |
|
737 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer); |
|
738 glGenRenderbuffersEXT(1, @depthr); |
|
739 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthr); |
|
740 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); |
|
741 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthr); |
|
742 glGenTextures(1, @texr); |
|
743 glBindTexture(GL_TEXTURE_2D, texr); |
|
744 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); |
|
745 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
746 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
747 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texr, 0); |
|
748 |
821 |
749 // reset |
822 // reset |
750 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0) |
823 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame) |
751 end |
824 end |
752 else |
825 else |
753 cStereoMode:= smNone; |
826 cStereoMode:= smNone; |
754 end; |
827 end; |
755 {$ENDIF} |
828 {$ENDIF} |
1019 // free the existing texture (if there is any) |
1090 // free the existing texture (if there is any) |
1020 FreeTexture(WeaponTooltipTex); |
1091 FreeTexture(WeaponTooltipTex); |
1021 WeaponTooltipTex:= nil |
1092 WeaponTooltipTex:= nil |
1022 end; |
1093 end; |
1023 |
1094 |
|
1095 {$IFDEF USE_VIDEO_RECORDING} |
|
1096 {$IFDEF SDL13} |
|
1097 procedure InitOffscreenOpenGL; |
|
1098 begin |
|
1099 // create hidden window |
|
1100 SDLwindow:= SDL_CreateWindow('hedgewars (you don''t see this)', |
|
1101 SDL_WINDOWPOS_CENTERED_MASK, SDL_WINDOWPOS_CENTERED_MASK, |
|
1102 cScreenWidth, cScreenHeight, |
|
1103 SDL_WINDOW_HIDDEN or SDL_WINDOW_OPENGL); |
|
1104 SDLTry(SDLwindow <> nil, true); |
|
1105 SetupOpenGL(); |
|
1106 end; |
|
1107 {$ELSE} |
|
1108 procedure InitOffscreenOpenGL; |
|
1109 var ArgCount: LongInt; |
|
1110 PrgName: pchar; |
|
1111 begin |
|
1112 ArgCount:= 1; |
|
1113 PrgName:= 'hwengine'; |
|
1114 glutInit(@ArgCount, @PrgName); |
|
1115 glutInitWindowSize(cScreenWidth, cScreenHeight); |
|
1116 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 |
|
1117 glutHideWindow(); |
|
1118 SetupOpenGL(); |
|
1119 end; |
|
1120 {$ENDIF} // SDL13 |
|
1121 {$ENDIF} // USE_VIDEO_RECORDING |
|
1122 |
1024 procedure chFullScr(var s: shortstring); |
1123 procedure chFullScr(var s: shortstring); |
1025 var flags: Longword = 0; |
1124 var flags: Longword = 0; |
1026 reinit: boolean = false; |
1125 reinit: boolean = false; |
1027 {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF} |
1126 {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF} |
1028 {$IFDEF SDL13}x, y: LongInt;{$ENDIF} |
1127 {$IFDEF SDL13}x, y: LongInt;{$ENDIF} |