Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML in FreeBasic  (Read 4562 times)

0 Members and 1 Guest are viewing this topic.

Merick

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML in FreeBasic
« on: December 04, 2008, 04:09:14 pm »
I'm looking to get SFML working in FreeBASIC using the C/mingw version of the libs. Can someone explain what the -d, and -s in the filenames of the libs stand for?

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: SFML in FreeBasic
« Reply #1 on: December 04, 2008, 04:22:00 pm »
Quote from: "Merick"
Can someone explain what the -d, and -s in the filenames of the libs stand for?
The -d is for the debug versions, and the -s is for the static versions (meaning they need no SFML DLLs).

Merick

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML in FreeBasic
« Reply #2 on: December 05, 2008, 04:44:30 am »
Thank you.

I've just finished using swig to convert the headers for use with FB. I'll need to clean them up a little and do some testing, but I can probably get them uploaded in the next couple of days.

Merick

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML in FreeBasic
« Reply #3 on: December 05, 2008, 02:58:23 pm »
Alright, if anyone's interested, here's a set of headers for use with FreeBASIC. They're based off the CSFML version, and I've included the mingw import libs and dll's from the CSFML windows package (I left out the -s and -s-d versions because FB spit out a bunch of linker errors when I tried to use them)

http://freefile.kristopherw.us/uploads/merick/sfml.rar

To use these with FB, you will need to copy the SFML folder into FreeBASIC\inc, the *.a libs into FreeBASIC\lib\win32, and the dlls to wherever your compiled programs can find them.

Here is the example from the CFSML docs converted to FB syntax:

Code: [Select]
#include once "SFML/Audio.bi"
#include once "SFML/Graphics.bi"

dim as sfWindowSettings Settings => (24, 8, 0)
dim as sfVideoMode Mode => (800, 600, 32)
dim as sfRenderWindow ptr App
dim as sfImage ptr Image
dim as sfSprite ptr Sprite
dim as sfFont ptr Font
dim as sfString ptr Text
dim as sfMusic ptr Music
dim as sfEvent Event


/' Create the main window '/
App = sfRenderWindow_Create(Mode, @"SFML window", sfResize or sfClose, Settings)
if App = NULL then goto fail

/' Load a sprite to display '/
Image = sfImage_CreateFromFile("image.jpg")
if Image = NULL then goto fail

Sprite = sfSprite_Create()
sfSprite_SetImage(Sprite, Image)
 
/' Create a graphical string to display '/
Font = sfFont_CreateFromFile("arial.ttf", 50, cast(wchar_t ptr, @""))

if Font = NULL then goto fail    
   
Text = sfString_Create()
sfString_SetText(Text, "Hello SFML")
sfString_SetFont(Text, Font)
sfString_SetSize(Text, 50)
 
/' Load a music to play '/
Music = sfMusic_CreateFromFile("music.ogg")
if Music = NULL then goto fail

/' Play the music '/
sfMusic_Play(Music)
 
/' Start the game loop '/
while sfRenderWindow_IsOpened(App) = sfTrue

    /' Process events '/
    if sfRenderWindow_GetEvent(App, @Event) = sfTrue then
       
        /' Close window : exit '/
        if Event.Type_ = sfEvtClosed then
            sfRenderWindow_Close(App)
        endif
       
    endif

    /' Draw the sprite '/
    sfRenderWindow_DrawSprite(App, Sprite)
 
    /' Draw the string '/
    sfRenderWindow_DrawString(App, Text)
 
    /' Update the window '/
    sfRenderWindow_Display(App)
wend

fail:
/' Cleanup resources '/
sfMusic_Destroy(Music)
sfString_Destroy(Text)
sfFont_Destroy(Font)
sfSprite_Destroy(Sprite)
sfImage_Destroy(Image)
sfRenderWindow_Destroy(App)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML in FreeBasic
« Reply #4 on: December 05, 2008, 03:25:11 pm »
Doesn't FreeBASIC support object oriented programming? Can't you bind the C++ version of SFML directly?
Laurent Gomila - SFML developer

Merick

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML in FreeBasic
« Reply #5 on: December 05, 2008, 05:13:44 pm »
FB is heading towards OO,  but it is not yet fully implemented.  Although FB can link to c++ (or libs made by other OO compilers), it doesn't have inheritance or virtual functions (and a few other things I can't remember off the top of my head) and so it would require a bit more work to get it running than with the ansi c version.

 

anything