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

[VB.NET] Orion Engine - Transparent Panels


Recoil
 Share

Recommended Posts

For the record, no one is ever at that site…

I have been working on a heavily modified copy of the Orion Engine for some high-end AI stuff.  I have been wanting to use a full screen for the game window, but I will need to have transparent panels for all the UI controls.

Right now I am bypassing the opacity requirement and just trying to draw to the panel exactly what is underneath it.  This flickers right now really bad, but can be fixed later when it gets put through the render...I did this just for simplicity, and it goes in a panel's paint method and refreshed in the game loop:

```
Dim tempImage = New Bitmap(Picturebox1.Width, Picturebox1.Height)

Dim memoryGraphics As Graphics = Graphics.FromImage(tempImage)
Dim screenPos As Point = Picturebox1.PointToScreen(New Point(0, 0))
memoryGraphics.CopyFromScreen(screenPos.X, screenPos.Y, 0, 0, Picturebox1.Size)

Dim destRect As New Rectangle(0, 0, Panel1.Width, Panel1.Height)
Dim srcRect As New Rectangle(picscreen.Location.X - 100, picscreen.Location.Y, Panel1.Width, Panel1.Height)
e.Graphics.DrawImage(tempImage, destRect, srcRect, GraphicsUnit.Pixel)

```
![](http://i.stack.imgur.com/FjtxH.jpg)

As you can see the more I bring the offset closer to being lined up (- 100) to the right it picks up the panel and doesn't make it transparent.  I'm desperately reaching out hoping that someone here can give me an idea of how to make transparent windows for the controls.

I have found dozens of articles of making transparent panels, but those only work if the underlying control has an image or background image, and do not work when graphics are constantly being redrawn to the underlying control.  I have asked at a few programming sites as well, but after 5 days and no response or idea how to do this I am hoping that someone here can help.
Link to comment
Share on other sites

Windows form controls being transparent over SFML is not an easy task, and honestly I would recommend against doing so. (Windows Forms, or the Win32 API to be more specific were never designed to do this and have their own way of being rendered within the OS itself.)

I'd recommend going for an SFML UI library such as the following: https://code.google.com/p/gwen-dotnet/
You could probably find a couple more around though. Not as simple as drag 'n drop editing, but it will save you a lot of headaches and frustration as well as awkward hacks to get it to work.
Link to comment
Share on other sites

Unfortunately that is actually the most helpful explanation I have found. Gwen doesn't look as if it has been worked on since 2013, and I have looked around some and have not found anything that is straight forward for VB.NET and using a compatible UI library from other sources.

Right now my options are to just keep with the smaller window that I have now or find something else to run this AI stuff with…and since I only know VB.NET it seems I am limited. If I knew SlimDX could do it I would see about converting it over, but likewise there is little-to-no documentation on doing this.
Link to comment
Share on other sites

You can try choose the BackColor and TransparencyKey same color. Then this panels be transparent(I made this with FORMS and works fine) Or can try to show GUI with code, Do you need to see how its draw on EO 4, Eclipse EFF or another DX8 Custom.
Link to comment
Share on other sites

I had to draw everything onto the game window, and do away with the panels. There is no way to use a control in this manner and have it display graphics drawn to a picturebox underneath…it just will not work.

I have made a grip of changes to the Orion Engine and will be releasing a revamped version when I get everything working.
Link to comment
Share on other sites

  • 2 months later...
I have an up to date version of TGUI using the latest SFML.net if you would prefer that. Its light weight, straight to the point and is EXTREMELY easy to use. The only draw back is that the memory management in it isnt 100% efficient so if you make classes that expose TGUI elements and dispose/create them many many times you will memory leak eventually… Granted on an optimized test I did properly managing the memory as much as the user can themselves from user-end it would take about 98 thousand iterations of creation/closing of a class to finally memoryleak(as it only goes up about 40 kb every time and most computers ment to play ANY games on takes significantly high amounts of MB to even mem leak.)

* * *

@'Bubblegum':

> The majority of C# libraries will work in VB.net as well, as they both run on the same framework.

All will as long as they are .net 2.0 and up. The only libraries that may run on C# but NOT VB.net ones are language plugin libraries like XNA where the framework exists and is compatable with both but only have templates documentation and debugging via C# because it only directly targeted that language through VS extention. Reguardless this still meens all will, it just meens its significantly harder to use in VB.Net.

* * *

@'Recoil':

> For the record, no one is ever at that site…
>
> I have been working on a heavily modified copy of the Orion Engine for some high-end AI stuff.  I have been wanting to use a full screen for the game window, but I will need to have transparent panels for all the UI controls.
>
> Right now I am bypassing the opacity requirement and just trying to draw to the panel exactly what is underneath it.  This flickers right now really bad, but can be fixed later when it gets put through the render...I did this just for simplicity, and it goes in a panel's paint method and refreshed in the game loop:
>
> ```
> Dim tempImage = New Bitmap(Picturebox1.Width, Picturebox1.Height)
>
> Dim memoryGraphics As Graphics = Graphics.FromImage(tempImage)
> Dim screenPos As Point = Picturebox1.PointToScreen(New Point(0, 0))
> memoryGraphics.CopyFromScreen(screenPos.X, screenPos.Y, 0, 0, Picturebox1.Size)
>
> Dim destRect As New Rectangle(0, 0, Panel1.Width, Panel1.Height)
> Dim srcRect As New Rectangle(picscreen.Location.X - 100, picscreen.Location.Y, Panel1.Width, Panel1.Height)
> e.Graphics.DrawImage(tempImage, destRect, srcRect, GraphicsUnit.Pixel)
>
> ```
> ![](http://i.stack.imgur.com/FjtxH.jpg)
>
> As you can see the more I bring the offset closer to being lined up (- 100) to the right it picks up the panel and doesn't make it transparent.  I'm desperately reaching out hoping that someone here can give me an idea of how to make transparent windows for the controls.
>
> I have found dozens of articles of making transparent panels, but those only work if the underlying control has an image or background image, and do not work when graphics are constantly being redrawn to the underlying control.  I have asked at a few programming sites as well, but after 5 days and no response or idea how to do this I am hoping that someone here can help.

Just for the heads up, you never want to try merging the functionality of SFML drawing and win forms controls(aside to one main draw surface) especially for any form of transparency overlay. This is because WinForms are very touchy and all of their controls derive of the form being the parent and all drawing is done based on Control to Parent relationships. This meens controls trying to overlap or move around eachother (or redraw over eachother durring runtime) will ALWAYS have a problem with flicker. As well this poor design choice, though allowing faster running UI(to make up for the interpreter slow down) the draw process isnt nearly as fast so even things such as resizing a window cause flickers. This can only be solved by creating windows and/or controls directly from graphical libraries.

Personally, I wouldnt recommend SFML to anyone however, it is slow and is NOT platform independant which nearly defeats any reason to move up from VB6(Threading or 64 bit processes can actually very EASILY be hacked back into vb6 through .net libraries.) The only reason one should fully move to .net at least as far as this community and engine are designed for should be cross platform compatability.
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...