I'm writing a game file editor that draws a graphical representation of the file to a screen, so the user can see what he's doing, instead of guessing. I have to redraw this everytime something is changed. This will entail ~75,000 draw commands when everything is being drawn. It runs fine on my P4, but tends to lock slower computers for an unreasonable amount of time.
Is it possible to have DirectX draw things without using sprites? Can I tell it to draw circles, lines and text?
Here's what I have now. I haven't modified it for stuff I learned about when I found this place yesterday, like paint events.
Any help is greatly appreciated.
Is it possible to have DirectX draw things without using sprites? Can I tell it to draw circles, lines and text?
Here's what I have now. I haven't modified it for stuff I learned about when I found this place yesterday, like paint events.
Visual Basic:
Public Sub DrawGalaxy()
Dim i, j As Integer
Dim pF As PointF
Dim rF As RectangleF
Dim Draw As System.Drawing.Graphics
Dim SystemFill As New System.Drawing.SolidBrush(System.Drawing.Color.Black)
Dim SystemOutline As New System.Drawing.Pen(System.Drawing.Color.White, 1)
pnlMap.Refresh()
Draw = pnlMap.CreateGraphics()
If Prefs.HighQuality = True Then
Draw.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Else
Draw.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
End If
'draw nebulae above or below grid?
'draw grid here
'draw hyperlinks
If Prefs.Hyperlinks.Draw = True Then
Dim Hyper As New System.Drawing.Pen(Prefs.Hyperlinks.drawColor, 1)
Dim SelColor As System.Drawing.Color = Color.FromArgb(128, Prefs.SelectedLinks.drawColor)
Dim Sel As New System.Drawing.Pen(SelColor, 5)
For i = 0 To Systems.Length - 1
If Systems(i).bDraw = True Then
For j = 0 To 15
If Systems(i).Hyperlink(j) <> -1 Then
If Systems(Systems(i).Hyperlink(j) - 128).bDraw = True Then
Dim Start, Dest As PointF
Start = Transform_Point(Systems(i).Position, pnlMap)
Dest = Transform_Point(Systems(Systems(i).Hyperlink(j) - 128).Position, pnlMap)
Draw.DrawLine(Hyper, Start, Dest)
If lstSystems.SelectedIndex <> -1 Then
If Get_Index(lstSystems.SelectedItem) = i Then
Draw.DrawLine(Sel, Start, Dest)
End If
End If
End If
End If
Next
End If
Next
End If
'Draw Wormholes
'Draw Hypergates
'Draw Systems
For i = 0 To Systems.Length - 1
If Systems(i).bDraw = True Then
'convert absolute position to account for zoom and
'translation and container coordinates (0,0 doesn't want to be the top, left)
pF = Transform_Point(Systems(i).Position, pnlMap)
pF.X -= Prefs.GetSystSize / 2
pF.Y -= Prefs.GetSystSize / 2
'create rectangle bounds for ellipse
rF = New RectangleF(pF, Prefs.SystSize)
'draw
Draw.FillEllipse(SystemFill, rF)
Draw.DrawEllipse(SystemOutline, rF)
End If
Next i
'Draw labels
If Prefs.SystemLabel.Draw = True Then
Dim Text As New System.Drawing.SolidBrush(Prefs.SystemLabel.drawColor)
For i = 0 To Systems.Length - 1
If Systems(i).bDraw = True Then
pF = Transform_Point(Systems(i).Position, pnlMap)
pF.X += Prefs.GetSystSize
pF.Y += Prefs.GetSystSize
Draw.DrawString("(" & Systems(i).ID & ") " & Systems(i).Name, _
Prefs.MapFont, _
Text, _
pF)
End If
Next
End If
End Sub
Any help is greatly appreciated.
Last edited: