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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - santiaboy

Pages: [1] 2
1
Hey guys, I think I found a bug when upscaling a smoothed texture. I tried replicating with a small example: The attached "upscalingBug.png" can be seen as three 64x64 squares. I render the middle square twice.

As far as I can see, if the RectangleShape is bigger than the textureRect it causes to render part of the neighbour if and only if the texture is smoothed. It results in this:



I saw a couple of threads in this vein, and those threads had movement and floating point error. I am rendering the squares on ints, and their size is ints.

Any idea what may be causing this? I thought about:
  • Something about smoothing texture and floating point arithmetic?
  • The image is wrong (unlikely as I tried a couple different, but hey it is a possibility)
  • This is "intented", as it is what OpenGL does.
  • An actual SFML bug

Cheers!

Example code:
#include <SFML/Graphics.hpp>

int main()
{
    int tilesize = 64;
    sf::RenderWindow window(sf::VideoMode(1280, 720), "upscaleBug?");

    sf::Texture texture;
    texture.loadFromFile("upscalingBug.png");
    ///Comment to watch the line dissapear
    texture.setSmooth(true);

    ///Setting up rectangles. Uncomment if you want to see 1:1 and 0.5:1
/*
    sf::RectangleShape rectSmall(sf::Vector2f(tilesize / 2,tilesize / 2));
    rectSmall.setPosition(50,50);
    rectSmall.setTexture(&texture);
    rectSmall.setTextureRect(sf::IntRect(tilesize,0,tilesize,tilesize));

    sf::RectangleShape rectSmall2(sf::Vector2f(tilesize / 2,tilesize / 2));
    rectSmall2.setPosition(82,50);
    rectSmall2.setTexture(&texture);
    rectSmall2.setTextureRect(sf::IntRect(tilesize,0,tilesize,tilesize));

    sf::RectangleShape rect(sf::Vector2f(tilesize,tilesize));
    rect.setPosition(50,100);
    rect.setTexture(&texture);
    rect.setTextureRect(sf::IntRect(tilesize,0,tilesize,tilesize));

    sf::RectangleShape rect2(sf::Vector2f(tilesize,tilesize));
    rect2.setPosition(114,100);
    rect2.setTexture(&texture);
    rect2.setTextureRect(sf::IntRect(tilesize,0,tilesize,tilesize));
*/

    sf::RectangleShape rectBig(sf::Vector2f(tilesize * 2,tilesize * 2));
    rectBig.setPosition(50,200);
    rectBig.setTexture(&texture);
    rectBig.setTextureRect(sf::IntRect(tilesize,0,tilesize,tilesize));

    sf::RectangleShape rectBig2(sf::Vector2f(tilesize * 2,tilesize * 2));
    rectBig2.setPosition(178,200);
    rectBig2.setTexture(&texture);
    rectBig2.setTextureRect(sf::IntRect(tilesize,0,tilesize,tilesize));

    ///Regular SFML Loop
    while (window.isOpen()){
        sf::Event event;
        while (window.pollEvent(event)){
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color::White);
        /*window.draw(rectSmall);
        window.draw(rectSmall2);
        window.draw(rect);
        window.draw(rect2);*/

        window.draw(rectBig);
        window.draw(rectBig2);
        window.display();
    }

    return 0;
}
 

2
Graphics / New renderWindow makes main renderWindow white
« on: August 27, 2014, 10:26:34 pm »
Hey guys, I encountered a bit of an issue. I want to create a new renderWindow so I can manipulate images, but when I do it the screen flashes. It is different depending on the main window style (none, closed or fullscreen).
None/closed: the screen flashes for a really short (but noticeable) time and then regains focus
Fullscreen: the screen goes white for a really short (but noticeable) time and then regains focus

Both of them are a little bit annoying, but the fullscreen it is even worse, as the screen goes white for a moment.

I think it is because the new renderWindow gets the focus as it is a new window, but I don't know how to solve it. Tried using setVisible(false) but didn't work out as I wanted.

Minimal code:
#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
    //RenderWindow mainWindow(VideoMode(1680, 1050, 32), "SFML Windowed Fullscreen", sf::Style::None);
    //RenderWindow mainWindow(VideoMode(1280, 720, 32), "SFML Windowed", sf::Style::Close);
    RenderWindow mainWindow(VideoMode(1680, 1050, 32), "SFML Fullscreen", sf::Style::Fullscreen);

    while (mainWindow.isOpen()){
        Event event;
        while (mainWindow.pollEvent(event)){
            if (event.type == Event::KeyPressed && event.key.code == Keyboard::Escape){
                mainWindow.close();
            }
            if(event.type == Event::KeyPressed && event.key.code == Keyboard::F){
                RenderWindow newWindow(sf::VideoMode(320, 128, 32), "Creating character", sf::Style::None);
                ///do stuff with the newWindow, and then it is useless
                newWindow.close();
            }

        }

        mainWindow.clear();
        ///draw main window stuff
        mainWindow.display();
    }

    return 0;
}

 

Note: My monitor goes up to 1680x1050, so that is my max resolution.

Any help, or hunches apprecieated! :D

3

Make it your game


Plataforma ULTRA is a fun and engaging platformer. Levels are challenging but fair. What makes Plataforma ULTRA different? Players can change the world.


Creating and editing is a big part of the game. You can create levels, characters, and sprite sheets without touching code! Create characters from scratch (using Photoshop, for example) or use the in-game editor to create your very own character.

Play through 90 exciting levels filled with platforming challenges. On each level, you can win the points, time and life medals reaching up to the total of 270 medals to collect. Can you win them all?

Plataforma ULTRA is currently in development (open alpha) and it will launch at the beginning of 2015.


Downloads:


Windows version (32 and 64 bits)


Linux Version (64 bits). Ubuntu 14.04 or similar.


4
SFML wiki / Making a repeating credits sequence
« on: March 22, 2014, 10:48:45 pm »
Hey guys, I made a repeating credits sequence. It is licensed via MIT, so you are free to use it. I wanted it to upload it to the wiki, but before that I wanted some feedback as I don't want to upload something wrong.

I made it so you can customize it easily. The credits re-appear after they show a first time. If you add multiple texts and want all to be centered, I recommend you to use a std::list or std::vector to manage them.

The code is here: http://codepad.org/bL2zVmZY . The code pasted here looked ugly, even with the code tags

Cheers, and I look forward to your feedback!

Made a youtube video, but the quality is rather poor (sorry about that!)

http://www.youtube.com/watch?v=mguZ-_TC8d4

5
General / [Solved][Linux] linking statically some, dinamically others
« on: November 21, 2013, 09:20:34 pm »
Hey guys!

I made a game using SFML and I wanted to link statically some libraries so the user doesn't have to download anything but the game. This is for the Desura branch, so I can link some libraries dinamically and the Desura App will handle the rest.

I can link these dinamically: sfml, libfreetype6, libjpeg8, libglew1.5, libopenal. And opengl and xlib should be installed by default. So, that leaves me with pthread, xrandr and sndfile to link statically.

I was wondering it's better to link statically some, dinamically others? Everything statically? I think that linking everything statically has the advantage that I know there won't be any library issues. I am unsure on how to proceed, and I was wondering how do you commonly approach this, or better yet, if you uploaded anything to Desura how did you do it?

6
Window / [SOLVED, USE THOR]"Pretty" way to remap keys
« on: November 17, 2013, 11:24:15 pm »
Hey there!

I am still working on my platformer (this week I'll update my project thread!) and wanted to add the option of key remapping. I thought about having some

Keyboard::Key jump
Keyboard::Key moveRight
//...

Then, I'll do Keyboad::isKeyPressed(jump). Then, when the user wants to remap it's just something like this

//..
jump = Keyboard::Escape
//..
or
//..
jump = Event::KeyEvent::code
//..

However, I'm having trouble "drawing" on screen which key represents what. Thing is, for the A-Z is simple. The Key code for A is 0, B is 1 and so on. So, I just add 65 (ascii code) and I'll have the correct letter. However, if the user presses any NUM key, or a slash, I have issues showing that on screen. I just don't know how to translate the key code to the ascii code, unless it's a big switch case (or a bunch of if/else if/else).

EDIT: 2 seconds after I posted it, I stumbled upon this: There is an event called "TextEntered" which gives you the unicode value of the character. http://www.sfml-dev.org/documentation/2.1/structsf_1_1Event_1_1TextEvent.php

So, now I am trying to use both "TextEntered" and KeyPressed to use it, and I think that will do.

7
Hey guys, it's me again ;D

First of all, I'm linking dinamically. I know that in Windows you have to provide .dlls, so anyone can run the program. Now, on Linux, I provide the SFML libs with the program, but I want to know if the user would need something else. Maybe instaling libglew or something like that.

Cheers!

8
General / [Linux] 32 bit version, using 64 bit linux
« on: September 16, 2013, 05:25:37 am »
Hey guys, I've realized that as I have 64 bit Linux, I am using the 64bit version of SFML. I was wondering, the game compiled in 64 bits, it won't run on 32 bit computers right?

I know that in windows you choose which platform you want to compile for, not which OS version you have. However, I do not know if it's the same way in Linux.

I want to reach the most people as possible, so I would like that the game runs nicely in every version (32 and 64)

9
General / Crediting SFML
« on: September 13, 2013, 05:23:53 am »
Hey guys, I'm trying to get my game on Ubuntu Software Center, and I wanted to know how's the correct way to credit SFML. I read that it's not necessary, but I want to do it.

Also, should I list it as an engine? (It appears on Desura, SFML an engine)

CHeers!

10
System / [Linux] using sf::String makes the accents disapear
« on: August 19, 2013, 02:52:10 am »
Hey guys, I've made a game in windows and was trying to port it to Linux. The game uses accents, so in windows I use std::wstrings. However, in linux, you don't have to use wstrings, but std::strings.

However, I have a problem: In windows works perfectly, but in linux it doesn't.

Example code


#include <iostream>
#include <fstream>
#include <SFML/System.hpp>

int main()
{
    std::fstream fin("folder/file");
    std::string aux = "";
        sf::String sfmlAux;
    while(getline(fin, aux)){
        std::cout << aux << std::endl;
                sfmlAux = aux;
                aux = sfmlAux;
                std::cout << aux << std::endl;
    }

    return 0;
}

 

the file contains
Code: [Select]
así
in UTF-8

The output of the program:
Code: [Select]
así
as

Thing is, using wstrings in windows works like a charm. I just change wstrings for strings (linux) and it doesn't work. Any ideas?

11
General / SFML 2.0 in Linux
« on: April 30, 2013, 02:00:53 am »
Hey guys, as 2.0 was released I wanted to try and code in Linux, too. I downloaded the file and then extracted it (because the sudo command brought me 1.6 :( )

However, when I try to do everything as the tutorial says, this happens:
 
||warning: libGLEW.so.1.7, needed by /home/santi/SFML-2.0/lib/libsfml-graphics.so, not found (try using -rpath or -rpath-link)|
/home/santi/SFML-2.0/lib/libsfml-graphics.so||undefined reference to `__glewUniform1fARB'|
//and 38 more errors

It happens when I try to compile via code::blocks, and via console, too! (It compiles, but the linker fails)

Aparently, I have a newer libGLEW, and that's why the error happens...so, any way to fix it? :p

EDIT: I don't know if it changes something, but I am using ubuntu 12.10

12
EDIT3: I didn't removed it because it may help someone. If anyone can tell me if I have been doing the color thing all wrong, please do.

I had a code::blocks version (10.02 or something like that) and I saw there was a new version, and I thought, hey let's update.

First, I tried compiling my Platform project, and this error happened: "error: cannot call constructor 'sf::Color::Color' directly [-fpermissive]", so I decided to try using sf::Color::Color on a simpler code and the same error happened.

Basically I can't do this:

        window.clear(Color::Color(120,120,120));

but I can do this

       window.clear(Color(120,120,120));

______________________________________

EDIT 2: I read about cMake, and unofficial nightly builds, so if anyone encounters the erroor below, try recompiling SFML and works.

However new projects doesn't work, not even this really simple code.
#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
    RenderWindow window(VideoMode(800, 600, 32), "SFML basic");
    CircleShape shape(150.f);
    shape.setFillColor(Color::Blue);

    while (window.isOpen()){
        Event event;
        while (window.pollEvent(event)){
            if (event.type == Event::Closed){
                window.close();
            }
        }

        window.clear();
        window.draw(shape);
        window.display();
    }
    return 0;
}
 

Process terminated with status -1073741819 (0 minutes, 3 seconds)

Is this a code::blocks issue and I should post that there? or is it a SFML one? I've never encountered that error before, and googling provides no useful results

13
SFML projects / Plataforma - ALL ABOUT CUSTOMIZATION
« on: March 26, 2013, 02:04:22 am »
Plataforma is a platformer game that lets you create your own characters, levels and be playing them right away.

You can modify Plataforma to make it your game. It is free and available in Desura for Windows and Ubuntu 12.04 LTS 64 bits. Click here (or the button below) to go to the Desura page, where you can download it.


Creating is easy


You can use your tool of preference, but I recommend using Inkscape for characters and sprite sheets, and Tiled for levels. I made tutorials in .txt format, which are included in the game download, as well as video tutorials explaining how to make levels, characters and sprite sheets. Currently, they have Spanish audio and English subtitles. Also, I started making online tutorials on the official website. These tutorials include images to make creating even easier for you!

How can you contribute to the game?

  • Creating a cool looking characters, levels, or sprite sheets, and posting them on the forums, or send it via twitter with the hashtag #plataformaVideogame.
  • Making a review in Desura
  • Telling your friends!

I hope you enjoy the game!

Hungry for more?


14
Making an options menu I realized .setVerticalSyncEnabled() resets when .create() is called.
I think this may be a bug, because for example setFramerateLimit doesnt reset at all
Below I provide small examples to show what I mean.

this is the code to show setFramerateLimit  doesn't reset (to "unlimited" FPS)  when create() is called
#include <SFML/Graphics.hpp>
#include <sstream>

using namespace sf;
using namespace std;

int main()
{
    RenderWindow app(VideoMode(800, 600, 32), "SFML Test");
    app.setFramerateLimit(60);
    app.create(VideoMode(800, 600, 32), "SFML Test");
    Clock myClock;
    float fps = 1 / myClock.restart().asSeconds();
    stringstream ssFPS;
    ssFPS << "fps: " << fps;
    Text myText(ssFPS.str());

    while (app.isOpen()){
        Event evento;
        while (app.pollEvent(evento)){
            if (evento.type == Event::Closed){
                app.close();
            }
        }

        fps = 1 / myClock.restart().asSeconds();
        stringstream ssFPS;
        ssFPS << "fps: " << fps;
        Text myText(ssFPS.str());

        app.clear();
        app.draw(myText);
        app.display();
    }

    return 0;
}
 

This is the code to show that setVerticalSyncEnabled does reset to false if create() is called

#include <SFML/Graphics.hpp>
#include <sstream>

using namespace sf;
using namespace std;

int main()
{
    RenderWindow app(VideoMode(800, 600, 32), "SFML Test");
    app.setVerticalSyncEnabled(true);
    app.create(VideoMode(800, 600, 32), "SFML Test");
    Clock myClock;
    float fps = 1 / myClock.restart().asSeconds();
    stringstream ssFPS;
    ssFPS << "fps: " << fps;
    Text myText(ssFPS.str());

    while (app.isOpen()){
        Event evento;
        while (app.pollEvent(evento)){
            if (evento.type == Event::Closed){
                app.close();
            }
        }

        fps = 1 / myClock.restart().asSeconds();
        stringstream ssFPS;
        ssFPS << "fps: " << fps;
        Text myText(ssFPS.str());

        app.clear();
        app.draw(myText);
        app.display();
    }

    return 0;
}
 

a simple fix is to set setVerticalSyncEnabled to true, every time you call .create(), like this:
//code here
    app.create(VideoMode(800, 600, 32), "SFML Test");
    app.setVerticalSyncEnabled(true);
//rest of the code
 

15
General / Multi-Language support in my game
« on: March 22, 2013, 08:02:11 pm »
Hey guys, I've been making a really simple platformer and I wanted to upload it to the SFML projects section, but I realized I made it all in Spanish.
My question would be how do you do multi-language support on videogames?
Do you have something like this for every string there is in the game?
//code
sf::String myString;
if(languageIsEnglish){
   myString.setString("Hi");
}
else if(languageIsSpanish){
   myString.setString("Hola");
}
//more code
 

Pages: [1] 2