Skip to content

Conversation

@Arc-huangjingtong
Copy link
Contributor

@Arc-huangjingtong Arc-huangjingtong commented May 4, 2025

PR Details

Add BackgroundColor and Opacity API

Why ADD

Support games like https://store.steampowered.com/app/2666510/Rustys_Retirement/
image

Related Issue

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@Eideren Eideren marked this pull request as draft May 4, 2025 09:39
@Eideren
Copy link
Collaborator

Eideren commented May 4, 2025

Looks cool, set it to draft for now given the WIP in the title, feel free to change it back to ready for review when you're ready :)

@Arc-huangjingtong Arc-huangjingtong changed the title [WIP] [Feat] Add more window api WIP: feat: Add more window api May 4, 2025
Change Opacity value type float->double ,because the internal API use the double type
@Arc-huangjingtong
Copy link
Contributor Author

image
Now,set opacity prop.in the winform window and SDL window ,is OK

/// Gets or sets the opacity of the window.
/// </summary>
/// <value> 1.0d is fully opaque, 0.0d is fully transparent. value will automatically be clamped to [0.0d, 1.0d] </value>
/// <remarks> default , if window is null , is regarded as no transparent (1.0d)</remarks>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML comment improments 🙂.

/// <summary>
/// Gets or sets the opacity of the window.
/// </summary>
/// <value>1.0d is fully opaque, 0.0d is fully transparent. The value will automatically be clamped to [0.0d, 1.0d].</value>
/// <remarks>The default value, if the window is null, is considered fully opaque (1.0d).</remarks>

/// Gets or sets the background color of the window.
/// </summary>
/// <value> The background color. </value>
public abstract Color BackgroundColor { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some spacing corrections

/// <summary>
/// Gets or sets the background color of the window.
/// </summary>
/// <value>The background color.</value>

@Arc-huangjingtong
Copy link
Contributor Author

Regarding the function of opacity, it seems to be working well, and then the function of designing window transparency. Unfortunately, I have to start working and will continue to develop it next weekend. :)

@Arc-huangjingtong
Copy link
Contributor Author

I'm research how to make Stride support transparent backgrounds, the backgroundColor is same as SplashScreenColor in GameSettingsAsset.
SO, that API(backgroundColor) ,will remove.

The following is my progress.....

if we change form.backColor or SplashScreenColorwith alpha , the backgroundcolor in screen will not change ,

and we set
drawContext.CommandList.Clear(drawContext.CommandList.RenderTarget,new Color4(1, 1, 0, 0));
in project jumpyJet , the scrren background color will be yellow

After several hours of research, I find the key point....

If we want to support transparet, we should change code in file SwapChainGraphicsPresenter.Direct3D line 460,

var description = new SwapChainDescription
{
     ModeDescription = new ModeDescription(Description.BackBufferWidth, Description.BackBufferHeight, 
Description.RefreshRate.ToSharpDX(), (DXGI_Format)swapchainFormat)
     , BufferCount     = bufferCount
     , // TODO: Do we really need this to be configurable by the user?
     OutputHandle      = handle
     , SampleDescription = new SampleDescription((int)Description.MultisampleCount, 0)
     , SwapEffect        = useFlipModel ? SwapEffect.FlipDiscard : SwapEffect.Discard
     , Usage             = Usage.BackBuffer | Usage.RenderTargetOutput
     , IsWindowed        = true
     , Flags             = GetSwapChainFlags()
     ,
};

SwapChainDescription is not support alphamode , if we want ,we should replace it by SwapChainDescription1

These modifications will bring about significant changes. Perhaps we should have a more detailed discussion

@Arc-huangjingtong
Copy link
Contributor Author

Now , I delete the "BackgroundColor" API , it will change in other PR :)

@Arc-huangjingtong Arc-huangjingtong marked this pull request as ready for review May 12, 2025 14:32
@Arc-huangjingtong Arc-huangjingtong changed the title WIP: feat: Add more window api feat: Add more window api May 16, 2025
@Eideren
Copy link
Collaborator

Eideren commented May 17, 2025

Looks good, anything else to add @Kryptos-FR ?

Copy link
Contributor

@VaclavElias VaclavElias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could review only XML comments. They seem to be ok now. Thanks.

@Arc-huangjingtong
Copy link
Contributor Author

I could review only XML comments. They seem to be ok now. Thanks.

Do I need to submit changes to the API document? :)

@VaclavElias
Copy link
Contributor

The API docs https://doc.stride3d.net/latest/en/api/index.html are generated automatically from the XML comments you added. Once we release new Stride NuGet packages, usually a few days after we deploy Stride Docs https://github.com/stride3d/stride-docs. We use docfx which is a static generator https://doc.stride3d.net/latest/en/contributors/documentation/index.html.

So you don't need to do anything regarding API docs.

If you would like to update the manual https://doc.stride3d.net/latest/en/manual/index.html, then a PR can be made here https://github.com/stride3d/stride-docs for the page updated or added. In this case I don't think we have any Window manual there.

@Arc-huangjingtong
Copy link
Contributor Author

The API docs https://doc.stride3d.net/latest/en/api/index.html are generated automatically from the XML comments you added. Once we release new Stride NuGet packages, usually a few days after we deploy Stride Docs https://github.com/stride3d/stride-docs. We use docfx which is a static generator https://doc.stride3d.net/latest/en/contributors/documentation/index.html.

So you don't need to do anything regarding API docs.

If you would like to update the manual https://doc.stride3d.net/latest/en/manual/index.html, then a PR can be made here https://github.com/stride3d/stride-docs for the page updated or added. In this case I don't think we have any Window manual there.

Thank you, I think I am more familiar with this process now! 😄

@Eideren Eideren merged commit d03516b into stride3d:master May 21, 2025
2 checks passed
@Eideren Eideren changed the title feat: Add more window api feat: Add Opacity to window api May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants