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.


Messages - hypnotix

Pages: [1] 2
1
SFML projects / Re: Graphical User Interface Library
« on: May 29, 2016, 05:48:23 pm »
I admit, it does seem a bit long and intimidating, but that's solely due to the lambdas. Otherwise, I think it's easier like this, by chaining functions.

2
SFML projects / Graphical User Interface Library
« on: May 29, 2016, 12:07:30 am »
TL;DR: https://github.com/shtgames/GUI-lib

I've spent the better part of the last three months working on a GUI library based on SFML.
I'm sure you're already rolling your eyes thinking: "Come on, another one of these?"
Well, I've been looking high and low and I haven't found one of those that's as practical and easy-to-use as what I wanted.
The whole design idea behind it is to create and define the interface with all the moving parts at the start of the program, setting textures, positions, colours, fonts, as well as, and here's the more important bit, setting the way in which every element should update itself and interact, if at all.
You'd then be able to have a clean, minimalistic main program loop that's nothing more than giving events to the GUI objects and drawing them, everything else is handled automatically the way you've defined it.
So, for instance, you'd give a TextArea an update function which returns the new string it should display, and it'll call that function and update itself often enough for humans to be incapable of seeing any lag.
You'd give a Button a void() function to call when an event specific to buttons; this would most often be, of course, telling it what to do upon being Released.
You can even set HoverMessages on most things, so that they display when the mouse enters the given object. After a certain delay, if you so desire, and naturally with optional and tweakable fade-in and fade-out animations.
Not only that, but you can even set individual parts of the text you'd give the HoverMessage to be with different colors or styles, as well as to update themselves independently of the rest of the text you've given.
All of the Buttons, ProgressBars, TextAreas etc. can be used as free-floating objects or, preferably, as parts of Windows which, in turn, can be stored in WindowManagers.
There's quite a lot more that I haven't covered, so please check it out and tell me what you think; you can find the library, compiled only on VS2015 for the moment, along with example code and accompanying resources, as well as some screenshots:
https://github.com/shtgames/GUI-lib

3
Thanks, that did it.

4
No dice, still get the exception. The address at which the access violation happens is 0xC0000005, if that helps.

5
Crap, I was using SFML for VS 2013 in VS 2015, sorry.

6
std::make_unique with sf::Text won't compile, it says sf::Text's move constructor is undefined.

7
Seems to happen at random as well, sometimes it doesn't crash, sometimes on constructing the first sf::Text, sometimes on the second one.

8
Same thing happens with
.emplace_back(new sf::Text("text", test, 13));

9
I get: 'Exception thrown at 0x...(sfml-system-2.dll) in ...exe at 0x... Access violation reading location 0x...'
With the following code in debug mode in Visual Studio 2015 (compiled as release - win32, tested with the debugger)
#include <SFML/Graphics.hpp>
#include <vector>
#include <memory>

void main()
{    
        std::vector<std::unique_ptr<sf::Text>> vec;
        sf::Font test;
        test.loadFromFile("Arial.ttf");
        sf::Text text("hello ", test, 13); // does not throw
        vec.push_back(std::unique_ptr<sf::Text>(new sf::Text("goodbye ", test, 13))); // throws exception
}
 

10
I have this std::vector<std::unique_ptr<sf::Text>> and I cannot for the life of me understand why I am getting an "Access violation readin location" exception when pushing into it like so:

   returnValue.push_back( std::unique_ptr<sf::Text> ( new sf::Text(someString, someFont, 13) ) );

The font is loaded successfully and all, so its not that. Any insight as to why this is happening would be appreciated.

11
Graphics / Re: sf::Shader::setParameter and const correctness issues
« on: December 31, 2015, 03:19:35 pm »
Oh. Well, you learn something every day I guess :p

12
Graphics / Re: sf::Shader::setParameter and const correctness issues
« on: December 31, 2015, 03:17:37 pm »
Yeah, but I can't make the sf::Shader instance in gui::Button mutable, because draw is declared const; nothing in gui::Button is mutable from draw(). Can I cast it or something so I can change its parameter?

13
Graphics / Re: sf::Shader::setParameter and const correctness issues
« on: December 31, 2015, 02:41:39 pm »
I have made it const because I got the impression that, after inheriting from sf::Drawable, for things to work as intended I need to override the draw() function without changing it, and in sf::Drawable it is declared as follows: virtual void draw(RenderTarget& target, RenderStates states) const = 0;

14
Graphics / [Solved] sf::Shader::setParameter and const correctness issues
« on: December 31, 2015, 01:09:39 pm »
In the following block of code:

    void gui::Button::draw(sf::RenderTarget& target, sf::RenderStates states)const
    {
       states.shader = &stateShader;
       if (!arePredicatesFulfilled()) states.shader->setParameter("buttonState", Unavailable);
            // draw statements....
    }

Where stateShader is a member of class Button, the compiler won't let me change the parameter of the shader, giving me an error reading: "error C2663: 'sf::Shader::setParameter' : 10 overloads have no legal conversion for 'this' pointer."
As far as I am aware, this is happening because of the fact that draw() is a const function and, as such, 'this' is a const pointer in it. Why does that, however, stop me from changing things in states, a non-const object?
I also tried instantiating a shader in the draw function instead of using the (const) one in class Button, still didn't allow me to change the parameter.

15
So, in short, when I zoom, I re-create the texture with textureSize.x*zoomFactor, textureSize.y*zoomFactor, then draw the lines with a width of lineWidth *= zoomFactor and at a distance of lineDistance *= zoomFactor and also go through each vertex and make it so vertex.texCoords *= zoomFactor. That about right?

Pages: [1] 2