• Print

Author Topic: SFML lib  (Read 446 times)

659_minifly

  • Full Member
  • ***
  • Posts: 120
SFML lib
« on: March 24, 2011, 08:53:38 AM »
Is that could interessing some one :

http://www.sfml-dev.org/index.php

That is free I don't know if that will be useful for QB64 or doing something in QB64.




unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: SFML lib
« Reply #1 on: March 24, 2011, 09:36:02 AM »
Yes you can use it with QB64, Galleon used it in his OpenGl Demo.
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: SFML lib
« Reply #2 on: March 24, 2011, 09:49:42 AM »
OpenGl Demo: http://www.qb64.net/forum/index.php?topic=2125.0
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

659_minifly

  • Full Member
  • ***
  • Posts: 120
Re: SFML lib
« Reply #3 on: March 24, 2011, 09:58:25 AM »
Thanks for the infos.

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: SFML lib
« Reply #4 on: March 29, 2011, 08:48:05 AM »
Dont know how this will work out, but here is what i have done so far. I based it on Galleons opengl helper. It allows you to create a SFML window, and also close the window. If you think it should be differant in anyway, or you want part of sfml wrapped to qb64 please let me know as i can but try.

So to make it work, download galleons opengl demo package and extract it to your qb64 folder as it instructs.

Put this code in SFML_Wrapper01.h
Code: [Select]
#include <SFML/Graphics.hpp>

sf::RenderWindow App;

void Create_Window(int32 sx,int32 sy, const char* title)
{
  App.Create(sf::VideoMode(sx, sy, 32), title);
  return;
}

void Check_Exit()
{
  sf::Event Event;
  while (App.GetEvent(Event))
  {
    if (Event.Type == sf::Event::Closed)
    App.Close();
  }
}
This code in WindowsWrapper01.h
Code: [Select]
//Windows API Wrapper v.01


long Window_GetHandle(const char* WindowTitle)
{
  return((long)FindWindow(NULL, WindowTitle));
}

bool Window_Minimise(const char* WindowTitle)
{
  return(CloseWindow(FindWindow(NULL, WindowTitle)));
}

bool Window_Restore(const char* WindowTitle)
{
  return(OpenIcon(FindWindow(NULL, WindowTitle)));
}

void Dialog_OpenFile(const char* fileType)
{

}

And then run this in qb64.
Code: [Select]
_TITLE "SFML Test"
x& = Window_Minimise("SFML Test")


Create_Window 800, 600, "SFML WINDOW 1"

DO


    Check_Exit 'http:// Clicking red x on SFML window exits the window only.

LOOP


DECLARE LIBRARY "SFML\libsfml-graphics", "SFML\libsfml-window", "SFML_Wrapper01"
    SUB Create_Window (BYVAL x AS LONG, BYVAL y AS LONG, Title$)
    SUB Check_Exit
END DECLARE


DECLARE LIBRARY "WindowsWrapper01"
    FUNCTION Window_GetHandle& (Title$)
    FUNCTION Window_Minimise (Title$)
    FUNCTION Window_Restore (Title$)
END DECLARE



i will work on making it do more....

Unseen
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: SFML lib
« Reply #5 on: March 29, 2011, 09:45:54 AM »
Galleon,

Why when i run this do the two images from your GL demo keep appearing on my screen? Are they embedded somewhere else? Screenshot..http://dl.dropbox.com/u/8822351/SFML_Dodgy.PNG

Qb64 code:
Code: [Select]
SCREEN _NEWIMAGE(1, 1, 32)

Create_Window 800, 600, "SFML WINDOW 1"

DO

    Check_Exit 'http:// Clicking red x on SFML window exits the window only.
    Update_Display

LOOP

DECLARE LIBRARY "SFML\libsfml-graphics", "SFML\libsfml-window", "SFML_Wrapper01"
    SUB Create_Window (BYVAL x AS LONG, BYVAL y AS LONG, Title$)
    SUB Check_Exit
    SUB Update_Display
END DECLARE

My wrapper for sfml
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

sf::RenderWindow App;

void Create_Window(int32 sx,int32 sy, const char* title)
{
  App.Create(sf::VideoMode(sx, sy, 32), title);
  return;
}

void Check_Exit()
{
  sf::Event Event;
  while (App.GetEvent(Event))
  {
    if (Event.Type == sf::Event::Closed)
    App.Close();
  }
  return;
}


void Update_Display()
{
  App.Display();
  return;
}


It just seems a bit weird to me...

Unseen
« Last Edit: March 29, 2011, 09:51:28 AM by unseenmachine »
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: SFML lib
« Reply #6 on: March 29, 2011, 11:28:00 AM »
Sorry to be a pain but, in the .h you made, and my one as i copied yours, you use a RenderWindow to create the graphics window, if i try to use a Window, it fails to compile...and i need that for opengl...as far as i know...any ideas?

p.s I have sorted the dosgy pictures thingy, i think they were being stored in some buffer and had not been cleared, dont seem to do it anymore...

Unseen
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: SFML lib
« Reply #7 on: March 29, 2011, 11:41:23 AM »
Quote
It just seems a bit weird to me...
Don't blame me, Kevin is a very special bird and you never know where he might appear!
Of course, it could just be a buffer you haven't cleared. ;)

Google: 'kevin the bird'
Something old... Something new... Something borrowed... Something blue...

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: SFML lib
« Reply #8 on: March 29, 2011, 11:44:04 AM »
I was not trying to impart blame, I think it was because i ran your demo, then started making my stuff and the images were still in a buffer somewhere. I sorted it with App.Clear(), but the RenderWindow is my main concern as it limits me to non GL stuff...
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: SFML lib
« Reply #9 on: March 29, 2011, 11:59:50 AM »
Quote
I was not trying to impart blame, I think it was because i ran your demo, then started making my stuff and the images were still in a buffer somewhere. I sorted it with App.Clear(), but the RenderWindow is my main concern as it limits me to non GL stuff...
I get it. It kinda makes you do a double-take about Window's security though, when memory of a previously running program stays around and becomes accessible to the next program launched, all in the name of saving a few micro-seconds.
Something old... Something new... Something borrowed... Something blue...

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: SFML lib
« Reply #10 on: March 29, 2011, 12:37:03 PM »
So after more reading, apparently i can use opengl with the RenderWindow, but i cant make it work yet!

SFML seems really useful, has built in support for image loading, saving, rotation, scaling and more! I will definately be looking into this one a lot more....Here's what i have so far...

SFML_Wrapper01.h (use notepad to create and save in qb64 folder)

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

sf::RenderWindow App;
sf::Color BackgroundColor = sf::Color(0,0,0,255);


void Create_Window(int32 sx,int32 sy, const char* title)
{
  App.Create(sf::VideoMode(sx, sy, 32), title);
  return;
}

void Check_Exit()
{
  sf::Event Event;
  while (App.GetEvent(Event))
  {
    if (Event.Type == sf::Event::Closed)
    App.Close();
  }
  return;
}

void Update_Display()
{
  App.Display();
  return;
}


void _CLS()
{
  App.Clear(BackgroundColor);
  return;
}


void Set_BackgroundColor(int32 R, int32 G, int32 B, int32 A)
{
  sf::Color col = sf::Color(R,G,B,A);
  BackgroundColor = col;
  return;
}

void Init_GL()
{
  App.PreserveOpenGLStates(true);

}



QB code

Code: [Select]
SCREEN _NEWIMAGE(1, 1, 32)

Create_Window 800, 600, "SFML WINDOW 1"
Set_BackgroundColor 0, 0, 180, 255
Init_GL

DO

    _CLS

    Check_Exit 'http:// Clicking red x on SFML window exits the window only.

    Update_Display

LOOP


DECLARE LIBRARY "SFML\libsfml-graphics", "SFML\libsfml-window", "SFML_Wrapper01"
    SUB Create_Window (BYVAL x AS LONG, BYVAL y AS LONG, Title$)
    SUB Check_Exit
    SUB Update_Display
    SUB _CLS
    SUB Set_BackgroundColor (BYVAL R AS LONG, BYVAL G AS LONG, BYVAL B AS LONG, BYVAL A AS LONG)
    SUB Init_GL
END DECLARE


UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

  • Print