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

Pages: [1]
1
Audio / Re: openAL32.dll error when using any sfml audio
« on: July 31, 2014, 03:35:41 am »
So simple. Thank you very much.

2
Audio / openAL32.dll error when using any sfml audio
« on: July 31, 2014, 02:32:00 am »
this code
#include <SFML\Audio.hpp>
int main()
{
        sf::SoundBuffer buffer;
};
produces this error

img

It was originally an openAL32.dll is missing error but I used an openAL installer from here
http://www.openal.org/creative-installers/

here's my system info
(click to show/hide)

I'm using Static SFML 2.1

I checked my Graphics card and audio drivers and both are up to date (now xD)
I have installed libsndfile-1.0.25 x64 and x32 from here
http://www.mega-nerd.com/libsndfile/
I will keep searching for a solution but if anyone has any idea what is causing this I would appreciate the info

3
General / Re: creating functions like getGlobalBounds()
« on: June 17, 2014, 04:56:16 am »
In the above code, when you call getPosition() you are returning the member variable "m_position" which itself has two member variables "x" and "y". These can be called using the "." operator right from the function. So for example if you wanted to access the "x" variable inside m_position, you could do:
THANK YOU!! I figured it was something simple like this but it's hard to learn certain things when you don't even know what to search for.

Quote
But again, you should really read up on structures and classes. It's something basic you should know before you try using SFML
I do realize that this question was a c++ question and not a question about SFML but I'm using SFML to make learning c++ a little more fun, anyways, I do appreciate the answer.

4
General / creating functions like getGlobalBounds()
« on: June 17, 2014, 02:50:10 am »
I want to create a function that can return multiple values based on the given criteria like getGlobalBounds().
getGlobalBounds can return top, left, height and width depending how you call the function. i.e. getGlobalBounds().height

what is this type of function called and can anyone link me to any documentation on how to create something similar?

5
Graphics / Re: strange behavior moving around a text object
« on: June 11, 2014, 12:29:13 am »
I figured out a much simpler way to write the positionText function and it simultaneously fixed the buggy behavior :)
here's the function, in case anyone else is interested.
void positionText(sf::Text &text, sf::Vector2f dimensions, sf::Vector2f position)
{
        if(text.getLocalBounds().height > dimensions.y)
        {
        text.setPosition(position.x, position.y + (dimensions.y - text.getLocalBounds().height));
        }
};

6
Graphics / strange behavior moving around a text object
« on: June 10, 2014, 03:52:00 am »
Hello.
I created a couple functions that process text input and display it to the screen using sf::text.
When the the bottom of the sf::Text object reaches a desired point it will begin scrolling the text upward to make sure it does not go below that point and if you begin removing text it will move the sf::Text object back down.
the problem I have is when the text begins scrolling down, it will jump up to a random point for probably a single frame.
any ideas why this is happening?
also, I'm looking for general feed back concerning both functions. Is there anyway I can improve on any part of this code?
(click to show/hide)

7
Graphics / Re: findCharacterPos() is not returning expected value.
« on: June 05, 2014, 11:09:28 pm »
I actually just figured it out!

void wrapText(sf::Text input_text, std::vector<std::string> &output_string, int string_width)
{      
        input_text.setCharacterSize(20);
        std::string string = input_text.getString();
        std::string temp_string;
        for(int i = 0; i < string.size(); i++)
        {

                input_text.setString(string);// <- I was missing this line!! i just needed to reset the string
                                    //inside the text object after I had modified it. derp

                if(input_text.findCharacterPos(i).x > string_width)
                {
                        for(int j = 0; j < i; j++)
                        {
                                temp_string += string[j];
                        }
                        output_string.push_back(temp_string);
                        temp_string = "";
                        for(int k = i; k < string.size(); k++)
                        {
                                temp_string += string[k];
                        }
                        string = temp_string;
                        temp_string = "";
                        i = 0;
                }
               
        }
        output_string.push_back(string);
};

8
Graphics / Re: findCharacterPos() is not returning expected value.
« on: June 05, 2014, 09:25:16 pm »
So... what exactly doesn't work with it?

what i'm having issues with is;
a line of 20 k's and a line of 20 j's are different graphical sizes but they are both returning the same x coordinate for the last letter in their index. 
As stated by Nexus, I am not using a monospace font and if I cannot use a non-monospace font with findCharachterPos() then I can deal with that, but, I would prefer to have that option open to me.

9
Graphics / Re: findCharacterPos() is not returning expected value.
« on: June 05, 2014, 07:09:37 pm »
thanks for all the replies! I have 2 new questions.

first.
all this talk about glyphs, kerning and horizontal advance is a bit over my head. can anyone link me some documentation to better understand what you're all talking about? the tutorials/API have left me wanting.
 
second
Can anyone break down what findCharacterPos() is doing/returning? The concept i have from reading the API is that it's supposed to return the x and y coordinates of the requested character in the string.

Also, I initially considered using newline instead of breaking up the string into sub strings but I liked the idea of being able to control each line as it's own text object. However, the more I work with sf:: text the less I see the need to use individual text objects for each line and I may just end up using a function like Nexus posted

float totalWidth = 0.f;
for (every character in text)
{
    totalWidth += character width; // use sf::Glyph
    if (totalWidth > maxWidth)
    {
        break line before character;
    }
}

10
Graphics / findCharacterPos() is not returning expected value.
« on: June 05, 2014, 04:41:53 am »
I'm writing a text wrapping function that takes a string and breaks it up in to multiple strings based on it's position in the window. I'm using a for loop and sf::Text.getCharacterpos().x to find the first character that is outside of the text box.
here's the problem I'm having.


lines that are composed of mostly large character's (like "k") are longer then lines that are composed of mostly smaller characters(like "j").
hopefully someone can help me understand what i'm doing wrong.

here's the function I'm working on,

//text wrapping function
//this function takes 3 arguments
//      #1 input_text : this argument passes in the original string via an sf::text object which will
//                             need to be broken up into into smaller strings based on the size of the intended text box.
//      #2 output_string: this argument will pass in a reference to the desired string vector so the function
//                                 can push back as many individual lines as needed.
//      #3 line_width   : use this argument to pass in the desired line length in pixels.
void wrapText(sf::Text input_text, std::vector<std::string> &output_string, int string_width)
{      
        std::string string = input_text.getString();
        std::string temp_string;
        for(int i = 0; i < string.size(); i++)
        {
                if(input_text.findCharacterPos(i).x > string_width)
                {
                        for(int j = 0; j < i; j++)
                        {
                                temp_string += string[j];
                        }
                        output_string.push_back(temp_string);
                        temp_string = "";
                        for(int k = i; k < string.size(); k++)
                        {
                                temp_string += string[k];
                        }
                        string = temp_string;
                        temp_string = "";
                        i = 0;
                }
               
        }
        output_string.push_back(string);
};

thanks in advance for any help  :D

11
General / Re: understanding noncopyable objects
« on: May 25, 2014, 01:57:16 am »
Thank you for the quick reply. Back to reading :)

12
General / understanding noncopyable objects
« on: May 24, 2014, 03:31:51 am »
Hello  :D
I've been learning C++ and I use SFML for a more engaging learning experience than just outputting text to the console. unfortunately, at times, my use of SFML extends past my knowledge of C++. Normally I just go back to reading a couple books that I have or I search the internet until i have a better understanding of C++ but this last problem I've ran into has me stumped because I don't really know what to search. I'm hoping someone out there can give me some specific terminology about this piece of code so I know what to google/what chapter I should be reading out of.
the problem started when i began passing "noncopyable" objects into functions, so I began researching the error I was getting and came across many pieces of code similar to the following.

changeWindow(sf::RenderWindow &window) : mainWindow(&window)
{
    mainWindow -> window;
}

I have a basic understanding of passing objects by reference and using pointers but what I really don't understand is, what the heck is that colon and the "->" doing or what it's called?

In short, can someone please give me some direction for research so I can understand the above code?

Pages: [1]