Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Drawing to pictureboxes (SkyWyre v10)


Xlithan
 Share

Recommended Posts

Hi guys. So as some of you know, I'm redesigning the interface in Skywyre v10 and going back to the traditional Picturebox on an interface design like in Eclipse. SkyWyre made the change to drawing to a full screen on frmMain, and my project specifically requires me to revert back. However, I don't want to go back to DirectX7, using an earlier engine.

Currently, I'm attempting to move everything from the main game screen (Which is now frmMain.picGame), to picture boxes on the interface.

Currently, I'm trying to draw the hotbar items/spells but I'm getting that infamous "Unrecoverable DX8 Error".

This is my procedure, and I know it's wrong but I tried my best attempt at it. If anybody could correct my code that'd be great, as I can then use it as a template for moving everything else.

**Code:**

Public Sub DrawSkillbar()
Dim I As Long, x As Long, y As Long, t As Long, sS As String

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

x = 0
y = 0

For I = 1 To MAX_HOTBAR
' draw the icon
Select Case Hotbar(I).sType
Case 1 ' inventory
If Len(Item(Hotbar(I).Slot).name) > 0 Then
If Item(Hotbar(I).Slot).Pic > 0 Then
'EngineRenderRectangle Tex_Item(Item(Hotbar(i).Slot).Pic), x + 2, y + 2, 0, 0, 32, 32, 32, 32, 32, 32
RenderTexture Tex_Item(Item(Hotbar(I).Slot).Pic), 5 + x, 5 + y, 0, 0, 30, 30, 30, 30, D3DColorARGB(255 - Item(Hotbar(I).Slot).a, 255 - Item(Hotbar(I).Slot).R, 255 - Item(Hotbar(I).Slot).G, 255 - Item(Hotbar(I).Slot).B)
End If
End If
Case 2 ' spell
If Len(Spell(Hotbar(I).Slot).name) > 0 Then
If Spell(Hotbar(I).Slot).Icon > 0 Then
' render normal icon
'EngineRenderRectangle Tex_Spellicon(Spell(Hotbar(i).Slot).Icon), x + 2, y + 2, 0, 0, 32, 32, 32, 32, 32, 32
RenderTexture Tex_SpellIcon(Spell(Hotbar(I).Slot).Icon), 5 + x, 5 + y, 0, 0, 30, 30, 30, 30
' we got the spell?
For t = 1 To MAX_PLAYER_SPELLS
If PlayerSpells(t).Spell > 0 Then
If PlayerSpells(t).Spell = Hotbar(I).Slot Then
If SpellCD(t) > 0 Then
'EngineRenderRectangle Tex_Spellicon(Spell(Hotbar(i).Slot).Icon), x + 2, y + 2, 0, 0, 32, 32, 32, 32, 32, 32, , , , , , , 254, 190, 190, 190
RenderTexture Tex_SpellIcon(Spell(Hotbar(I).Slot).Icon), 5 + x, 5 + y, 0, 0, 30, 30, 30, 30, D3DColorARGB(255, 100, 100, 100)
End If
End If
End If
Next
End If
End If
End Select
' draw the numbers
sS = str(I)
If I = 10 Then sS = "0"
If I = 11 Then sS = " -"
If I = 12 Then sS = " ="
RenderText Font_Default, sS, 5 + x + 8, 5 + y + 28, White

x = x + 40
If x >= 120 Then
x = 0
y = y + 40
End If
Next

Direct3D_Device.EndScene
Direct3D_Device.Present ByVal 0, ByVal 0, frmMain.picSkillbar.hwnd, ByVal (0)

' Error handler
Exit Sub
errorhandler:
HandleError "DrawSkillbar", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
Link to comment
Share on other sites

@Xlithan

I think I figured out what's causing the error. My guess is that

Direct3D_Device.BeginScene

Is in another

Direct3D_Device.BeginScene

To explain better, you have a code like this

Direct3D_Device.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorARGB(0, 0, 0, 0), 1#, 0
Direct3D_Device.BeginScene

Direct3D_Device.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorARGB(0, 0, 0, 0), 1#, 0
Direct3D_Device.BeginScene

Call DrawMapTile(X, Y)

Direct3D_Device.EndScene
Direct3D_Device.Present ByVal 0, ByVal 0, 0, ByVal 0

So search for where DrawSkillbar is called and keep back tracking until you find where the scene begins.

If this isn't the cause, then I'm not sure what else would be causing it.
Link to comment
Share on other sites

DrawSkillbar is located in DrawGUI which is located in Render_Graphics, which has a Beginscene line. So would I have to move DrawSkillbar to a location that doesn't have it, or what can I do inside DrawSkillbar that would draw it to a picturebox?

**Edit:**

I moved it to DrawGDI and I can now enter the game. The picturebox is completely black and doesn't show anything so I'm guessing I'll have to change some things in DrawSkillbar

**Edit 2:**

I managed to get this far but obviously needs some adjustment. They're supposed to be 30px boxes, 5px from Left and Top, and 40px apart. Not sure why it's drawing it like that but I'll figure it out.

![alt text](https://i.snag.gy/MwJXe5.jpg)

**Edit 3:**

I had my suspicions and they were right. It sizes the graphics based on the size of the PictureBox... How can I fix this issue?

![alt text](https://i.snag.gy/knCXIZ.jpg)
Link to comment
Share on other sites

I'm pretty sure the drawing actually scales to the size of the main hwnd (it should be frmMain in thic case). You're overriding which surface you're drawing to, but it should still be rendering to that scale mode.

Direct3D_Device.Present ByVal 0, ByVal 0, frmMain.picSkillbar.hwnd, ByVal (0)

Try changing that to use your surface rects.

With srcRect
.x1 = 0
.x2 = frmMain.Picture1.ScaleWidth
.y1 = 0
.y2 = frmMain.Picture1.ScaleHeight
End With

Direct3D_Device.Present srcRect, srcRect, frmMain.Picture1.hwnd, ByVal 0

Of course you need to change the 0s to your starting points but, otherwise, that should work (tested with displaying ER in a pic box).

Here's what the image looks like
![alt text](https://media.discordapp.net/attachments/361361857354924033/378935338460119042/image.png?width=401&height=270)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...