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

Author Topic: Difficulty in getting SFML to work (first use) with Code::Blocks/MinGW (C++)  (Read 11991 times)

0 Members and 1 Guest are viewing this topic.

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
I am not saying they do not use DLL's, I am saying I never SEE them. Out of sight, out of mind.

Indeed. Something occurs to me now... asSeconds does not take an argument, does it? That explains a few things. In this case, the latter one makes sense - your time is equal to the time object it makes, in seconds, sort of. The first one confuses me, though. How can you assign one object (Time time) to another time object? Throws me a bit.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Quote
I am not saying they do not use DLL's, I am saying I never SEE them. Out of sight, out of mind.
They are usually there, either with the executable or in a sub-directory.

Quote
Indeed. Something occurs to me now... asSeconds does not take an argument, does it? That explains a few things. In this case, the latter one makes sense - your time is equal to the time object it makes, in seconds, sort of. The first one confuses me, though. How can you assign one object (Time time) to another time object? Throws me a bit.
I can't teach you how C++ works. Find a book or online articles, really ;)
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Sub Directory. Like, a folder further in the path?

Let's say my .exe is as C:\Folder1\. Could the DLL's still work correctly in C:\Folder1\Folder2\ ?

I agree. I really m a bit befuddled, though. Time is a class. You make an object of that clase, time. It has some sort of constructer, all its members, etc. The function getElaspedTime() returns a Time object. I don't recall anything about making an object equal another object. The only thought that comes to mind is your overloaded the = operator, but in the doc, unless I missed it somehow, you overloaded every operator BUT =. Well, and [] and ., I guess. And... ->. I think.

I am officially confused.

Of note is that its public member attribute is static... but it is also constant, which, for me at least, suggest it cannot change, except upon creation, but it must incriment somehow...

Am I dumb or is this more complex? :)

EDIT: On second though, I got the clock and Time mixed up. The clock incriments itself. Now... I find this very confusing :) hopefully it grows on me. I tried:

#include <SFML/system.hpp>

int main()
{
    sf::Clock clock;
    while (1)
    {
        if (clock.getElapsedTime().asSeconds() > 5)
        {
            break;
        }
    }
}
 

Is this more of the correct way? It is hard to tell because with GUI project the debugger defaulty pauses at the end.
« Last Edit: April 19, 2012, 08:23:14 pm by chessguy »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Quote
Sub Directory. Like, a folder further in the path?
Yes.

Quote
Let's say my .exe is as C:\Folder1\. Could the DLL's still work correctly in C:\Folder1\Folder2\ ?
Yep, everything's possible if you know how to do it ;)

Quote
The only thought that comes to mind is your overloaded the = operator, but in the doc, unless I missed it somehow, you overloaded every operator BUT =.
There's a default implementation of operator= (auto-generated by the compiler), you don't need to always explicitely write it if its implementation is trivial (ie. calling = recursively on members).

Quote
Of note is that its public member attribute is static... but it is also constant, which, for me at least, suggest it cannot change, except upon creation, but it must incriment somehow...
It's not the only member, there's another one ;)
The public static one is just a special value that represents the 0 time.
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Ah. I guess that answers that.

the only time I have come across the term recursive is functions calling themselves, say. I have no idea how that goes with classes so much, and what = has to do with it.

m_milliseconds, the private member?

I guess that would make sense. I still don't get the = part though. The tuturials I had never said anything about an object = anything, so I don't know what it does. Does it... do something?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Quote
the only time I have come across the term recursive is functions calling themselves, say. I have no idea how that goes with classes so much, and what = has to do with it.
I just meant that operator= is called on the object's members, and if some of these membres are objects themselves, the same mechanism is applied in cascade until the compiler reaches primitive types, for which operator= is a simple assembly instruction.

Quote
m_milliseconds, the private member?
m_microseconds
Laurent Gomila - SFML developer

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Are you saying that if you assign one object the value of another object, any, say, common variables, such as the non static constant time one, is assigned to the object beign assigned to, similar to using time.variable = time.variable?

Ah. right. I get those mixed up, but I remember it had an m in it. Although, I only saw it in the time.hpp (speaking of which, what is an hpp? A C++ header file that isn't .h for some reason?), not the doc. Why?

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Ah. right. I get those mixed up, but I remember it had an m in it. Although, I only saw it in the time.hpp (speaking of which, what is an hpp? A C++ header file that isn't .h for some reason?), not the doc. Why?

Private methods and variables aren't in the doc because... you can't use it. There are used internally (by the class)

a .hpp is a header for a cpp file. It's not mandatory, a .h file works too, you can use both of them. It's just that in .hPP there is PP that means PlusPlus so it's generally used for programming in C++

Then, sometimes the operator= isn't required because the compilator (like Laurent said) knows how to convert, for example, a float into a time. This is due to the constructor overload of class Time (a least in part, I don't get all the subtilities of c++).

For example if I got this class :

Code: [Select]
class A
{
      public:
          A(int i) : m_int(i) { }
      private:
          int m_int;
};

I can do :

Code: [Select]
A object = 3;
The compilator knows that it's the same as :

Code: [Select]
A object(3);
(Hit me if i'm wrong)
« Last Edit: April 19, 2012, 11:42:13 pm by Lo-X »

chessguy

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
True...  Hrm. Still never quite get the whole private thing though. I guess in the case of libraries people make such as SFML it makes ie easier to use.

Ah. Is there an advantage to using one over the other?

For normal variables, I know that imiplicit assignment variable(value) is the same as variable = value, but in the case of an object, the only thing that A object(value) would do is prvide the value to a parimatarized constructor. As such, I am unaware what using = would do, not to mention if it does provide to the constructor, I am pretty sure there is not a parameter taking one that I know of.