Available functions

MiniFB.mfb_openFunction
mfb_open(title, width, height)

Create a window that is used to display the buffer sent into the mfb_update function, returns 0 if fails

MiniFB.mfb_open_exFunction
mfb_open_ex(title, width, height, flags)

Create a window, with flags

MiniFB.mfb_updateFunction
mfb_update(window, buffer)

Update the display. Input buffer is assumed to be a 32-bit buffer of the size given in the open call. Will return a negative status if something went wrong or the user want to exit. Also updates the window event

MiniFB.mfb_update_eventsFunction
mfb_update(window)

Only updates the window events. Either mfb_update or mfb_update_events must be called in a loop to clear the event queue.

MiniFB.mfb_set_user_dataFunction
mfb_set_user_data(window , user_data::Ptr{Cvoid})

Set a per-window user data. Data is supplied as a pointer. The data at the end of that pointer should be prevented from garbage collection.

Example

x=Ref(2)
mfb_set_user_data(w, x)

See also: mfb_get_user_data

MiniFB.mfb_get_user_dataFunction
mfb_get_user_data(window)::Ptr{Cvoid}

Retrive the user data associated with this window. The return value is a void pointer that should be derferenced

Example

g=mfb_get_user_data(w)
unsafe_load(convert(Ptr{Int}, g)) # 2

See also: mfb_set_user_data

MiniFB.mfb_set_viewportFunction
mfb_set_viewport(window, offset_x, offset_y, width, height)

Set viewport (useful when resize)

MiniFB.mfb_timer_createFunction
mfb_timer_create()

Create a timer. Returns an opaque pointer that should be stored, and passed to subsequent timer related calls.

MiniFB.mfb_rgbFunction
mfb_rgb(r, g, b)::UInt32

convert 8 bit color channels to a single 32 bit buffer. Input should be integers 0-255

mfb_rgb(c::Colorant)::UInt32

convert a color object from Colors.jl into a 32 bit buffer.

Callback signatures

These are the callback signatures used by the C library when signalling events. The Julia function should be written accordingly, and wrapped with a @cfunction before passing on to the library. See the Image Viewer example for more detail.

active

active(window::Ptr{Cvoid}, isActive::Uint8)

resize

resize(window::Ptr{Cvoid}, width::Cint, height::Cint)

keyboard

keyboard(window::Ptr{Cvoid}, key::mfb_key, mod::mfb_key_mod, isPressed::Uint8)

char_input

char_input(window::Ptr{Cvoid}, charCode:Cuint)

mouse_btn

mouse_btn(window::Ptr{Cvoid}, button::mfb_mouse_button, mod::mfb_key_mod, isPressed::Uint8)

mouse_move

mouse_move(window::Ptr{Cvoid}, x::Cint, y::Cint)

mouse_scroll

mouse_scroll(window::Ptr{Cvoid}, mod::mfb_key_mod, deltaX::Cfloat, deltaY::Cfloat)