Xlithan Posted November 11, 2017 Author Share Posted November 11, 2017 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 More sharing options...
Mohenjo Daro Posted November 11, 2017 Share Posted November 11, 2017 I'm not sure if it's important, but try changing the ByVal 0 to a Rect of the screen size.It would also help if you put a breakpoint at the top of the sub and press Shift + F8 to find the line that sends you to the error handler. Link to comment Share on other sites More sharing options...
Xlithan Posted November 11, 2017 Author Share Posted November 11, 2017 Direct3D_Device.BeginScene is when it breaks, which doesn't really make a lot of sense to me as it hasn't even run any of the code at that point. Link to comment Share on other sites More sharing options...
Xlithan Posted November 11, 2017 Author Share Posted November 11, 2017 Crazy thing is, the log says this..."The following error occured at 'Render_Graphics' in 'modGraphics'.Run-time error '-2005530516': Automation error."Apparently the error occurs during the time in which the procedure is called... Link to comment Share on other sites More sharing options...
Mohenjo Daro Posted November 11, 2017 Share Posted November 11, 2017 @Xlithan I think I figured out what's causing the error. My guess is that Direct3D_Device.BeginSceneIs in another Direct3D_Device.BeginSceneTo 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 0So 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 More sharing options...
Xlithan Posted November 11, 2017 Author Share Posted November 11, 2017 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 More sharing options...
Mohenjo Daro Posted November 11, 2017 Share Posted November 11, 2017 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 0Of 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 More sharing options...
Xlithan Posted November 11, 2017 Author Share Posted November 11, 2017 Perfect, thanks bro![alt text](https://i.snag.gy/CPvV8W.jpg) Link to comment Share on other sites More sharing options...
SolidLink Posted November 12, 2017 Share Posted November 12, 2017 Don't forget to set the thread as solved ;) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now