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

Pages: [1]
1
The result I'm experiencing: captures 1 and 2 have a circle on green background, while 3-5 are just green with no graphics.
The result I expected: all captures have a circle on green background.
Why I expect this result: nothing about the drawing process changes after the window is closed. All drawing is performed on an unrelated RenderTexture. There is a call to texture.draw(shape); just like all other times, and yet the circle does not appear.

Creating a context did not change anything.

2
Sorry, my mistake, I forgot to delete a line before posting the example. The code I meant to post does not have the line "if (!window.isOpen()) break;". I edited the original post with correct code.

3
Hello, I'm having trouble with a RenderTexture. It seems that in a program where an unrelated RenderWindow has been closed, during the last iteration of the game loop, the RenderTexture gets drawn incorrectly and essentially has nothing on it except for the color used in clear().

I narrowed it down to this piece of code, which draws a simple circle on a green RenderTexture. After the close button has been pressed, The program captures the texture 5 times at different points. On my machine, captures 1 and 2 have the circle, while 3-5 are just green with no graphics.


#include <SFML/Graphics.hpp>

int main() {
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    sf::CircleShape shape(200);
    shape.setPosition(150, 150);

    // Create a new render-texture
    sf::RenderTexture texture;
    if (!texture.create(500, 500))
        return -1;
    // The main loop
    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                texture.getTexture().copyToImage().saveToFile("test1.png");
                window.close();
                texture.getTexture().copyToImage().saveToFile("test2.png");
            }
        }

        // Clear the whole texture with green color
        texture.clear(sf::Color::Green);
        // Draw stuff to the texture
        texture.draw(shape);   // shape is a sf::Shape
        // We're done drawing to the texture
        texture.display();

        if (!window.isOpen()) texture.getTexture().copyToImage().saveToFile("test3.png");
        // Now we start rendering to the window, clear it first
        window.clear();
        // Draw the texture
        sf::Sprite sprite(texture.getTexture());
        if (!window.isOpen()) texture.getTexture().copyToImage().saveToFile("test4.png");
        window.draw(sprite);
        // End the current frame and display its contents on screen
        window.display();
        if (!window.isOpen()) texture.getTexture().copyToImage().saveToFile("test5.png");
    }
}


Is there something I'm doing wrong? Is this a bug in SFML? Thanks.

My specs are: SFML 2.5.1, Windows 10 update 2004, Nvidia graphics with latest drivers. Tested on two machines with similar results.

4
General / SFML installed from vcpkg fails to link statically
« on: November 20, 2019, 05:28:50 pm »
When installing SFML from the vcpkg package manager, static linking fails.
I have opened an issue on vcpkg github https://github.com/microsoft/vcpkg/issues/8864, but it seems that it does not get much attention.

I want to post it here in case anyone has encountered this problem and can contribute. Seems like a pretty big issue to me.
I will copy the issue below:

Description
When building a "hello world" program with sfml and visual studio (configured to use static triplets), build fails on link step. It seems that vcpkg does not define `SFML_STATIC`, which is required for static builds. But even after defining it manually linking still fails (build log below). Dynamic SFML builds fine.

Environment
- OS: Windows 10 Education (ver. 1903).
- Locale: ru-RU
- Successfully installed `sfml:x86-windows`, `sfml:x64-windows`, `sfml:x86-windows-static`, `sfml:x64-windows-static`
- Visual studio 2019 16.3.7
- Project file modified to include these lines:

<PropertyGroup Label="Globals">
  ...
  <VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
  <VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
</PropertyGroup>


To Reproduce
Steps to reproduce the behavior:
1. integrate vcpkg with visual studio as per tutorial.
2. ./vcpkg install sfml:x86-windows-static sfml:x64-windows-static
3. Create a project, modify the project file as specified above, set library switches to /MTd and /MT for debug and release
4. Copy and paste this example code:

#define SFML_STATIC // This is a bug by itself - shouldn't vcpkg define this for me?
#include <SFML/Graphics.hpp>

int main() {
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);

        while (window.isOpen()) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.draw(shape);
                window.display();
        }

        return 0;
}

5. Build and observe linking errors.

Failure logs
This is a build log with normal verbosity, building x86 debug application and manually defining `SFML_STATIC`:

1>------ Build started: Project: Test Project (Static Linking), Configuration: Debug Win32 ------
1>Build started 03.11.19 02:21:59.
1>Target InitializeBuildStatus:
1>  Touching "Debug\Test Pro.75f51cad.tlog\unsuccessfulbuild".
1>Target VcpkgTripletSelection:
1>  Using triplet "x86-windows-static" from "C:\Users\andreasxp\vcpkg\installed\x86-windows-static\"
1>Target ClCompile:
1>  main.cpp
1>Target Link:
1>  sfml-window-s-d.lib(JoystickImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__joyGetPosEx@8 referenced in function "public: static bool __cdecl sf::priv::JoystickImpl::isConnected(unsigned int)" (?isConnected@JoystickImpl@priv@sf@@SA_NI@Z)
1>  sfml-window-s-d.lib(JoystickImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__joyGetDevCapsW@12 referenced in function "public: bool __thiscall sf::priv::JoystickImpl::open(unsigned int)" (?open@JoystickImpl@priv@sf@@QAE_NI@Z)
1>  sfml-system-s-d.lib(SleepImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__timeGetDevCaps@8 referenced in function "void __cdecl sf::priv::sleepImpl(class sf::Time)" (?sleepImpl@priv@sf@@YAXVTime@2@@Z)
1>  sfml-system-s-d.lib(SleepImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__timeBeginPeriod@4 referenced in function "void __cdecl sf::priv::sleepImpl(class sf::Time)" (?sleepImpl@priv@sf@@YAXVTime@2@@Z)
1>  sfml-system-s-d.lib(SleepImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__timeEndPeriod@4 referenced in function "void __cdecl sf::priv::sleepImpl(class sf::Time)" (?sleepImpl@priv@sf@@YAXVTime@2@@Z)
1>  D:\Files\Develop\VS Projects\Test Project (Static Linking)\Debug\Test Project (Static Linking).exe : fatal error LNK1120: 5 unresolved externals
1>Done building target "Link" in project "Test Project (Static Linking).vcxproj" -- FAILED.
1>
1>Done building project "Test Project (Static Linking).vcxproj" -- FAILED.
1>
1>Build FAILED.
1>
1>sfml-window-s-d.lib(JoystickImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__joyGetPosEx@8 referenced in function "public: static bool __cdecl sf::priv::JoystickImpl::isConnected(unsigned int)" (?isConnected@JoystickImpl@priv@sf@@SA_NI@Z)
1>sfml-window-s-d.lib(JoystickImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__joyGetDevCapsW@12 referenced in function "public: bool __thiscall sf::priv::JoystickImpl::open(unsigned int)" (?open@JoystickImpl@priv@sf@@QAE_NI@Z)
1>sfml-system-s-d.lib(SleepImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__timeGetDevCaps@8 referenced in function "void __cdecl sf::priv::sleepImpl(class sf::Time)" (?sleepImpl@priv@sf@@YAXVTime@2@@Z)
1>sfml-system-s-d.lib(SleepImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__timeBeginPeriod@4 referenced in function "void __cdecl sf::priv::sleepImpl(class sf::Time)" (?sleepImpl@priv@sf@@YAXVTime@2@@Z)
1>sfml-system-s-d.lib(SleepImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__timeEndPeriod@4 referenced in function "void __cdecl sf::priv::sleepImpl(class sf::Time)" (?sleepImpl@priv@sf@@YAXVTime@2@@Z)
1>D:\Files\Develop\VS Projects\Test Project (Static Linking)\Debug\Test Project (Static Linking).exe : fatal error LNK1120: 5 unresolved externals
1>    0 Warning(s)
1>    6 Error(s)
1>
1>Time Elapsed 00:00:01.05
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Additional context
Digging around in SFML, I found out that sfml-system requires winmm library for joystick support. Maybe this library is not linked properly, which is causing joystick-related linking errors. I do not know what's causing the sleep-related errors.

Pages: [1]
anything