Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a background color for the window when opening it, before starting the rendering #2725

Closed
1 of 10 tasks
mat007 opened this issue Aug 16, 2023 · 2 comments
Closed
1 of 10 tasks

Comments

@mat007
Copy link
Contributor

mat007 commented Aug 16, 2023

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • Xbox
  • Web Browsers

What feature would you like to be added?

A way to control the initialization of the window when the game opens up, e.g. at least be able to set a color.

Why is this needed?

My game intro screen has a black background, and when launching it, there is a not very pleasing white background that flashes in the window, before the first draw.

This can be reproduced by running the paint example with the following changes:

diff --git a/examples/paint/main.go b/examples/paint/main.go
index de3b5df1..362977b0 100644
--- a/examples/paint/main.go
+++ b/examples/paint/main.go
@@ -27,8 +27,8 @@ import (
 )

 const (
-       screenWidth  = 640
-       screenHeight = 480
+       screenWidth  = 1024
+       screenHeight = 768
 )

 var (
@@ -76,7 +76,7 @@ func NewGame() *Game {
        g := &Game{
                canvasImage: ebiten.NewImage(screenWidth, screenHeight),
        }
-       g.canvasImage.Fill(color.White)
+       g.canvasImage.Fill(color.Black)
        return g
 }

The bigger the window, the more visible it seems to be.

@hajimehoshi
Copy link
Owner

I am not sure this is controllable. Let me investigate this

@hajimehoshi hajimehoshi added this to the v2.7.0 milestone Aug 17, 2023
@mat007
Copy link
Contributor Author

mat007 commented Aug 19, 2023

Thanks @hajimehoshi !

On Windows I believe it could just be doing

wc.hbrBackground = …

in

func registerWindowClassWin32() error {
passing it a brush.

But I have no clue for other platforms.

I’m also thinking I could perhaps delay the showing of the window after it’s been created somehow, to make sure there is at least one rendering that’s been done?

theinternetftw added a commit to theinternetftw/ebiten that referenced this issue Dec 29, 2023
Fixes hajimehoshi#2725 by avoiding the flash in the first place. Showing the
window this way was already default on macOS; This makes it default
for all glfw platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants