DirectDraw Max2D Driver?

BlitzMax Forums/BlitzMax Programming/DirectDraw Max2D Driver?

Ked(Posted 2008) [#1]
Does anyone have a DirectDraw Max2D Driver? How hard would it be to implement one?


MGE(Posted 2008) [#2]
What are you trying to do?


tonyg(Posted 2008) [#3]
I believe drawpixmap uses directdraw interface. You then need to create a bitmap font using drawpixmap rather than use drawtext... I think.


Ked(Posted 2008) [#4]
What are you trying to do?

Make more graphics drivers for BlitzMax.


MGE(Posted 2008) [#5]
DirectDraw and D3D for DX7 are 2 different things.


tonyg(Posted 2008) [#6]
DirectDraw and D3D for DX7 are 2 different things.

Thats true. I believe Bmax uses both.


MGE(Posted 2008) [#7]
Just wanted to verify that DirectDraw is not used in Blitzmax. All of the 2d plotting, rect, line drawing, etc, is actually via the 3d pipeline.

	Method DrawLine( x0#,y0#,x1#,y1#,tx#,ty# )
		If Not IsValid() Return

		Local lx0#,ly0#,lx1#,ly1#
		
		lx0=x0*ix+y0*iy+tx
		ly0=x0*jx+y0*jy+ty
		lx1=x1*ix+y1*iy+tx
		ly1=x1*jx+y1*jy+ty
		
		If linewidth=1.0
			cverts[0]=lx0+.5001
			cverts[1]=ly0+.5001
			cverts[4]=lx1+.5001
			cverts[5]=ly1+.5001
			SetActiveFrame Null
			device.DrawPrimitive(D3DPT_LINELIST,D3DFVF_XYZ|D3DFVF_DIFFUSE,cverts,2,0)
		Else
			Local lw#=linewidth*0.5
			If Abs(ly1-ly0)>Abs(lx1-lx0)
				cverts[0]=lx0-lw
				cverts[1]=ly0
				cverts[4]=lx0+lw
				cverts[5]=ly0
				cverts[8]=lx1-lw
				cverts[9]=ly1
				cverts[12]=lx1+lw
				cverts[13]=ly1
			Else
				cverts[0]=lx0
				cverts[1]=ly0-lw
				cverts[4]=lx0
				cverts[5]=ly0+lw
				cverts[8]=lx1
				cverts[9]=ly1-lw
				cverts[12]=lx1
				cverts[13]=ly1+lw
			EndIf
			SetActiveFrame Null
			device.DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_XYZ|D3DFVF_DIFFUSE,cverts,4,0)
		EndIf
	End Method



Tommo(Posted 2008) [#8]
DrawPixmap and GrabPixmap uses directDraw¡£


Yan(Posted 2008) [#9]
All of the 2d plotting, rect, line drawing, etc, is actually via the 3d pipeline.

Hence tonyg's original post...
I believe drawpixmap uses directdraw interface.



MGE(Posted 2008) [#10]
Yan - yep. Thanks for pointing that out. :)

	Method DrawPixmap( pixmap:TPixmap,x,y )
		If Not IsValid() Return

		Local srcdc,destdc
		Local surf:IDirectDrawSurface7
		Local renderSurf:IDirectDrawSurface7

		D3D7GraphicsDriver().EndScene

		device.GetRenderTarget Varptr renderSurf
		
		renderSurf.GetDC Varptr destdc
		surf=surffrompixmap( pixmap )
		surf.GetDC Varptr srcdc
		BitBlt destdc,x,y,pixmap.width,pixmap.height,srcdc,0,0,ROP_SRCCOPY
		surf.ReleaseDC srcdc
		renderSurf.ReleaseDC destdc
		surf.Release_

		D3D7GraphicsDriver().BeginScene
	End Method

	Method GrabPixmap:TPixmap( x,y,width,height )
		If Not IsValid() Return
		
		Local pixmap:TPixmap
		Local srcdc,destdc
		Local surf:IDirectDrawSurface7
		Local renderSurf:IDirectDrawSurface7
		
		D3D7GraphicsDriver().EndScene

		device.GetRenderTarget Varptr renderSurf
		
		pixmap=TPixmap.Create( width,height,PF_BGR888 )
		renderSurf.GetDC Varptr srcdc
		surf=surffrompixmap( pixmap )
		surf.GetDC Varptr destdc
		BitBlt destdc,0,0,width,height,srcdc,x,y,ROP_SRCCOPY
		surf.ReleaseDC destdc
		renderSurf.ReleaseDC srcdc
		surf.Release_()
		D3D7GraphicsDriver().BeginScene

		Return pixmap	
	End Method



TomToad(Posted 2008) [#11]
I believe drawpixmap uses directdraw interface.

Didn't realize that before. That opens up a bunch of new possibilities. Like this.
http://www.blitzbasic.com/codearcs/codearcs.php?code=2352