A dead simple 2D game library for Go

Overview

Ebiten (v2)

PkgGoDev Build Status Build Status Go Report Card

A dead simple 2D game library for Go

Ebiten is an open source game library for the Go programming language. Ebiten's simple API allows you to quickly and easily develop 2D games that can be deployed across multiple platforms.

Overview

Platforms

Note: Gamepad and keyboard are not available on Android/iOS.

For installation on desktops, see the installation instruction.

Features

  • 2D Graphics (Geometry/Color matrix transformation, Various composition modes, Offscreen rendering, Fullscreen, Text rendering, Automatic batches, Automatic texture atlas)
  • Input (Mouse, Keyboard, Gamepads, Touches)
  • Audio (Ogg/Vorbis, MP3, WAV, PCM)

Packages

Community

Slack

#ebiten channel in Gophers Slack

License

Ebiten is licensed under Apache license version 2.0. See LICENSE file.

Issues
  • Fullscreen broken on X11 with HiDPI

    Fullscreen broken on X11 with HiDPI

    Repro:

    • Set display DPI to something other than 96: echo Xft.dpi: 144 | xrdb -merge
    • Run examples/windowsize
    • Press F

    Observe that a large part of the screen is cut off (see screenshots).

    20210820-100222 20210820-100226

    Note how Xft.dpi does not influence the Device Scale Factor, but it does change the initial window size and causes this weird fullscreen scale up.

    Reproduced on:

    • X11/i3
    • Wayland/Sway/Xwayland

    Does NOT reproduce on:

    • Cinnamon

    Most likely because ebiten has its own support for querying device scale that is specific to Cinnamon and GNOME, while not supporting anything else; at the same time, glfw has its different support and these two disagree.

    Maybe we should just always use glfw's content scale?

    Note though:

    // deviceScaleFactor() is a scale by desktop environment (e.g., Cinnamon), while GetContentScale() is X's scale.
    

    I do not quite understand this - when do these two ever differ, except when there simply is no desktop environment managing this at all? In fact, do we ever handle the case of these two differing right?

    bug os:linux 
    opened by divVerent 45
  • Regression: invisible window, wrong fullscreen size

    Regression: invisible window, wrong fullscreen size

    On my system (Linux/Sway/XWayland), 77664ff0575c8f51e1ba5cd3604a57808fbf95f4 causes a regression:

    • Before the commit, Ebiten windows get created on the correct screen and get centered correctly.
    • After the commit, I don't get any visible window, and in fullscreen it displays too small in the bottom left corner.

    Commenting out the initializeWindowAfterCreation(window) in createWindow() fixes it, although I do not yet know why. What the function does looks reasonable to me (other than the window being way too small, 16x16).

    Checking with xwininfo reveals that the window actually gets created but outside the visible area of my dual screen setup. Fullscreen oddly uses the wrong size.

    I suggest backing out the commit for now, unless it fixes similar issues on other systems. Or maybe have it temporarily controlled by an environment variable until fixed for good?

    bug os:linux 
    opened by divVerent 41
  • Immediate crash when running gamepad example locally

    Immediate crash when running gamepad example locally

    I'm running Void Linux. I copied the code for the gamepad example and removed the // +build example jsgo. It compiles, but upon running it immediately crashes.

    Error Log

    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    GLFW: An uncaught error has occurred: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    GLFW: Please report this bug in the Go package immediately.
    panic: InvalidValue: Invalid button in gamepad mapping 030000004c050000cc09000011810000 (PS4 Controller)
    
    goroutine 1 [running]:
    github.com/go-gl/glfw/v3.3/glfw.acceptError(0xc00015de58, 0x1, 0x1, 0xc00016a120, 0xc00000e160)
    	/home/semi/go/src/github.com/go-gl/glfw/v3.3/glfw/error.go:174 +0x216
    github.com/go-gl/glfw/v3.3/glfw.Init(0xddf27cfb, 0xb94fc6b71120b9e0)
    	/home/semi/go/src/github.com/go-gl/glfw/v3.3/glfw/glfw.go:37 +0x54
    github.com/hajimehoshi/ebiten/internal/glfw.Init(...)
    	/home/semi/go/src/github.com/hajimehoshi/ebiten/internal/glfw/glfw_notwindows.go:291
    github.com/hajimehoshi/ebiten/internal/uidriver/glfw.initialize(0xc0001005a0, 0xc000100570)
    	/home/semi/go/src/github.com/hajimehoshi/ebiten/internal/uidriver/glfw/ui.go:129 +0x26
    github.com/hajimehoshi/ebiten/internal/uidriver/glfw.init.1()
    	/home/semi/go/src/github.com/hajimehoshi/ebiten/internal/uidriver/glfw/ui.go:119 +0x22
    
    bug external 
    opened by semilin 38
  • cmd/ebitenmobile: support current NDK

    cmd/ebitenmobile: support current NDK

    Hi,

    I've installed a fresh Android Studio with NDK 24.0.8215888. When trying to use ebitenmobile, I get:

    $ export ANDROID_HOME=$HOME/Android/Sdk
    $ export ANDROID_NDK_HOME=$HOME/Android/Sdk/ndk/24.0.8215888
    $ go run github.com/hajimehoshi/ebiten/v2/cmd/ebitenmobile \
    	bind -target android -javapkg io.github.divverent.aaaaxy.android \
    	-androidapi 21 \
    	-o aaaaxy.aar \
    	github.com/divVerent/aaaaxy/internal/mobile
    2022/05/02 09:20:33 gomobile [init] failed: gomobile: No compiler for 386 was found in the NDK (tried /home/rpolzer/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android16-clang). Make sure your NDK version is >= r19c. Use `sdkmanager --update` to update it.
    

    I do not know why it tries to search SDK 16 binaries (and for x86 even, which is an odd platform for Android); this NDK comes with versions 21 to 32 for aarch64 and x86_64, as well as 19 to 32 for armv7a and i686.

    I would assume that passing -androidapi sets which NDK binaries it'll use, but to no avail.

    In general, the ebitenmobile instructions could be a LOT clearer - many things in there I just do not understand and will have to figure out by trial and error, not being an Android developer myself.

    bug os:android external 
    opened by divVerent 34
  • graphics: Shader API

    graphics: Shader API

    EDIT: There is a proposal document for the shader language:

    https://docs.google.com/document/d/1yVfqWY6B-yF0H3NOVff3r791_n2zUu8BUWdW9TuEorw/edit?usp=sharing


    In Unity, there is a converter from HLSL to GLSL for portability

    https://docs.unity3d.com/Manual/SL-ShadingLanguage.html

    feature request 
    opened by hajimehoshi 34
  • graphics: HTML5-Canvas-like API

    graphics: HTML5-Canvas-like API

    Random note

    How to implement

    For simple primitives, GLSL would work. For complex things like filling polygon, GLSL would also work but stencil buffers might be better.

    Or, how about implementing scan-line algorithm on GLSL without vertices?

    What kind of features there are in HTML5 Canvas

    Ref: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D

    • Shapes / Paths

      • Line
      • Rectangle
      • Polygon
      • Arc
        • Circle
        • Ellipse
      • Bezier Curve
      • Quadratic Curve
    • Line style

      • Width
      • Cap
      • Join
      • Miter Limit
      • Dash
    • Fill/Stroke Style

      • Solid
      • Gradient
      • Pattern
    • Shadow

      • Blur
      • Color
      • Offset
    • Paths

      • Fill (non-zero / even-odd) (NanoVG supports only even-odd)
      • Stroke
      • Clip
    • Others

      • imageSmoothingEnabled (Anti alias)

    I don't think we need all the above items though...

    Text

    As for text rendering, we already have github.com/hajimehoshi/ebiten/text and that's fine. For true type fonts, using bezier curves might be more effective, but the text package accepts more general font.Face interface, that can be any rasterized data.

    Filling pattern / Clip

    We already have composition modes, so I don't think we need API to specify complex filling pattern and clipping. Just filling with a solid color might be enough.

    Actual use cases

    I need actual use cases before considering API. This is similar way to Go2 language change.

    • Prototyping
    • Graphs or charts
    • UI
    feature 
    opened by hajimehoshi 33
  • Add a single-thread mode by introducing a new build tag

    Add a single-thread mode by introducing a new build tag

    This project is super cool so I finally started porting the cp-examples over to ebiten. With vsync off I noticed the ebiten tumble ran much slower than the cp-example tumble that builds the triangles every single frame.

    The cp-example was getting ~1600 FPS and ebiten was at ~600 FPS.

    So I did some profiling and noticed some channel related locks. From what I understand most game engines are single threaded, so I removed the threading and the ebiten version is now getting ~2100 FPS.

    Is there a specific design decision that lead to threading in the GLFW code? If there's a good reason maybe add an option to disable threading to unlock peak performance?

    performance 
    opened by jakecoffman 32
  • Dual monitor setups on Windows with different windows scaling

    Dual monitor setups on Windows with different windows scaling

    When you're running an app produced on windows when you have 2 different scaling options the game resizes based on what the active window is rather than what desktop it's on.

    image

    image

    https://user-images.githubusercontent.com/111667/136635776-6c38c056-e4d3-4385-8fbc-3af684361458.mp4

    See video.. All I'm doing is switching window (not ebiten related either). Between display 1 and 2.

    It seems it's basing it's internal scaling based on what the active window is. I don't often program using windows api so I can't tell you what the solution is. But some testing with another app shows that: https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-windowposchanged is triggered with SWP_NOSIZE when I move a window between the two. (But not my field.)

    Sorry originally logged on wrong repo: https://github.com/ebiten/ebiten.org/issues/63

    bug os:windows 
    opened by arran4 30
  • Keyboard key press and key release events

    Keyboard key press and key release events

    Add a way to detect a key press event and a key release event.

    In my particular problem I am trying to toggle the display of debug information on screen. I have a global var debug bool. It is being toggled when I press D:

    if ebiten.IsKeyPressed(ebiten.KeyD) {
        debug = !debug
    }
    

    the debug information is displayed:

    if debug == true {
        ebitenutil.DebugPrint(…)
    }
    

    Problem here is that at each iteration of the main loop debug is toggled at about 60 Hz… A key press and release events would help to solve that.

    bug os:linux help-wanted external 
    opened by yuvallanger 26
  • panic while accessing gamepadButtonDurations

    panic while accessing gamepadButtonDurations

    The following error occurs when running a blank application (nothing drawn/updated) on the latest master (likely caused by c95049b).

    panic: runtime error: index out of range [32] with length 32
    
    goroutine 5 [running]:
    github.com/hajimehoshi/ebiten/inpututil.(*inputState).update(0xb50f20)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/inpututil/inpututil.go:122 +0xdc6
    github.com/hajimehoshi/ebiten/inpututil.init.0.func1(0x0, 0x0)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/inpututil/inpututil.go:64 +0x2d
    github.com/hajimehoshi/ebiten/internal/hooks.RunBeforeUpdateHooks(0x0, 0x0)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/internal/hooks/hooks.go:38 +0xb8
    github.com/hajimehoshi/ebiten.(*uiContext).update(0xb50d20, 0x0, 0x0)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/uicontext.go:287 +0xe7
    github.com/hajimehoshi/ebiten.(*uiContext).Update(0xb50d20, 0xc00005de10, 0x8d0000)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/uicontext.go:241 +0xaa
    github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).update(0xb132e0, 0x20001, 0x1)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/internal/uidriver/glfw/ui.go:816 +0x266
    github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).loop(0xb132e0, 0x0, 0x0)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/internal/uidriver/glfw/ui.go:862 +0xcb
    github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).run(0xb132e0, 0x0, 0x0)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/internal/uidriver/glfw/ui.go:731 +0x2e4
    github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).Run.func1(0xc000098410, 0xc0000b4180, 0xb132e0)
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/internal/uidriver/glfw/ui.go:568 +0x6b
    created by github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).Run
    	/home/trevor/go/pkg/mod/github.com/hajimehoshi/[email protected]/internal/uidriver/glfw/ui.go:565 +0x17b
    
    bug os:linux os:windows 
    opened by tslocum 25
  • internal/graphicsdriver/opengl: remove CGO in opengl for macOS

    internal/graphicsdriver/opengl: remove CGO in opengl for macOS

    internal/os/dl is an implementation of some of dlfcn.h functions (right now just dlsym) in pure go.

    internal/os/syscall contains 4 functions that call a C function handle in pure go. The code is an adaptation of code from runtime/sys_darwin_arm64.s & runtime/sys_darwin_amd64.s. It works by doing the necessary steps required to call C and then calls a psuedo C function written in go assembly instead of a CGO generated C function. This pseudo C function places the arguments in the spot where the C function expects them and then calls the C functions.

    This is the beginning of converting the darwin portion of ebiten to a pure Go implementation. The benefits of doing so is a smaller executable (because there is no C function for every C call), faster compilation, and eventually cross-compilation. This also lays down the foundation to remove CGO from other unix platforms that have dlfcn.h. All that would need to be done would be to add internal/dl/dl_GOOS.go that links into the unix's libc implementation and then write an implementation of the SyscallX functions for each GOOS and GOARCH.

    The only downside to the way this is accomplished is that it uses pragmas such as //go:linkname and //go:cgo_import_dynamic which are used extensively in the go runtime and cgo respectively. There is also a need to maintain the assembly code but that should be easy to match up with the runtime.

    opened by TotallyGamerJet 24
  • proposal: add `NoCopy` field to new `ImageOptions`

    proposal: add `NoCopy` field to new `ImageOptions`

    With the addition of the new NewImageOptions struct we could also add a flag to try to avoid unnecessary copies during Ebitengine's image creation. It's very common that standard Golang image.Image images are only created to be passed to Ebitengine's image initialization, so allocating a new buffer for the data and copying it, when the format is already compatible (RGBA images), is wasteful.

    ebitenutil.NewImageFrom* functions and well as many Ebitengine related libraries could often benefit from this.

    The downsides are:

    • More surface area for NewImageOptions. But I don't think this is out of place there.
    • We may be worrying too much about optimization here. But I'd say seeking to eliminate redundant allocations is quite fair.
    • Only works with image.RGBA, and this on itself also kinda exposes internal implementation details.
    • Safety: if users continue using the image data slices anyway, they will get in trouble. To me this is the strongest argument against this proposal. I personally don't think anyone would have any right to complain if they misuse this feature, but it's true that Ebitengine typically goes out of its way to avoid such situations, and this kinda opens a door for undetected misuse (well, Golang doesn't really prevent developers from manually creating such doors anyway with raw pointers, but you know...).
    feature request 
    opened by tinne26 2
  • internal/graphicsdriver/metal: use MTLFence to sync engines correctly

    internal/graphicsdriver/metal: use MTLFence to sync engines correctly

    My understanding is that there are a 'copy' engine and a '3d' engine like DirectX: https://docs.microsoft.com/en-us/windows/win32/direct3d12/user-mode-heap-synchronization

    We need to sync them correctly with MTLFence rather than WaitUntilCompleted.

    os:macos os:ios needs-investigation 
    opened by hajimehoshi 0
  • internal/graphicsdriver/directx: fix fence usages

    internal/graphicsdriver/directx: fix fence usages

    The current fence usages might be wrong. For example, there are two fences but the Microsoft GDK official examples only have one. Let's investigate how to use fences correctly.

    Potentially related issues:

    • #2034
    • #2138
    bug os:windows needs-investigation 
    opened by hajimehoshi 0
  • ebiten: `ScreenSizeInFullscreen` should return a monitor size on browsers

    ebiten: `ScreenSizeInFullscreen` should return a monitor size on browsers

    As there is a fullscreen mode on browsers, ScreenSizeInFullscreen should return a monitor size instead of a window frame size.

    diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go
    index a73dd24c4..93f206b9a 100644
    --- a/internal/ui/ui_js.go
    +++ b/internal/ui/ui_js.go
    @@ -99,6 +99,7 @@ func init() {
     var (
            window                = js.Global().Get("window")
            document              = js.Global().Get("document")
    +       screen                = js.Global().Get("screen")
            canvas                js.Value
            requestAnimationFrame = js.Global().Get("requestAnimationFrame")
            setTimeout            = js.Global().Get("setTimeout")
    @@ -119,7 +120,7 @@ func init() {
     }
     
     func (u *userInterfaceImpl) ScreenSizeInFullscreen() (int, int) {
    -       return window.Get("innerWidth").Int(), window.Get("innerHeight").Int()
    +       return screen.Get("width").Int(), screen.Get("height").Int()
     }
    

    As this is a breaking-change, I'll introduce the fix to v3.

    bug os:js breaking-change 
    opened by hajimehoshi 0
Releases(v2.3.4)
Owner
Hajime Hoshi
Software Engineer
Hajime Hoshi
Simple 2D game to teach myself various things about game development and ECS, etc

2d-grass-game I really don't know what to name this game. Its a big grass field, and its in 2d so....2D Grass game This is a simple 2D game to teach m

James Wynne III 1 Jan 17, 2022
Arkanoid game in Go using Ebiten game engine with ECS.

Arkanoid-go Arkanoid game in Go using Ebiten game engine with ECS. You must have Git LFS installed when cloning the repository to download assets. See

null 56 Apr 2, 2022
AircraftWar - a game powered by Go+ spx game engine

AircraftWar - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download thi

GoPlus 1 Jan 5, 2022
FlappyCalf - a game powered by Go+ spx game engine

FlappyCalf - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this

GoPlus 2 Jan 10, 2022
FlappyCalf - a game powered by Go+ spx game engine

FlappyCalf - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this

GoPlus 2 Jan 10, 2022
MazePlay - a game powered by Go+ spx game engine

MazePlay - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this g

GoPlus 1 Dec 16, 2021
RundQuiz-Game - This is a Go exercise that implements and builds a quiz game from a list of math questions in a CSV file.

Go RundQuiz Game Exercise details This exercise is broken into two parts to help simplify the process of explaining it as well as to make it easier to

IkehAkinyemi 0 Jan 5, 2022
A hand-crafted 2D game library in Go

Pixel A hand-crafted 2D game library in Go. Take a look into the features to see what it can do. go get github.com/faiface/pixel If you are using Mod

Michal Štrba 4k Jun 28, 2022
Rock-paper-scissors game library

jankensheep Rock-paper-scissors game library Examples Play with two players:

Genta Kamitani 6 May 13, 2022
Golang writen 3D render library and some game-relative concepts

Golang writen 3D render library and some game-relative concepts.

null 2 Jun 6, 2022
Battleblips - Work in progress multiplayer terminal base battleship game written in Go (with mouse support!) using tcell library

battleblips Work in progress multiplayer terminal base battleship game written in Go (with mouse support!) using tcell library (see https://github.com

null 1 Apr 26, 2022
Spaceshooter - A port to go of the pygame Space Shooter game using the ebiten library

Space Shooter This is a port to go of the pygame Space Shooter (https://github.c

Jesús Espino 4 Apr 28, 2022
Simple 2D game prototyping framework.

prototype Simply prototype 2D games using an easy, minimal interface that lets you draw simple primitives and images on the screen, easily handle mous

null 71 May 25, 2022
Bampf is a simple 3D arcade style game. Collect Energy Cores in order to finish a level. Teleport (bampf) to safety or use cloaking abilities to avoid Sentinels.

Bampf Bampf is a simple 3D arcade style game. Collect energy cores in order to finish a level. Teleport (bampf) to safety or use cloaking abilities to

null 39 Apr 7, 2021
This is a "simple" game server. Main functionalities are matching and establishing a connection between players

Game Server This is a "simple" game server. Main functionalities are matching and establishing a connection between players How to Run? run the server

eco 7 Feb 6, 2022
Simple rule based matchmaking for your online game with support of Redcon(RESP) protocol.

Simple Matchmaking Simple rule based matchmaking for your online game with support of Redcon(RESP) protocol. 1- Simple Match Rule Easiest usage of sys

Fatih Kahveci 74 Apr 19, 2022
A simple desktop snake game

A simple desktop snake game that's supposed to run on Linux and Mac OS (maybe eventually on Windows). Work on the game is currently in progress - so i

Meghashyam Chirravoori 2 Oct 12, 2021
Simple word guessing game written in golang.

Word Guessing Game Simple word guessing game written in golang. successTexts := []string{ "You guessed right! ????????", "Correct! ✅", "Horray!

Mahmudul Hasan 1 Oct 19, 2021
Simple moonlander like game with some new mechanics

Space Crane game Controls Arrows - control ship engines Q/A - wind/unwind crane chain Tab - capture cargo Screenshots Features Levels Levels are simpl

Maxim Kozlov 14 Jun 11, 2022