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 - iride

Pages: [1] 2
1
Graphics / Can't directly type Korean
« on: February 09, 2018, 06:43:22 am »
Hi,
Whenver I type in Korean,I don't receive TextEntered events right away.
Instead a small popup appears and I must first type the text on that popup window and press enter to receive the events.
This makes it very frustrating to type.
How can I get rid of this??

I'm on windows 10, sfml 2.4.2.

2
Graphics / Weird tilemap issue
« on: March 15, 2017, 05:36:10 pm »
This is how it should look normally.


But sometimes when I move around the camera by using view.setCenter()

Weird artifacts appear.

I have tried adding (.5f, .5f) to the center position of view. Then the issue is mostly gone. But rarely, I can still see the artifacts.
I am using a gtx 1070.



3
Graphics / Weird stuttering issue
« on: February 12, 2017, 08:47:02 am »
Hello, I have a strange stuttering issue with this code.
#include "Core/MathUtility.h"
#include <SFML/Graphics.hpp>
int main()
{
        sf::RenderWindow window(sf::VideoMode(1000, 800), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);
       
        sf::Clock clock;
        sf::Time elapsed = sf::Time::Zero;
        sf::Vector2f pos;
        sf::Vector2f oldPos;


        while (window.isOpen())
        {
                elapsed += clock.restart();
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
               
                while (elapsed >= sf::seconds(1 / 60.f))
                {
                        std::cout << "tick\n";
                        elapsed -= sf::seconds(1 / 60.f);
                        oldPos = pos;
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
                                pos.x -= 5.f;
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                                pos.x += 5.f;
                }
                float t = elapsed.asSeconds() / sf::seconds(1 / 60.f).asSeconds();
                window.clear();
                sf::Vector2f renderPos = lerp(oldPos, pos, t);
                std::cout << "renderPos: " << renderPos.x << "\n";
                shape.setPosition(pos);
                window.draw(shape);
                window.display();
        }
        return 0;
}
 

I think the stutter comes from random high frametimes.
dt: 0.000104
renderPos: 298.681
dt: 0.038244
tick
tick
tick
renderPos: 310.154
dt: 0.000183
renderPos: 310.209
dt: 0.000158
renderPos: 310.257
dt: 0.037992
tick
tick
renderPos: 321.655
dt: 0.000206
renderPos: 321.716
dt: 0.000212
renderPos: 321.78

I'm using sfml 2.4.0, windows 10, i7 6700k/gtx 1070.
Sometimes if I reboot my computer, the stutter goes away.


What I don't understand is that stutter never seems to occur on my laptop with integrated graphics.

4
Window / How to filter out weird characters in TextEntered event?
« on: April 27, 2016, 05:18:23 am »
Sometimes I get weird symbols like � through TextEntered
How to filter these out?

5
Graphics / I want to fit a text inside a box
« on: March 28, 2016, 07:37:43 am »
I'd like to make a textbox using sf::RectangleShape and sf::Text.
Rectangle has a fixed height.
My question is how to find the perfect character size and text position to fit the text in rectangleshape?

6
General discussions / Why does sf::Packet convert to big endian?
« on: March 02, 2016, 07:47:56 pm »
Windows and OS X are little endian. Linux can theoretically be big endian, but today pretty much 100% use little endian.
Converting to big endian seems like waste of cpu. Is there something I'm missing?

7
Graphics / making a rectangle enclosing a text
« on: May 26, 2015, 06:05:51 am »
float height = m_text.getFont()->getLineSpacing(m_text.getCharacterSize()) / 2.f;
m_rect.setSize({ m_rect.getSize().x, m_text.getLocalBounds().height + height});
window.draw(m_text); window,draw(m_rect);

when the text has letters it looks fine


but when the text is just like "..." the rectangle's height is shorter than it should be


how can i solve this issue?

8
Graphics / What is wrong with my code?
« on: May 06, 2015, 05:13:59 am »
Hello, i'm building my own gui system.

i have a Container class that derives from sf::Transformable and stores children widgets. I also have a Panel class that derives from Container.
When I set a child widget's position, I want it to be relative to the parent's position.

auto panel = ui::Panel::create();
panel->setSize({ 100.f, 100.f });
panel->setPosition({ 50.f, 50.f });
panel->color = sf::Color::Blue;

auto panel2 = ui::Panel::create();
panel2->setSize({ 50.f, 50.f });
panel2->color = sf::Color::Green;

panel->add(panel2);

...
ui.add(panel);
window.draw(ui);
 

Since I never moved Green panel's position, I expect it to be at the same position as the Blue panel. However in my program it appears at 50, 50 relative to the blue panel.

What I get


What I expect


void Panel::draw(sf::RenderTarget & target, sf::RenderStates states) const
{
        states.transform *= getTransform();
        sf::RectangleShape r;
        r.setFillColor(color);
        r.setSize(getSize());
        target.draw(r, states);
        Container::draw(target, states);
}

void Container::draw(sf::RenderTarget & target, sf::RenderStates states) const
{
        states.transform *= getTransform();
        for (auto w : m_widgets)
                target.draw(*w, states);
}

What's wrong?

9
Audio / crash with sf::Music
« on: May 03, 2015, 06:54:36 pm »
I'm using phsfsstream class from here: https://github.com/SFML/SFML/wiki/Source%3A-PhysicsFS-Input-Stream

#include "PhysfsStream.h"
#include <SFML/Audio.hpp>
#include <iostream>

int main(int argc, char* argv[])
{      
        PHYSFS_init(argv[0]);
        PHYSFS_addToSearchPath("musics", 1);

        sf::Music music;
        PhysfsStream stream;
        stream.open("sample.ogg");
        music.openFromStream(stream);
        music.play();
       

        //music.stop(); //adding this line will prevent the program from crashing

        PHYSFS_deinit();
}

this program crashes saying "pure virtual function call", but if I stop the music before it goes out of scope, it won't crash. Is this a bug in SFML?

using visual studio 2013 and sfml 2.2

10
Network / accepting a socket that has already been accepted
« on: April 15, 2015, 06:20:57 am »
 What happens when I accept a socket that has already been accepted?
will it just continue to return sf::Socket::Done?
listener.accept(socket); //accepted
listener.accept(socket); //??


11
Network / sending one packet to multiple recipents
« on: January 22, 2014, 04:54:59 am »
I noticed that sf::Tcp::Socket::send  takes a reference to  a sf::Packet , not const sf::Packet
Does this mean that when I send a packet , the contents of the packet get modified so I can't send the same packet to the other clients?
or in code
sf::Packet packet;
packet<<"hi";
for(sf::TcpSocket & s : sockets)
    s.send(packet);//is this ok?
 

12
General / using std::enable_if for sf::Packet overloads for enums
« on: January 20, 2014, 08:28:30 pm »
I'm trying to write a function template for overloading enums with sf::Packet. What did I do wrong?

template <class Enum>
sf::Packet & operator<<(sf::Packet & packet, const typename std::enable_if<std::is_enum<Enum>::value, Enum>::type & t)
{
        return packet << static_cast<typename std::underlying_type<EnumT>::type>(t);
}

template <class Enum>
sf::Packet & operator>>(sf::Packet & packet, typename std::enable_if<std::is_enum<Enum>::value, Enum>::type & t)
{
        typename std::underlying_type<EnumT>::type i;
        packet >> i;
        t = static_cast<Enum>(i);
        return packet;
}

enum Month : sf::Int32
{
    January
}

//doesn't compile
sf::Packet packet;
packet<<January;
Month month;
packet>>month;
 

13
Network / interpolating
« on: December 28, 2013, 05:43:57 pm »
http://www.gabrielgambetta.com/fpm3.html

I'm trying to implement entity interpolation explained in this article. I understand that I have to display the game couple frames late, but I have no clue how to translate this into code.
 sf::Packet packet;
 receivePacket(packet);
 packet>>newX>>newY; //now what should I do with this new position?
 

14
Network / issues with sf::Int8
« on: December 22, 2013, 05:36:03 am »
I initially thought this was a issue with networking..

int main()
{

        sf::Int8 i = 1;
        std::cout << i;
        std::cin.get();
}

This piece of code prints a smiley face to the console screen, not 1

windows 8.1 visual studio 2013

15
Network / Example network program doesn't work on school network
« on: October 19, 2013, 02:38:25 am »
I get an error msg - Failed to set socket option "TCP_NODELAY" ; all your TCP packets will be buffered

What's wrong?

Pages: [1] 2
anything