still use same EndScene, Present and Reset hooks as in 4.x
only thing added in 5.0.4 is device.SetRenderState(D3DRS.COLORWRITEENABLE, RedGreenBlueAlpha)
without this setting only 2d font drawing was rendered, but no 3d primitives.
rendering, EndScene hook:
Code:
self.stateblock.Capture()
self.device.SetVertexShader(0)
self.device.SetPixelShader(0)
self.device.SetFVF(D3DFVF.XYZ | D3DFVF.DIFFUSE)
# ИЗ-ЗА ЭТОГО ГАДСТВА НИЧЕГО НЕ РИСОВАЛОСЬ.
RedGreenBlueAlpha = 15
self.device.SetRenderState(D3DRS.COLORWRITEENABLE, RedGreenBlueAlpha)
z_disable = True
if z_disable:
self.device.SetRenderState(D3DRS.ZENABLE, D3DZB.FALSE)
self.device.SetRenderState(D3DRS.STENCILENABLE, 0)
else:
self.device.SetRenderState(D3DRS.ZENABLE, D3DZB.TRUE)
self.device.SetRenderState(D3DRS.ZWRITEENABLE, D3DZB.TRUE)
self.device.SetRenderState(D3DRS.ZFUNC, D3DCMP.LESSEQUAL)
self.device.SetRenderState(D3DRS.STENCILENABLE, 1)
self.device.SetRenderState( D3DRS.SPECULARENABLE, 0)
self.device.SetRenderState( D3DRS.LIGHTING, 0 )
self.device.SetRenderState( D3DRS.CULLMODE , D3DCULL.NONE)
self.device.SetRenderState( D3DRS.ANTIALIASEDLINEENABLE, 1)
self.device.SetRenderState(D3DRS.FOGENABLE, 0)
self.device.SetRenderState( D3DRS.ALPHABLENDENABLE, 1 )
self.device.SetRenderState( D3DRS.SRCBLEND, D3DBLEND.SRCALPHA )
self.device.SetRenderState( D3DRS.DESTBLEND, D3DBLEND.INVSRCALPHA )
Viewport = D3DVIEWPORT9()
self.device.GetViewport(byref(Viewport))
Viewport.MinZ = 0
Viewport.MaxZ = 0.94
self.device.SetViewport(byref(Viewport))
self.device.SetTransform(D3DTS.WORLD, byref(IdentityMatrix))
self.device.SetTransform(D3DTS.VIEW, byref(ViewMatrix(cam)))
self.device.SetTransform(D3DTS.PROJECTION, byref(ProjectionMatrix(cam)))
try:
#THERE IS MY RENDERING DONE
finally:
self.stateblock.Apply()
init/deinit, Reset hook:
Code:
init:
self.stateblock = POINTER(IDirect3DStateBlock9)()
self.device.CreateStateBlock(1, byref(self.stateblock))
deinit:
self.stateblock.Release()