Seite 4 von 6

Verfasst: 01.06.2009 19:31
von Fluid Byte
Ich habe mir mal die Freiheit genommen den Code zu aktualisieren:

Code: Alles auswählen

; Overlay for DirectX 7 via DirectDraw
;
; Original by Stefan Moebius (02 Nov. 2004)
; Updated by Fluid Byte (10 May 2009)
;
;
; Attention:
; ¯¯¯¯¯¯¯¯¯¯
; Not every graphic card supports overlays.

EnableExplicit

Declare WindowCallback(hWnd,uMsg,wParam,lParam)
Declare CreateOverlayFromSprite(Sprite)
Declare ShowOverlay(*DDS.IDirectDrawSurface7,X,Y,Width,Height)
Declare HideOverlay(*DDS.IDirectDrawSurface7)
Declare FreeOverlay(*DDS.IDirectDrawSurface7)

#DDOVER_HIDE = $00000200
#DDOVER_SHOW = 16384
#DDSCAPS_OVERLAY = 128   
#DDSCAPS_VIDEOMEMORY = 16384
#DDSD_PIXELFORMAT = 4096
#DDSD_CAPS = 1
#DDSD_HEIGHT = 2
#DDSD_WIDTH = 4
#DDPF_RGB = 64
#DDPF_FOURCC = 4
#DDLOCK_WAIT = 1

Structure DDPIXELFORMAT
	dwSize.l
	dwFlags.l
	dwFourCC.l
	dwRGBBitCount.l
	dwRBitMask.l
	dwGBitMask.l
	dwBBitMask.l
	dwRGBAlphaBitMask.l
EndStructure

Structure DDCOLORKEY
	dwColorSpaceLowValue.l
	dwColorSpaceHighValue.l
EndStructure

Structure DDSCAPS2
	dwCaps.l
	dwCaps2.l
	dwCaps3.l
	dwCaps4.l
EndStructure

Structure DDSURFACEDESC2
	dwSize.l
	dwFlags.l
	dwHeight.l
	dwWidth.l
	lPitch.l
	dwBackBufferCount.l
	dwRefreshRate.l
	dwAlphaBitDepth.l
	dwReserved.l
	lpSurface.l
	ddckCKDestOverlay.DDCOLORKEY
	ddckCKDestBlt.DDCOLORKEY
	ddckCKSrcOverlay.DDCOLORKEY
	ddckCKSrcBlt.DDCOLORKEY
	ddpfPixelFormat.DDPIXELFORMAT
	ddsCaps.DDSCAPS2
	dwTextureStage.l
EndStructure

Structure PB_Sprite
	Sprite.i
	Width.w
	Height.w
	Depth.w
	Mode.w
	FileName.i
	RealWidth.w
	RealHeight.w
	ClipX.w
	ClipY.w
EndStructure

Global bShow, Overlay

Define x, y, Angle.f
Define DesktopWidth = GetSystemMetrics_(#SM_CXFULLSCREEN)
Define DesktopHeight = GetSystemMetrics_(#SM_CYFULLSCREEN)

LoadFont(0,"Arial",32)

; Open Screen
InitSprite()

OpenWindow(0,0,0,200,100,"Overlay-Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,320,200,0,0,0)

; Create overlay sprite
CreateSprite(1,256,64) ; Width / height must be dividable by 2

StartDrawing(SpriteOutput(1))
For x=0 To 255
	For y=0 To 63
		Plot(x,y,RGB(255 - x,y * 4,x))
	Next
Next
DrawingFont(FontID(0))
DrawingMode(1)
DrawText(3,3,"Hallo Welt !!!")
DrawText(0,0,"Hallo Welt !!!",#White)
StopDrawing()

Overlay = CreateOverlayFromSprite(1) ; On my computer only one overlay is supported

; Register the hot key 			
RegisterHotKey_(WindowID(0),0,#MOD_ALT,#VK_F11) ; Press ALT + F11 to show / hide the overlay

SetWindowCallback(@WindowCallback())

; ------------------------------------------------------------------------------------------------------
; MAIN LOOP
; ------------------------------------------------------------------------------------------------------

Repeat	
	FlipBuffers()	
	
	If bShow
		Angle + 0.02
		 
		X = Sin(Angle) * (DesktopWidth - 256) / 2 + (DesktopWidth - 256) / 2
		Y = Cos(Angle) * (DesktopHeight - 64) / 2 + (DesktopHeight - 64) / 2
		
		ShowOverlay(Overlay,X,Y,256,64)
	EndIf
Until WindowEvent() = #PB_Event_CloseWindow

FreeOverlay(Overlay)

; ------------------------------------------------------------------------------------------------------
; FUNCTIONS
; ------------------------------------------------------------------------------------------------------

Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
	Select uMsg
		Case #WM_HOTKEY
		bShow = 1 - bShow
		
		If bShow = 0 : HideOverlay(Overlay) : EndIf
	EndSelect
	
	ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CreateOverlayFromSprite(Sprite)
	Protected *Sprite.PB_Sprite, *SrcDDS.IDirectDrawSurface7, *DD.IDirectDraw7, ddsd.DDSURFACEDESC2
	Protected Width, Height, Result, *DDS.IDirectDrawSurface7, Format, SrcDC, DC, Addr, Pitch, X, Y
	Protected C1, C2, Y0, U0, V0, Y1, U1, V1
	
	*Sprite = IsSprite(Sprite)
	
	*SrcDDS = *Sprite\Sprite
	*SrcDDS\GetDDInterface(@*DD)
	
	Width = *Sprite\RealWidth
	Height = *Sprite\RealHeight
	
	ddsd.DDSURFACEDESC2
	ddsd\dwSize = SizeOf(DDSURFACEDESC2)
	ddsd\ddsCaps\dwCaps = #DDSCAPS_OVERLAY | #DDSCAPS_VIDEOMEMORY
	ddsd\dwFlags = #DDSD_CAPS | #DDSD_HEIGHT | #DDSD_WIDTH | #DDSD_PIXELFORMAT
	ddsd\dwWidth = Width
	ddsd\dwHeight = Height
	
	ddsd\ddpfPixelFormat\dwSize = SizeOf(DDPIXELFORMAT)
	ddsd\ddpfPixelFormat\dwFlags = #DDPF_RGB
	ddsd\ddpfPixelFormat\dwRGBBitCount = 16
	ddsd\ddpfPixelFormat\dwRBitMask = $F800
	ddsd\ddpfPixelFormat\dwGBitMask = $07E0
	ddsd\ddpfPixelFormat\dwBBitMask = $001F
	Result = *DD\CreateSurface(ddsd,@*DDS,0)
	Format = 1
	
	If Result
		ddsd\ddpfPixelFormat\dwRBitMask = $7C00
		ddsd\ddpfPixelFormat\dwGBitMask = $03E0
		ddsd\ddpfPixelFormat\dwBBitMask = $001F
		Result = *DD\CreateSurface(ddsd,@*DDS,0)
		Format = 1
	EndIf
	
	If Result
		ddsd\ddpfPixelFormat\dwRGBBitCount = 0
		ddsd\ddpfPixelFormat\dwRBitMask = 0
		ddsd\ddpfPixelFormat\dwGBitMask = 0
		ddsd\ddpfPixelFormat\dwBBitMask = 0
		ddsd\ddpfPixelFormat\dwFlags = #DDPF_FOURCC
		ddsd\ddpfPixelFormat\dwFourCC = PeekL(@"UYVY")
		Result = *DD\CreateSurface(ddsd,@*DDS,0)
		Format = 2
	EndIf
	
	If Result
		ddsd\ddpfPixelFormat\dwFourCC = PeekL(@"YUY2")
		Result = *DD\CreateSurface(ddsd,@*DDS,0)
		Format = 3
	EndIf
	
	If Result : MessageRequester("Error","Can't create Surface !") : End : EndIf
	
	SrcDC = StartDrawing(SpriteOutput(Sprite))
 
	If Format = 1	
		*DDS\GetDC(@DC)
		BitBlt_(DC,0,0,Width,Height,SrcDC,0,0,#SRCCOPY)
		*DDS\ReleaseDC(DC)		
	Else
		*DDS\Lock(0,ddsd,#DDLOCK_WAIT,0)
		
		Addr = ddsd\lpSurface
		Pitch = ddsd\lPitch
		
		For y = 0 To Height-1
			For x = 0 To Width-1 Step 2			
				C1 = Point(x,y)
				C2 = Point(x + 1,y)
				
				Y0 =      ( Red(C1) * 29 +Green(C1) * 57 +Blue(C1) * 14) / 100
				U0 = 128 +(-Red(C1) * 14 -Green(C1) * 29 +Blue(C1) * 43) / 100
				V0 = 128 +( Red(C1) * 36 -Green(C1) * 29 -Blue(C1) * 07) / 100
				
				Y1 =      ( Red(C2) * 29 +Green(C2) * 57 +Blue(C2) * 14) / 100
				U1 = 128 +(-Red(C2) * 14 -Green(C2) * 29 +Blue(C2) * 43) / 100
				V1 = 128 +( Red(C2) * 36 -Green(C2) * 29 -Blue(C2) * 07) / 100
				
				Select Format
					Case 2
					PokeL(Addr,Y1 << 24 + ((V0 + V1) / 2) << 16 + Y0 << 8 + (U0 + U1) / 2) : Addr + 4
					
					Case 3
					PokeL(Addr,((V0 + V1) / 2) << 24 + Y1 << 16 + ((U0 + U1) / 2) << 8 + Y0) : Addr + 4
				EndSelect			
			Next
			
			Addr + (Pitch - Width * 2)
		Next
		
		*DDS\UnLock(0)
	EndIf
	
	StopDrawing()
	
	ProcedureReturn *DDS
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure ShowOverlay(*DDS.IDirectDrawSurface7,X,Y,Width,Height)
	Protected re1.RECT, re2.RECT, *DD.IDirectDraw7, *GDI.IDirectDrawSurface7
 	
 	SetRect_(re1,X,Y,X + Width,Y + Height)
	SetRect_(re2,0,0,Width,Height)
	
	*DDS\GetDDInterface(@*DD)
	*DD\GetGDISurface(@*GDI)
	
	*DDS\UpdateOverlay(re2,*GDI,re1,#DDOVER_SHOW,0)
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure HideOverlay(*DDS.IDirectDrawSurface7)
	Protected *DD.IDirectDraw7, *GDI.IDirectDrawSurface7
	
	*DDS\GetDDInterface(@*DD)
	*DD\GetGDISurface(@*GDI)
	
	*DDS\UpdateOverlay(0,*GDI,0,#DDOVER_HIDE,0)
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure FreeOverlay(*DDS.IDirectDrawSurface7)
	ProcedureReturn *DDS\Release()
EndProcedure
Ich versuche gerade ein Overlay für die Source-Spiele auf Steam zu programmieren. Also CounterStrike, Day Of Defeat, etc. die alle auf DirectX 9 basieren.

Mir sind zwei grundlegende Probleme mit dem Code aufgefallen:

1.) Die Auflösung des Desktops muss mit der im Spiel identisch sein sonst funktioniert es nicht (auch Bit-tiefe).

2.) Wird das Spiel minimiert wird das Overlay zerstört

Es wäre schon interessant zu wissen wie man diese Probleme umgehen kann. Auf der anderen Seite ist DD veraltet, eingestellt und nicht 64bit kompatibel. Es ist wohl an der Zeit sowas mit D3D zu realisieren.

Verfasst: 01.06.2009 21:17
von Andreas21
Wie lest du das Overlay in Spielen? Bei mir zeigt er nur das Overlay aud dem desktop. Aber in Games ist nichts zu sehen. Kann man nicht das Handel des Fenster angeben oder ist es immer Desktop?

Verfasst: 01.06.2009 21:45
von Fluid Byte
Ich habe in meine aktualisierten Beispiel einen Hotkey registriert. Du musst erst das Spiel starten, dann das Spiel minimieren und den Quelltext kompilieren. Dann zurück zum Spiel und ALT+F11 drücken um das Overlay zu zeigen/verstecken. Wie gesagt, Spiel- und Desktopauflösung müssen identisch sein sonst klappt es nicht.

Verfasst: 01.06.2009 21:48
von Andreas21
Naja bei mir kommt dann immer noch nichts. Das Spiel ist mit Directx 7 geschrieben. Im Code wird eigentlich ja auch Directx7 benutzt.

Verfasst: 01.06.2009 22:21
von Fluid Byte
Andreas21 hat geschrieben:Naja bei mir kommt dann immer noch nichts.
Hast du es exakt so gemacht wie beschrieben? Bei mir funktioniert auf jeden Fall.
Andreas21 hat geschrieben:Das Spiel ist mit Directx 7 geschrieben. Im Code wird eigentlich ja auch Directx7 benutzt.
Das hat damit nichts zu tun. Das Overlay wird immer über alles gezeichnet. Egal ob Desktop, normale Fenster oder DirectX 7, 8, 9 oder 10.

Verfasst: 01.06.2009 22:53
von Andreas21
Im Fenster Modus gehst ja, aber nicht im Vollbild Modus.
Und wenn ich das Spiel dann wieder Minimiere ist das Overlay auch auf dem Desktop nicht zu sehn.

Ich teste es mal mit anderen spielen.

Verfasst: 01.06.2009 22:57
von Fluid Byte
Andreas21 hat geschrieben:Im Fenster Modus gehst ja, aber nicht im Vollbild Modus.
Und wenn ich das Spiel dann wieder Minimiere ist das Overlay auch auf dem Desktop nicht zu sehn.
Bitte mal genauer lesen ich hab' das bereits erklärt. Das funktioniert nur einmal. Wenn das Overlay aktiviert ist und du das Spiel erneut minimierst wird es zerstört.

Verfasst: 01.06.2009 23:18
von Andreas21
Ok ich hab den Fehler gefunden. Warums bei mir nicht lauffen wolte.
Mein Desktop leuft auf 32 Bit Farben aber mein spiel nur auf 16 Bit.

Änder ich die Desktop Farben auf 16 Bit leufts.
Unter Windows XP 32Bit und Vista 64Bit leufts

edit:
Das mit dem minimiren klap bei mir jetzt.
Änder mal dein code so:
(Das Klapt aber dann nur mit einem Game. Da man das Handel vom Game Fenster braucht.)

Code: Alles auswählen

; Overlay for DirectX 7 via DirectDraw 
; 
; Original by Stefan Moebius (02 Nov. 2004) 
; Updated by Fluid Byte (10 May 2009) 
; 
; 
; Attention: 
; ¯¯¯¯¯¯¯¯¯¯ 
; Not every graphic card supports overlays. 

EnableExplicit 

Declare WindowCallback(hWnd,uMsg,wParam,lParam) 
Declare CreateOverlayFromSprite(Sprite) 
Declare ShowOverlay(*DDS.IDirectDrawSurface7,X,Y,Width,Height) 
Declare HideOverlay(*DDS.IDirectDrawSurface7) 
Declare FreeOverlay(*DDS.IDirectDrawSurface7) 

#DDOVER_HIDE = $00000200 
#DDOVER_SHOW = 16384 
#DDSCAPS_OVERLAY = 128    
#DDSCAPS_VIDEOMEMORY = 16384 
#DDSD_PIXELFORMAT = 4096 
#DDSD_CAPS = 1 
#DDSD_HEIGHT = 2 
#DDSD_WIDTH = 4 
#DDPF_RGB = 64 
#DDPF_FOURCC = 4 
#DDLOCK_WAIT = 1 

Structure DDPIXELFORMAT 
   dwSize.l 
   dwFlags.l 
   dwFourCC.l 
   dwRGBBitCount.l 
   dwRBitMask.l 
   dwGBitMask.l 
   dwBBitMask.l 
   dwRGBAlphaBitMask.l 
EndStructure 

Structure DDCOLORKEY 
   dwColorSpaceLowValue.l 
   dwColorSpaceHighValue.l 
EndStructure 

Structure DDSCAPS2 
   dwCaps.l 
   dwCaps2.l 
   dwCaps3.l 
   dwCaps4.l 
EndStructure 

Structure DDSURFACEDESC2 
   dwSize.l 
   dwFlags.l 
   dwHeight.l 
   dwWidth.l 
   lPitch.l 
   dwBackBufferCount.l 
   dwRefreshRate.l 
   dwAlphaBitDepth.l 
   dwReserved.l 
   lpSurface.l 
   ddckCKDestOverlay.DDCOLORKEY 
   ddckCKDestBlt.DDCOLORKEY 
   ddckCKSrcOverlay.DDCOLORKEY 
   ddckCKSrcBlt.DDCOLORKEY 
   ddpfPixelFormat.DDPIXELFORMAT 
   ddsCaps.DDSCAPS2 
   dwTextureStage.l 
EndStructure 

Structure PB_Sprite 
   Sprite.i 
   Width.w 
   Height.w 
   Depth.w 
   Mode.w 
   FileName.i 
   RealWidth.w 
   RealHeight.w 
   ClipX.w 
   ClipY.w 
EndStructure 

Global bShow, Overlay 

Define x, y, Angle.f, a.b
Define DesktopWidth = GetSystemMetrics_(#SM_CXFULLSCREEN) 
Define DesktopHeight = GetSystemMetrics_(#SM_CYFULLSCREEN) 
Define game_fenster_handel = FindWindow_("Game Fenster Name",#Null)

LoadFont(0,"Arial",32) 

; Open Screen 
InitSprite() 

OpenWindow(0,0,0,100,100,"Overlay-Test",#PB_Window_Invisible) 
OpenWindowedScreen(WindowID(0),0,0,100,100,0,0,0) 

; Create overlay sprite 
CreateSprite(1,256,64) ; Width / height must be dividable by 2 

StartDrawing(SpriteOutput(1)) 
For x=0 To 255 
   For y=0 To 63 
      Plot(x,y,RGB(255 - x,y * 4,x)) 
   Next 
Next 
DrawingFont(FontID(0)) 
DrawingMode(1) 
DrawText(3,3,"Hallo Welt !!!") 
DrawText(0,0,"Hallo Welt !!!",#White) 
StopDrawing() 

Overlay = CreateOverlayFromSprite(1) ; On my computer only one overlay is supported 
; Register the hot key           
RegisterHotKey_(WindowID(0),0,#MOD_ALT,#VK_F11) ; Press ALT + F11 to show / hide the overlay 

SetWindowCallback(@WindowCallback()) 

; ------------------------------------------------------------------------------------------------------ 
; MAIN LOOP 
; ------------------------------------------------------------------------------------------------------ 

Repeat    
   FlipBuffers()    
    
   If bShow 
      Angle + 0.02 
       
      X = Sin(Angle) * (DesktopWidth - 256) / 2 + (DesktopWidth - 256) / 2 
      Y = Cos(Angle) * (DesktopHeight - 64) / 2 + (DesktopHeight - 64) / 2 
      If GetForegroundWindow_() = game_fenster_handel
        ShowOverlay(Overlay,X,Y,256,64) 
        a = 0
      Else
        If a = 0
          HideOverlay(Overlay)
          a = 1
        EndIf
      EndIf
   EndIf 
Until WindowEvent() = #PB_Event_CloseWindow 

FreeOverlay(Overlay) 

; ------------------------------------------------------------------------------------------------------ 
; FUNCTIONS 
; ------------------------------------------------------------------------------------------------------ 

Procedure WindowCallback(hWnd,uMsg,wParam,lParam) 
   Select uMsg 
      Case #WM_HOTKEY 
      bShow = 1 - bShow 
       
      If bShow = 0 : HideOverlay(Overlay) : EndIf 
   EndSelect 
   ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Procedure CreateOverlayFromSprite(Sprite) 
   Protected *Sprite.PB_Sprite, *SrcDDS.IDirectDrawSurface7, *DD.IDirectDraw7, ddsd.DDSURFACEDESC2 
   Protected Width, Height, Result, *DDS.IDirectDrawSurface7, Format, SrcDC, DC, Addr, Pitch, X, Y 
   Protected C1, C2, Y0, U0, V0, Y1, U1, V1 
    
   *Sprite = IsSprite(Sprite) 
    
   *SrcDDS = *Sprite\Sprite 
   *SrcDDS\GetDDInterface(@*DD) 
    
   Width = *Sprite\RealWidth 
   Height = *Sprite\RealHeight 
    
   ddsd.DDSURFACEDESC2 
   ddsd\dwSize = SizeOf(DDSURFACEDESC2) 
   ddsd\ddsCaps\dwCaps = #DDSCAPS_OVERLAY | #DDSCAPS_VIDEOMEMORY 
   ddsd\dwFlags = #DDSD_CAPS | #DDSD_HEIGHT | #DDSD_WIDTH | #DDSD_PIXELFORMAT 
   ddsd\dwWidth = Width 
   ddsd\dwHeight = Height 
    
   ddsd\ddpfPixelFormat\dwSize = SizeOf(DDPIXELFORMAT) 
   ddsd\ddpfPixelFormat\dwFlags = #DDPF_RGB 
   ddsd\ddpfPixelFormat\dwRGBBitCount = 32 
   ddsd\ddpfPixelFormat\dwRBitMask = $F800 
   ddsd\ddpfPixelFormat\dwGBitMask = $07E0 
   ddsd\ddpfPixelFormat\dwBBitMask = $001F 
   Result = *DD\CreateSurface(ddsd,@*DDS,0) 
   Format = 1 
    
   If Result 
      ddsd\ddpfPixelFormat\dwRBitMask = $7C00 
      ddsd\ddpfPixelFormat\dwGBitMask = $03E0 
      ddsd\ddpfPixelFormat\dwBBitMask = $001F 
      Result = *DD\CreateSurface(ddsd,@*DDS,0) 
      Format = 1 
   EndIf 
    
   If Result 
      ddsd\ddpfPixelFormat\dwRGBBitCount = 0 
      ddsd\ddpfPixelFormat\dwRBitMask = 0 
      ddsd\ddpfPixelFormat\dwGBitMask = 0 
      ddsd\ddpfPixelFormat\dwBBitMask = 0 
      ddsd\ddpfPixelFormat\dwFlags = #DDPF_FOURCC 
      ddsd\ddpfPixelFormat\dwFourCC = PeekL(@"UYVY") 
      Result = *DD\CreateSurface(ddsd,@*DDS,0) 
      Format = 2 
   EndIf 
    
   If Result 
      ddsd\ddpfPixelFormat\dwFourCC = PeekL(@"YUY2") 
      Result = *DD\CreateSurface(ddsd,@*DDS,0) 
      Format = 3 
   EndIf 
    
   If Result : MessageRequester("Error","Can't create Surface !") : End : EndIf 
    
   SrcDC = StartDrawing(SpriteOutput(Sprite)) 
  
   If Format = 1    
      *DDS\GetDC(@DC) 
      BitBlt_(DC,0,0,Width,Height,SrcDC,0,0,#SRCCOPY) 
      *DDS\ReleaseDC(DC)       
   Else 
      *DDS\Lock(0,ddsd,#DDLOCK_WAIT,0) 
       
      Addr = ddsd\lpSurface 
      Pitch = ddsd\lPitch 
       
      For y = 0 To Height-1 
         For x = 0 To Width-1 Step 2          
            C1 = Point(x,y) 
            C2 = Point(x + 1,y) 
             
            Y0 =      ( Red(C1) * 29 +Green(C1) * 57 +Blue(C1) * 14) / 100 
            U0 = 128 +(-Red(C1) * 14 -Green(C1) * 29 +Blue(C1) * 43) / 100 
            V0 = 128 +( Red(C1) * 36 -Green(C1) * 29 -Blue(C1) * 07) / 100 
             
            Y1 =      ( Red(C2) * 29 +Green(C2) * 57 +Blue(C2) * 14) / 100 
            U1 = 128 +(-Red(C2) * 14 -Green(C2) * 29 +Blue(C2) * 43) / 100 
            V1 = 128 +( Red(C2) * 36 -Green(C2) * 29 -Blue(C2) * 07) / 100 
             
            Select Format 
               Case 2 
               PokeL(Addr,Y1 << 24 + ((V0 + V1) / 2) << 16 + Y0 << 8 + (U0 + U1) / 2) : Addr + 4 
                
               Case 3 
               PokeL(Addr,((V0 + V1) / 2) << 24 + Y1 << 16 + ((U0 + U1) / 2) << 8 + Y0) : Addr + 4 
            EndSelect          
         Next 
          
         Addr + (Pitch - Width * 2) 
      Next 
       
      *DDS\UnLock(0) 
   EndIf 
    
   StopDrawing() 
    
   ProcedureReturn *DDS 
EndProcedure 

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Procedure ShowOverlay(*DDS.IDirectDrawSurface7,X,Y,Width,Height) 
   Protected re1.RECT, re2.RECT, *DD.IDirectDraw7, *GDI.IDirectDrawSurface7 
     
    SetRect_(re1,X,Y,X + Width,Y + Height) 
   SetRect_(re2,0,0,Width,Height) 
    
   *DDS\GetDDInterface(@*DD) 
   *DD\GetGDISurface(@*GDI) 
    
   *DDS\UpdateOverlay(re2,*GDI,re1,#DDOVER_SHOW,0) 
EndProcedure 

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Procedure HideOverlay(*DDS.IDirectDrawSurface7) 
   Protected *DD.IDirectDraw7, *GDI.IDirectDrawSurface7 
    
   *DDS\GetDDInterface(@*DD) 
   *DD\GetGDISurface(@*GDI) 
    
   *DDS\UpdateOverlay(0,*GDI,0,#DDOVER_HIDE,0) 
EndProcedure 

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Procedure FreeOverlay(*DDS.IDirectDrawSurface7) 
   ProcedureReturn *DDS\Release() 
EndProcedure
Und was die Göße des Fensters angeht. Kann man das Overlay nicht erst erzeugen wenn man im Game ist? Müste es dann nicht gehn? Muss ich mal testen.

Verfasst: 02.06.2009 13:56
von Fluid Byte
Jo, minimieren klappt jetzt. Das ist schon mal nicht schlecht. Das eigentliche Problem bleibt aber die Auflösung. Ich habe einen 16:9 Monitor und DoD:S auf 2048x1152 mit alle Details auf Maximum laufen zu lassen ist selbst für dieses ältere Spiel zu viel des Guten.

Verfasst: 02.06.2009 14:11
von Kaeru Gaman
also, ich bin ja kein spezialist dafür...

aber müßte es nicht möglich sein, auf HotKey hin vom aktuellen GetForegroundWindow_() das handle zu ermitteln und dort das overlay zu plazieren?

und eben im selben thread auch checken, ob das noch aktuell ist und wenn nicht das overlay zu deaktivieren oder auf dem dann aktuellen vordergrund zu plazieren...