[DX8] Drawing faces on a picturebox

I am trying to draw the faces on a picturebox (for the multiple characters system), but for some reason it only displays it for a very short time (less than half a second) and then it disappears.

Code:

Sub BltCharFaces()

Dim sRect As RECT, dRect As RECT, FaceNum As Long, srcRect As D3DRECT, destRect As D3DRECT

Dim i As Byte

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If NumFaces = 0 Then Exit Sub

Direct3D_Device.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorRGBA(0, 0, 0, 0), 1#, 0

Direct3D_Device.BeginScene

For i = 1 To MAX_PLAYER_CHARACTERS

FaceNum = CharData(i).Sprite

If FaceNum > 0 Or FaceNum <= NumFaces Then

sRect.Top = 0

sRect.Bottom = sRect.Top + 100

sRect.Left = 0

sRect.Right = sRect.Left + 100

dRect.Top = CharTop

dRect.Bottom = CharTop + 100

dRect.Left = CharOffSetX + (CharOffSetX * (i - 1)) + 100 * (i - 1)

dRect.Right = dRect.Left + 100

RenderTextureByRects Tex_Face(FaceNum), sRect, dRect

End If

Next

With srcRect

.x1 = 0

.x2 = frmMenu.picFaces.Width

.y1 = 0

.y2 = frmMenu.picFaces.Height

End With

With destRect

.x1 = 0

.x2 = frmMenu.picFaces.Width

.y1 = 0

.y2 = frmMenu.picFaces.Height

End With

Direct3D_Device.EndScene

Direct3D_Device.Present srcRect, destRect, frmMenu.picFaces.hwnd, ByVal (0)

' Error handler

Exit Sub

errorhandler:

HandleError "BltCharFace", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Have you included a call to the subroutine in the render loop?

Nope, but thats because this is in frmMenu, and then the ServerLoop isn’t activated yet.

EDIT: I’ll try adding the rendering in a timer tomorrow. ;)

Log in to reply