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

Pages: [1]
1
Feature requests / Re: Get the x-height of a sf::Text
« on: May 03, 2017, 11:36:00 pm »
Ahh!! Why didn't I think of that  ;D
Thanks.

2
Feature requests / Re: Get the x-height of a sf::Text
« on: May 03, 2017, 11:24:55 pm »
Yes if I make the text upper cased that would probably work. If it is not feasible to implement, I would understand.
I have made an image showing what the problem was.

3
Feature requests / Get the x-height of a sf::Text
« on: May 03, 2017, 10:41:05 pm »
In my current project I noticed that some of my buttons had their text at different heights. It took awhile to figure out what the problem was. I had used sf::Text getLocalBounds().height
The height returned was its current bounds for that particular text. So I made my self a little helper function. It may not be the best solution but it at least it works (I think).

int Button::GetXHeight()
{
        // Info about x-height: https://en.wikipedia.org/wiki/X-height
        text.setString("a");
        int xheight = (int)this->text.getLocalBounds().height;
        text.setString(buttonText);
        return xheight;
}

Note: must used before using text dimensions.

By setting the text to temporally to "a" then query the getLocalBounds().height for its x-height. Then set the text back.

I am wondering if this could be a feature to be added. Lets say: getXHeight() perhaps?
That said, I am not an expert so I might have overlooked something essential.

4
General / Re: Getting warnings in MinGW - SFML Book - Source Code on Github
« on: September 17, 2013, 11:47:17 pm »
Okay I could try, never done that before.

5
General / Getting warnings in MinGW - SFML Book - Source Code on Github
« on: September 17, 2013, 11:39:42 pm »
Getting warning in MinGW due to unordered initialized members.
Here is Aircraft.cpp/hpp as an example:

$ make
Windows makefile running...
Compiling...
g++ -Wall -std=c++11 -c -s Aircraft.cpp -o ../Temp/Aircraft.o
In file included from Aircraft.cpp:1:0:
Aircraft.hpp: In constructor 'Aircraft::Aircraft(Aircraft::Type, const TextureHolder&, const FontHolder&)':
Aircraft.hpp:76:12: warning: 'Aircraft::mSpawnedPickup' will be initialized after [-Wreorder]
Aircraft.hpp:67:17: warning:   'sf::Sprite Aircraft::mSprite' [-Wreorder]
Aircraft.cpp:23:1: warning:   when initialized here [-Wreorder]
In file included from Aircraft.cpp:1:0:
Aircraft.hpp:89:12: warning: 'Aircraft::mIdentifier' will be initialized after [-Wreorder]
Aircraft.hpp:77:12: warning:   'bool Aircraft::mPickupsEnabled' [-Wreorder]
Aircraft.cpp:23:1: warning:   when initialized here [-Wreorder]
 

Following files are affected:
Aircraft.cpp
GameServer.cpp
Player.cpp
 

Also there is one more warning to get rid of:
Utility.cpp: In function 'std::string toString(sf::Keyboard::Key)':
Utility.cpp:28:9: warning: enumeration value 'KeyCount' not handled in switch [-Wswitch]
 

Change from:
                BOOK_KEYTOSTRING_CASE(F13)
                BOOK_KEYTOSTRING_CASE(F14)
                BOOK_KEYTOSTRING_CASE(F15)
                BOOK_KEYTOSTRING_CASE(Pause)
        }

        return "";
}
 

Change this to:
                BOOK_KEYTOSTRING_CASE(F13)
                BOOK_KEYTOSTRING_CASE(F14)
                BOOK_KEYTOSTRING_CASE(F15)
                BOOK_KEYTOSTRING_CASE(Pause)
                default:
                        return "";
        }

        return "";
}
 

Please update this source code on github. I know it is only warnings but I find them annoying.

6
Graphics / Re: OSX - Failed to compile fragment shader
« on: September 16, 2013, 08:35:06 pm »
Thanks guys!

I was your help able to find the problem and correct it. Shaders kinda new thing for me.
In Brightness.frag I found the error:
sourceFragment *= clamp(luminance - Threshold, 0, 1) * Factor;
 

Changed to this:
sourceFragment *= clamp(luminance - Threshold, 0.0, 1.0) * Factor;
 

Seems like clamp(...) didn't like "int" as parameters. It is a couple of weeks since I downloaded the source code, so I don't know if it has been fixed or not. Hope this might help other trying to get a OSX version to work.

7
Graphics / [SOLVED] OSX - Failed to compile fragment shader
« on: September 16, 2013, 03:55:58 pm »
I have bought the SFML book and downloaded the source code. Okay I had no problem compiling and linking this in linux and windows, and program runs okay there but on OSX 10.8 (Mountain Lion) it's another story. Used "clang++" to compile and link it. But when I am starting the program it runs ok until push play button.

It immediately crashes and this is what it prints in terminal:
Failed to compile fragment shader:
ERROR: 0:12: No matching function for call to clamp(float, int, int)


EXCEPTION: ResourceHolder::load - Failed to load /Users/max/Projects/EagleFighters/Game/Data/Shaders/Fullpass.vert
 

I suspect this is due to that my mac mini with NVIDIA GeForce 9400M isn't supporting latest GLSL.
Checked documentation on "clamp(...)" http://www.opengl.org/sdk/docs/manglsl/
and crosschecked with documentation on the GFX-card. https://developer.apple.com/graphicsimaging/opengl/capabilities/ but I am not really sure.

Anyone know exactly why this gives me "Failed to compile fragment shader" ?

8
General discussions / Re: SFML Game Development -- A book on SFML
« on: July 28, 2013, 02:26:29 pm »
Hi!
I purchased this book and are eager to read it. Normally I would not buy books on Amazon that does not have a preview, so I would recommend that you (the authors) write an email to PacktPub about that. But in this case I support SFML by buying this book. :)
Also it would not hurt if there was more customer reviews.

From what I could tell all those chapters look like they are packed with good stuff, like networking for instance.
Typically that's an area most game dev books just skims over only to show how to send a TCP/UDP-packet. But totally ignores to go deeper on how to make LAN/Internet game (i.e: a 2d tank internet game ). So my hopes is high on this one.

Thanks for make a great community!

9
Graphics / Re: sf::RoundedRectangleShape
« on: July 15, 2013, 06:35:16 pm »
Okay thanks for clarifying that.  :)

10
Graphics / sf::RoundedRectangleShape
« on: July 15, 2013, 06:12:00 pm »
I am wondering if sf::RoundedRectangleShape exists in SFML 2.0 or if it is missing in documentation.

Pages: [1]