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

Pages: [1] 2
1
General / Re: Transitioning from VS 2012 to VS Community 2013
« on: December 10, 2014, 10:37:03 am »
The error essentially says everything and if you don't understand it, Microsoft's documentation writes the errors out in a bit better English, just search for it.

error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj

The SFML libraries you are trying to link are built with the static release version of the runtime lib, while you try to link the dynamic debug libs. Thus they are incompatible, thus they don't link.

Build from source and follow the tutorial. Don't mix static and dynamic libs and don't mix debug and release modes.

Ah okay. Made a slight change to properties for static:
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
 

All is good now.

2
General / Re: Transitioning from VS 2012 to VS Community 2013
« on: December 10, 2014, 09:16:05 am »
You use a different runtime lib version than these SFML binaries were compiled with.

I should mention I'm not using a project file from VS 2012. The above error was with a new empty project. I used the same SFML binaries for both the template which passed the green cricle test and my own project which failed with the above error.

Visual Studio 2013 (Including express, professional and community) use msvcr120.dll (Microsoft Visual C Redicstributable version 120), where as VS12 uses msvcr110.dll. You will either need to compile from source yourself (Best option in my opinion), or use a nightly build which can be found in eXpl0it3rs signature.

I plan to, but I'm curious why my test settings aren't working.

3
General / Transitioning from VS 2012 to VS Community 2013
« on: December 10, 2014, 08:48:03 am »
So I'm switching over to Visual Studio Community 2013, and I'm having some trouble setting it up. I downloaded the SFML 2.1 Binaries for VS 2013 from here. I got the template to work, but I'd like to know how to set it up myself as well. I'm following from what I usually do in VS 2012, but that doesn't seem to work. I'm comparing it to the template project settings, but I can't seem to find the issue. I'm getting the following error:

(click to show/hide)

4
General / Re: AW: Keeping mouse within window when dragging.
« on: March 15, 2014, 10:32:29 am »
Since you usually want to drag the window to a place "outside" the window, I wonder how you want to implement it the. ;)

SFML doesn't have a "mouse locking" feature (yet). In your case you might want to go with real-time input (sf::Mouse::getPosition()), which can also track the mouse states outside the window. ;)

Ah okay. So I changed up my approach a bit. I was using a single variable for both calculating the offset and checking whether the mouse was within the area.

5
General / Keeping mouse within window when dragging.
« on: March 15, 2014, 07:50:36 am »
I'm using borderless style for my window. I've set up an area where you can click and drag the window itself. My issue is keeping the mouse inside the window. I remember reading a reply in a thread about this too but still unsure of it.

int main (int argc, char **argv) {
    -- Snip --
    while (root.GetGameState() != Root::GameState::Quit) {
        switch (root.GetGameState()) {
            case Root::GameState::Menu:
                sf::Event currentEvent;
                while (root.GetRenderWindow()->pollEvent(currentEvent)) {
                    switch (currentEvent.type) {
                        case sf::Event::MouseButtonPressed:
                            Utilities::currentMouseButton = currentEvent.mouseButton.button;
                            Utilities::lastMousePosition = sf::Mouse::getPosition(*root.GetRenderWindow());
                            break;
                        case sf::Event::MouseButtonReleased:
                            Utilities::lastMousePosition = sf::Mouse::getPosition(*root.GetRenderWindow());
                            -- Snip --
                            break;
                        case sf::Event::MouseEntered:
                            Utilities::mouseWithinWindow = true;
                            break;
                        case sf::Event::MouseLeft:
                            Utilities::mouseWithinWindow = false;
                            break;
                        default:
                            break;
                    }
                    if (Utilities::IsMouseButtonHeld(sf::Mouse::Button::Left)) {
                        root.GetTitleBar()->HandleDrag(root.GetRenderWindow());
                    }
                }
                root.GetRenderWindow()->clear(sf::Color(48, 48, 48, 255));
                root.Update();
                root.GetRenderWindow()->display();
                break;
            case Root::GameState::Quit:
                root.GetRenderWindow()->close();
                break;
            default:
                break;
        }
    }
    return root.GetExitStatus();
}
 

6
General / Re: Major lag when a C++ statement is removed
« on: March 05, 2014, 12:10:51 am »
You're effectively creating an infinite loop, which by itself could/should already eat up a full CPU core. But it doesn't seem to happen on your end, unless you add the std::cout, which takes up a bit more to process, thus increasing the CPU usage.

Your while loop is really not a good idea. You should halt your whole application that way, instead everything should run as usual or maybe pause it, while you drag the window. Thus you'll need to write a function which does the same thing, but that will get called in the update process of your main loop.

This function is called in the main loop when I poll an event and the mouse is being pressed. I'm still trying to wrap my head around this. I understand that the infinite loop will take up a lot of CPU usuage and run as fast as it can, but the std::cout is actually slowing down that infinite loop?

7
General / Re: Major lag when a C++ statement is removed
« on: March 04, 2014, 10:56:04 am »
Console output is always slow and laggy, compared to the rest  ;)
Why do you need it?

The console output was there for debugging purposes, but the weird thing is that it lags without the console output! I can't figure out why that is.

According to a performance analysis. Calling getPosition() for the window and mouse take up most of the process when the console output is commented out.

8
General / Major lag when a C++ statement is removed
« on: March 04, 2014, 10:42:40 am »
I have the style of the window set to none, and this snippet allow the user to drag the window when the mouse is pressed.

void TitleBar::HandleDrag(sf::RenderWindow *renderWindow) {
    dragging = true;
    while (dragging) {
        lastMousePosition = sf::Vector2i(sf::Mouse::getPosition(*renderWindow).x, sf::Mouse::getPosition(*renderWindow).y);
        if (Utilities::AABBCollision(float(lastMousePosition.x), float(lastMousePosition.y), float(lastMousePosition.x), float(lastMousePosition.y),
                                     float(area.left), float(area.top), float(area.left + area.width), float(area.top + area.height)) && draggable) {
            //std::cout << "Within area" << std::endl;
            int offsetX = lastMousePosition.x - sf::Mouse::getPosition(*renderWindow).x;
            int offsetY = lastMousePosition.y - sf::Mouse::getPosition(*renderWindow).y;
            renderWindow->setPosition(sf::Vector2i(renderWindow->getPosition().x - offsetX, renderWindow->getPosition().y - offsetY));
            sf::Mouse::setPosition(lastMousePosition, *renderWindow);
            if (!sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) {
                dragging = false;
            }
        }
    }
}

The code has CPU usage for the process spike up to the high 20's and the window stutters when dragging, but when I uncomment the console output statement the CPU usage for the process is about 6% and dragging works as intended. The length of the string that the console outputs also seems to impact performance. The shorter the length of the string the more lag there is.

I'll work on a minimal example tomorrow morning, but for now I hope someone can find a reason why.

9
General / Re: Optimizing CPU usuage
« on: February 26, 2014, 01:20:02 am »
I'm also running this on an older computer and that's the reason for wanting to reduce the CPU usage. The program is more of a form application, though I remember reading SFML is more for real time applications.

Regarding the clear->draw->display I may have been unclear.  To clarify my program will run updates every 1/30th of a second but not draw every iteration, and it calls clear()->draw()->display() when there is something that needs to be drawn.

Isn't it fine to keep the old frame shown as long as I'm not using any old pixels in the next frame? When I do need to display something I'll go through clear->draw->display, not using any pixels from the previous frame, but I'm not going through clear->draw->display every frame since there isn't anything new to be drawn. I'm not really doing anything against what the red box states other than being scared to draw frames several times a second, am I?

10
General / Optimizing CPU usuage
« on: February 25, 2014, 10:17:29 am »
Alright so I had a thread earlier about calculating FPS after window.display() is called, but my while loop doesn't always call window.display() only when there is user input. CPU usage hits a peak of 20% for the program because of the while loop. I implemented the following to limit it:

void Root::CheckElapsedTime(sf::Clock &clock) {
    if (elapsedTime >= 1.0f / float(framesPerSecond)) {
        std::cout << "While Loop: " << 1.0f / elapsedTime << std::endl;
        elapsedTime = 0;
        return;
    }
    sf::sleep(sf::seconds(1.0f / float(framesPerSecond) - elapsedTime));
    elapsedTime += clock.restart().asSeconds();
    CheckElapsedTime(clock);
}

I have the frame-limit set to 30, and FPS is just shy of 30 which is good. CPU usage drops to a peak of 3%. Is this implementation correct, and is there a better way to optimize it?

11
General / Re: What's up with my FPS?
« on: February 24, 2014, 09:54:41 pm »
FPS are the inverse of the (mean) frame length.
Your currentTime variable is essentially the time elapsed since lastFrame, so you don't need a lastTime variable to compute your FPS:
float currentTime = clock.restart().asSeconds();
float fps = 1.f / currentTime;

You can also compute your FPS with the time elapsed since the clock started, you would need a lastTime variable and you shouldn't restart the clock:
float currentTime = clock.asSeconds();
float fps = 1.f / (currentTime - lastTime);
lastTime = currentTime;

Oh I see. Thank you G.!

And thanks to eXpl0it3r his post led me to solve the problem in my up-scaled project. My "while" loop wasn't calling window.display() every loop therefore I had huge numbers for the FPS.

12
General / Re: What's up with my FPS?
« on: February 24, 2014, 10:05:26 am »
You don't call window.display(), thus the frame limiter doesn't get active, instead you just have an infinite loop that goes as fast as it can (20k-40k fps apparently). ;)

There is a nice FPS class on the wiki, if you need some more inspiration.

Woops forgot about that. I call it right before calculating the FPS but still with the same results.

13
General / [SOLVED]What's up with my FPS?
« on: February 24, 2014, 09:28:31 am »
For the life of me I can't figure out what the issue is. I've done plenty of searches, but I think I might be missing something since I now have tunnel vision. I'm using SFML 2.1 for this.

Here's the minimal example with code from a search:
int main() {
    sf::RenderWindow Window(sf::VideoMode(100, 100, 32), "Test");
    Window.setFrameLimit(60);

    sf::Clock clock;
    float lastTime = 0;
    while (Window.isOpen()) {
        float currentTime = clock.restart().asSeconds();
        float fps = 1.f / (currentTime - lastTime);
        lastTime = currentTime;
        std::cout << fps << std::endl;
    }

    return 0;
}

Console:
-327.225
32258.1
23255.8
-1002
 
And so on with various numbers

14
General / Re: Compiling program on Linux
« on: August 10, 2013, 07:50:06 am »
Ah, okay. I couldn't compile it correctly the first time, so I turned to the precompiled verion. Haha, only have an ARM chip cause I just got a Raspberry Pi. I'm only using SFML for the network module, since OpenGL isn't support :(

Thank you so much :D I got it to work.

15
General / Re: Compiling program on Linux
« on: August 09, 2013, 08:58:26 pm »
uname -a
Linux mcn 3.6.11+ #474 PREEMPT Thu Jun 13 17:14:42 BST 2013 armv6l GNU/Linux
 

cat /proc/version
Linux version 3.6.11+ (dc4@dc4-arm-01) (gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08) ) #474 PREEMPT Thu Jun 13 17:14:42 BST 2013
 

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --wiht-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
 

Pages: [1] 2
anything