Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [Scripting]Introduction to SFML, Part 1 of ?
Rukiri
post Sep 10 2011, 03:59 PM
Post #1


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,723
Type: Scripter
RM Skill: Advanced




Simple Fast Media Library

If you program in C++, Ruby, Python or whatever you need a library and many people as of late at Gamedev.net have been referring people to SFML. So what is SFML? It's exactly what the name suggest, simple-fast-media-library(SFML).

What I like from the start is that the main team only focuses on C/C++ that's great, there's also other bindings by users for .net, ruby, python, and even D(It's getting there but I prefer F for now). Personally don't use ruby or pythons bindings mainly due to the fact is that they don't work as "well" as they should, there's also ATI graphics card issues that are NOT a problem with the C/C++ versions. It's better if you just bind the language you want as a scripting language and leave the rest to C++ or C depending on which one you chose (C is great if your creating old school games and want to use what the original nes-snes did)

Now presumably I hope you know how to download a source and compile it to whatever you want to use for an IDE, I use Visual C++ 2010 Express as I'm not a fan of Code::Blocks. If not I'll have a blank version of SFML 1.6 pre-built for visual studio 2010 for you to use with a basic Main.cpp displaying "Hello World" on the screen.

Now a basic project for SFML is going to look something like this.
CODE
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

// Application Entry Point

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

{

    // Create the main rendering window
      sf::RenderWindow app(sf::VideoMode(640, 480, 32), "SFML Window Caption Test");

    // Application Loop
    while(app.IsOpened())
    {
 // Event Processing
 sf::Event event;
 while(app.GetEvent(event))
 {
     // Window is closed
     if(event.Type == sf::Event::Closed)
   app.Close();
     // Escape key pressed
           if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape))
           app.Close();
           // Exeample of a Key Event
     if (event.Key.Code == sf::Key::F1)
           {
             sf::Image Screen = app.Capture();
             Screen.SaveToFile("screenshot.jpg");
           }

 }

 // Clear the display
 app.Clear();
 // Update the display
 app.Display();
    }
    
    return 0;
}


Now let's talk about "events" for a moment, events are used in every language library I've used, they're in C++, they're in Ruby, and they're most certainly in Python. So what are they? They're basically actions, now if you look at the Key event(action) example you see if you press "F1" you'll save a screenshot as "screenshot.jpg" but if you were saving multiple screenshots it'd be like "screenshot_"+NUM".jpg" or something like that. Just stick to snagit for screenshots but that's basically what event actions are for.

Now in my own project I'm binding Lua with C++ as it's super fast and was made to be embedded! so when I press "M" for example it's going to call my Menu.lua file and the script will run from there. Still messing and getting to know the binding a bit more before I get too technical.

There's a ton of things you can do out of the box with SFML, 2D, 2D-HD, even 3D with openGL! The only limit as for what I can tell is your programming ability and many believe this is what's going to take over the aging SDL(Standard development library), the sheer speed alone should make people switch over.

I haven't gone much into SFML only telling you what a few things are and where to even find SFML. In the next topic I'm going to teach you how to bind Lua with C++ and your assignment will be to get it working in a SFML project!

For those who want the SFML 1.6 build for C++ you can download it here.
Size: 30.1MB
Download: Download SFML

Just to let you know there is a version 2.0 but I would hold off until it's officially released or a RC and with updated documentation and all of the current docs are for 1.6.


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 06:26 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker