Skip to content

Commit

Permalink
Simplify linking to only be in gosu.cr, added windows only linker cal…
Browse files Browse the repository at this point in the history
…ls, ran formatter, added new Gosu.clipboard/clipboard= methods
  • Loading branch information
cyberarm committed Oct 3, 2022
1 parent 4ef4123 commit b51965d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 8 deletions.
16 changes: 16 additions & 0 deletions src/gosu.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ module Gosu
# Returns version of Gosu that gosu.cr was built/tested against
VERSION = "1.2.0"

{% if flag?(:windows) %}
@[Link("gdi32")]
@[Link("user32")]
@[Link("Gosu")]
{% end %}
@[Link("gosu-ffi")]
lib GosuC
fun fps = Gosu_fps : UInt32
Expand Down Expand Up @@ -76,6 +81,9 @@ module Gosu
fun screen_height = Gosu_screen_height(window : UInt8*) : UInt32
fun available_width = Gosu_available_width(window : UInt8*) : UInt32
fun available_height = Gosu_available_height(window : UInt8*) : UInt32

fun clipboard = Gosu_clipboard() : UInt8*
fun set_clipboard = Gosu_set_clipboard(text : UInt8*)
end

# Returns the current framerate, in frames per second.
Expand Down Expand Up @@ -306,6 +314,14 @@ module Gosu
GosuC.available_height(window)
end

def clipboard : String
String.new(GosuC.clipboard(pointer))
end

def clipboard=(text : String)
GosuC.set_clipboard(text)
end

def self.color_to_drawop(color : Gosu::Color | Int64 | UInt32)
color.is_a?(Gosu::Color) ? color.gl : color
end
Expand Down
1 change: 0 additions & 1 deletion src/gosu/channel.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib ChannelC
fun channel_destroy = Gosu_Channel_destroy(pointer : UInt8*)

Expand Down
1 change: 0 additions & 1 deletion src/gosu/color.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib ColorC
fun create_color = Gosu_Color_create(color : UInt32) : UInt32
fun create_color_argb = Gosu_Color_create_argb(alpha : UInt8, red : UInt8, green : UInt8, blue : UInt8) : UInt32
Expand Down
1 change: 0 additions & 1 deletion src/gosu/font.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib FontC
fun create_font = Gosu_Font_create(line_height : Int32, name : UInt8*, font_flags : UInt32) : UInt8*

Expand Down
1 change: 0 additions & 1 deletion src/gosu/image.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib ImageC
fun create_image = Gosu_Image_create(filename : UInt8*, flags : UInt32) : UInt8*
fun create_image_from_text = Gosu_Image_create_from_text(text : UInt8*, font : UInt8*, line_height : Float64,
Expand Down
1 change: 0 additions & 1 deletion src/gosu/sample.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib SampleC
fun create_sample = Gosu_Sample_create(filename : UInt8*) : UInt8*
fun destroy_sample = Gosu_Sample_destroy(pointer : UInt8*)
Expand Down
1 change: 0 additions & 1 deletion src/gosu/song.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib SongC
fun create_song = Gosu_Song_create(filename : UInt8*) : UInt8*
fun destroy_song = Gosu_Song_destroy(song : UInt8*)
Expand Down
1 change: 0 additions & 1 deletion src/gosu/text_input.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib TextInputC
fun create_textinput = Gosu_TextInput_create : UInt8*
fun destroy_textinput = Gosu_TextInput_destroy(textinput : UInt8*)
Expand Down
1 change: 0 additions & 1 deletion src/gosu/window.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Gosu
@[Link("gosu-ffi")]
lib WindowC
fun create_window = Gosu_Window_create(width : Int32, height : Int32, window_flags : UInt32, update_interval : Float64) : UInt8*
fun window_show = Gosu_Window_show(window : UInt8*)
Expand Down

0 comments on commit b51965d

Please sign in to comment.