Giter Site home page Giter Site logo

minifb.jl's People

Contributors

aviks avatar giordano avatar github-actions[bot] avatar jebej avatar oheil avatar xiaodaigh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

minifb.jl's Issues

First call to mfb_update doesn't do anything

Might be an init problem?

MWE: Execute the following step-by-step:

window = mfb_open_ex("my display", 800, 600, MiniFB.WF_RESIZABLE)
mfb_update(window, rand(Int32, 800, 600))
mfb_update(window, ones(Int32, 800, 600).*typemax(Int32))
mfb_update(window, zeros(Int32, 800, 600))

The first call to mfb_update doesn't seem to do anything -- you'll only see a while and then a black screen.

clicking close button kills Julia Repl

Clicking the close button on a running window kills the REPL. Ctrl-C in the REPL stops the process updating the window but doesn't close the window. Clicking the close button in this case does not kill the REPL.

Julia Version 1.5.1
Commit 697e782ab8 (2020-08-25 20:08 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD EPYC 7702P 64-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, znver2)
Environment:
  JULIA_NUM_THREADS = 64
  JULIA_EDITOR = "/usr/share/code/code"

attempt to modify variable captured in a closure causes segmentation fault

When attempting to modify a field in a struct variable that is captured from the enclosing scope MiniFB crashes. If the struct variable is global then MiniFB doesn't segfault.

See the function onkeypress below for the assignment that causes the segfault.

version info:

Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD EPYC 7702P 64-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, znver2)
Environment:
JULIA_NUM_THREADS = 64
JULIA_EDITOR = "/usr/share/code/code"julia> using MiniFB

minimum working example:

julia> mutable struct Simple
           a::Float64
       end

julia> function mwe()
           width = 600
           height = 600
           window = mfb_open_ex("Luxor -> MiniFB", width, height, MiniFB.WF_RESIZABLE)
           t = Simple(1.0)

           function onkeypress(window::Ptr{Cvoid}, key::mfb_key, mod::mfb_key_mod, ispressed::Bool)
               t.a += 1 #this causes the segfault. If t is a global variable no segfault
               return nothing
           end

           mfb_set_target_fps(60)
           mfb_set_keyboard_callback(window, onkeypress)

         
           while mfb_wait_sync(window) # The Luxor `@imagematrix` macro creates a 2D matrix of Color objects in ARGB32 format, which is exactly what MiniFB requires
               buffer = Luxor.@imagematrix begin
                   Luxor.background("grey40")
               end 600 600 
               # The image matrix created by Luxor is, in standard Julia convention, column first. The buffer
               # expected by MiniFB is row first. The call to `permutedims` makes that change.
               state = mfb_update(window, permutedims(buffer, (2, 1)))
               # Exit when the user closes the window.
               if state != MiniFB.STATE_OK
                   break
               end
           end

           mfb_close(window)
       end
mwe (generic function with 1 method)

julia> mwe()

Window created using X11 API

signal (11): Segmentation fault
in expression starting at REPL[5]:1
unknown function (ip: 0x7f7e8800cfc3)
Allocations: 11027408 (Pool: 11024513; Big: 2895); GC: 24
Segmentation fault (core dumped)

malloc error and crash

julia> using MiniFB

julia> include(joinpath(pathof(MiniFB),"..","..","example","Plasma.jl"))
Window created using X11 API

# closed the window with esc after a couple seconds

julia> macro m()
       end
malloc(): mismatching next->prev_size (unsorted)

signal (6): Aborted
in expression starting at none:0

Why is `mfb_update_ex' not exposed within the wrapper?

The example used in the repository for minifb uses the function mfb_update_ex. This function slightly differs from from mfb_update, as it includes 2 extra arguments stating the current size of the frame buffer.

Why is this function missing from the Julia API? I could not locate the function within the dylib located within the Artifacts folder.

Thanks!

'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'

Tried to run the code example here: https://juliagraphics.github.io/Luxor.jl/dev/howto/livegraphics/

("Open and run the first window in its own thread:")

Got this:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'
*** First throw call stack:
libc++abi: terminating due to uncaught exception of type NSException
[30629] signal (6): Abort trap: 6
in expression starting at none:0
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)

Handling (?) the Escape key (MacOS)

I find that closing the window created by MiniFB using the Close button works OK, but if I press Escape, the Julia process seems to get "stuck". Is there a way of disabling or ignoring Escape?

Might be a Mac-only thing i suppose..

How to use mfb_get_mouse_button_buffer and mfb_get_key_buffer?

I'm trying to get mouse button and key press information for the window without using callbacks.

I'm using the following functions:

mouse_button_buffer = MFB.mfb_get_mouse_button_buffer(window)
key_buffer = MFB.mfb_get_key_buffer(window)

They both are of type Ptr{UInt8}. How do I actually use them to know if and which a key / mouse button has been pressed?

Also, nothing seems to happen to the unsafe_loaded values when I press or mouse buttons or keyboard keys. Is that the correct way to use these functions?

Full code available at https://github.com/Sid-Bhatia-0/SimpleIMGUIExample/tree/00e52da38c97e0753711fe9d8c1d546239461e04.

When/How does this package get new releases?

First of all, thank you for creating this wrapper package. I really like the simplicity of minifb.

On the minifb repository, I see commits in the source code that are more recent than the last release of MiniFB.jl.

I am not familiar with how MiniFB.jl was created from minifb, so this is a beginner level question. I am curious to know when and how would MiniFB.jl incorporate changes from the original minifb library? I saw that there is MiniFB_jll, but even over there, the last commit seems to be long back.

Thanks.

Does not work on Arch linux with system /usr/lib/libstdc++.so.6.0.30

Problem

When I install MiniFB on julia 1.8 (taken the original binary build from the official julia website) I get the following error.

julia> mfb_open_ex("My Window", 400, 400, MiniFB.WF_RESIZABLE)
libGL error: MESA-LOADER: failed to open radeonsi: /usr/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/dri/radeonsi_dri.so) (search paths /usr/lib/dri, suffix _dri)
libGL error: failed to load driver: radeonsi
libGL error: MESA-LOADER: failed to open swrast: /usr/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/dri/swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
X Error:  BadMatch
  Request Major code 150 (GLX)
  Request Minor code 5 ()
  Error Serial #41
  Current Serial #41

Workaround

Replacing the symlink in /usr/lib/julia for libstdc++.so.6 which points to libstdc++.so.6.0.29 with the system library (libstdc++.so.6.0.30) I can get MiniFB to work.

cd /usr/lib/julia/
sudo rm libstdc++.so.6 
sudo ln -s /usr/lib/libstdc++.so.6.0.30 libstdc++.so.6

System

[cc649173] MiniFB v0.1.1
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 16 ร— AMD Ryzen 7 5700X 8-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, znver3)
Threads: 1 on 16 virtual cores

Add helper methods for callback functions

Would you be interested in having helper methods to set the callback functions which automatically create the function pointer with @cfunction ? Since the signature is fixed by the library we can just assume that the user is passing a valid method.

Eg. we could define:

function mfb_set_keyboard_callback(window, keyboard::Function)
    keyboard_c = @cfunction(keyboard, Cvoid, (Ptr{Cvoid}, mfb_key, mfb_key_mod, Bool))
    mfb_set_keyboard_callback(window, keyboard_c)
end

Let me know if that would be good to have, and if the naming, or something else would need to be changed

Cannot draw anything transparent (non trivial alpha)

I am not able to produce a partially transparent drawing, no matter which value for alpha i use

example:

using MiniFB

WIDTH=800
HEIGHT=600
window = mfb_open_ex("My Window", WIDTH, HEIGHT, MiniFB.WF_RESIZABLE)

buffer = zeros(UInt32, WIDTH*HEIGHT)
alpha = 0
while true
    
    x = reinterpret(UInt32, [UInt8(100),UInt8(0),UInt8(0), UInt8(alpha%255)])[1]
    alpha += 1
    buffer = fill(x, WIDTH*HEIGHT)

    state = mfb_update(window,buffer)
    if state != MiniFB.STATE_OK
        break
    end
end

The window does not close on wayland

When testing the example Noise.jl on wayland the window does not close after pressing the close button.
The function noise() however is terminates.

System

[cc649173] MiniFB v0.1.1

Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 16 ร— AMD Ryzen 7 5700X 8-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, znver3)
Threads: 1 on 16 virtual cores

wayland 1.21.0-1

Can't close window; forcing it kills Julia

This is on OpenBox on X11 and Linux, with Julia 1.5.1, running the "plasma" example.

The window comes up and I can see the visualization. Clicking on the window's "close" button does nothing. Forcing it to close from the window manager, I get this:

  • Right-clicking on the taskbar and selecting "close":
julia> plasma()
Window created using X11 API
X connection to :0 broken (explicit kill or server shutdown).
0[~] $
  • Sending the window a "close" command via a keyboard shortcut:
julia> plasma()
Window created using X11 API
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 1481 requests (1477 known processed) with 0 events remaining.
0[~] $

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.