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.


Topics - Nexus

Pages: 1 2 3 [4] 5 6 7
46
System / Linker error at sf::Time
« on: January 21, 2012, 12:53:01 am »
Using Visual Studio 2010, I get strange linker errors when I compile the SFML Network module with dynamic (DLL) configuration.
Code: [Select]
3>Ftp.obj : error LNK2001: Unresolved external symbol ""public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)".
3>SocketSelector.obj : error LNK2001: Unresolved external symbol ""public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)".
3>TcpSocket.obj : error LNK2001: Unresolved external symbol ""public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)".

I don't see a mistake in the code, sf::Time has the SFML_API macro, and Zero is properly defined in Time.cpp. If I interpret the Dependency Walker output correctly, this symbol is exported in sfml-system-d-2.dll. With MinGW/g++, SFML compiles fine.

Can anybody confirm this? I've also found a similar problem on StackOverflow...

47
SFML website / You live in the past!
« on: January 08, 2012, 11:04:08 am »
The website footer, the SFML sources and the license file still contain old years ;)
Code: [Select]
Copyright (C) 2007-2009 Laurent Gomila
But at least, 2012 is the last year you have to adapt it :shock: :D

48
Graphics / New render cache in combination with OpenGL
« on: December 31, 2011, 05:08:59 pm »
The revision with the new render cache introduced bugs at me: Some sprites and shapes aren't rendered at all, some seem to be shifted. When I comment code that uses OpenGL out, everything works fine. Other codes using OpenGL (Thor.Particles or the SFML sample) seem to work well so far...

Is there something more to consider than PushGlStates() and PopGlStates()? Might the render cache get into trouble when one is using separate OpenGL states?

This is part of a bigger project, so it would take some time to extract everything to a minimal example. Maybe you have some general tips, otherwise I'll try to find a reproducable example.

49
General / Linux: Why 3 shared libraries per component?
« on: October 18, 2011, 05:47:49 pm »
Why are there three librares with the extensions .so, .so.2 and .so.2.0 (of which two are symbolic links) generated on Linux? I know these specify the library version, but why both .2 and .2.0?

I also have the "problem" that the linker seems to require sfml-xy.so, but the dynamic loader needs sfml-xy.so.2. That happens when I specify the flag -lsfml-xy at g++.

50
General / Compile SFML for 32 bits
« on: October 07, 2011, 05:02:28 pm »
I try to compile SFML 2 for 32 Bits on a 64 Bit Ubuntu. I have added the flag -m32 to CMAKE_CXX_FLAGS.

When I tried to build SFML, I first got errors concerning an incompatible standard library, which could be fixed through a symbolic link:
Code: [Select]
sudo ln -s /usr/lib32/libstdc++.so.6 /usr/lib32/libstdc++.so
Now a similar problem occured with the GLEW library:
Quote
Linking CXX shared library ../../../lib/libsfml-graphics.so
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libGLEW.so when searching for -lGLEW
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libGLEW.a when searching for -lGLEW
/usr/bin/ld: skipping incompatible //usr/lib/libGLEW.so when searching for -lGLEW
/usr/bin/ld: skipping incompatible //usr/lib/libGLEW.a when searching for -lGLEW
/usr/bin/ld: cannot find -lGLEW
collect2: ld returned 1 exit status

I guess I need a 32 bit version, or make the path known. But I don't know how to. I currently have the packages libglew1.5 and libglew1.5-dev installed.

Do you know more about this issue and possible solutions?

51
General / Ubuntu: Link specific SFML 2 version
« on: October 04, 2011, 10:29:17 pm »
Hi,

I'm trying to compile a project on Ubuntu, for this I use the newest SFML 2 revision. Since I want to make sure there are no version conflicts, I intend to ship the SFML .so libraries with my application. As far as I've experienced it, executables don't look first in their directory for dynamic libraries. And static linking seems not to be recommended on Linux, I would also have to link every library SFML uses.

How can I tell the executable to search in the current directory for dynamic libraries? I use Code::Blocks as IDE.

52
SFML projects / Airport
« on: October 04, 2011, 02:36:31 pm »


Hello!

Airport is a game in which you have to guide airplanes to their airfield. New planes appear on the screen every few seconds, your job is to coordinate their routes and to prevent them from colliding. The difficulty constantly increases as the time interval between arriving planes becomes shorter and shorter. How long will you survive?

Some scenes from the game:


I developed this game last winter, recently I improved it and prepared it for public release. Originally, I used realistic graphics (a real landscape). Due to licenses, I had to paint my own graphics. I hope you like them :)

The game is free and can be downloaded at my homepage. At the moment, there is only a Windows version. I am going to see if I can port the code to Linux.

53
General discussions / List of modifications from SFML 1.6 to 2.0
« on: July 16, 2011, 01:05:57 pm »
Since many SFML users have already asked this question and it might be useful for people who port projects from SFML 1.6 to Git revisions of SFML 2, I have created a list of API and functionality modifications. Feel free to complete it, I will edit this post. Note that SFML 2 is not finished yet, so the current API is still subject to change.

I only want to mention the most important and not obvious API-breaking changes to keep a good overview. Red are changes which may still compile with old code, but which introduce silent bugs and hence require special attention. Blue are pure additions.

General
  • CMake instead of specific compiler solutions and makefiles
  • Use SFML_STATIC to indicate static linkage instead of SFML_DYNAMIC for dynamic linkage
  • Changed naming convention for functions from PascalCase to camelCase
System package
  • Added sf::Vector2u typedef for sf::Vector2<unsigned int>
  • Added explicit conversion constructors from different vector types
  • All times (sf::Clock, sf::sleep(), ...) are now measured with the sf::Time class instead of float seconds
  • sf::Thread works now with function objects, no more inheritance
  • Split sf::Unicode::Text to high-level sf::String and low-level sf::Utf
  • Removed sf::Randomizer
  • Low-level memory functions operate on void* instead of char*
Window package
  • Added sf::InputStream for customized resource loading
  • Added events JoystickConnected and JoystickDisconnected to track plug/unplug of joysticks
  • Replaced sf::Input with 3 separate classes sf::Mouse, sf::Keyboard and sf::Joystick. They use global inputs, not window-specific ones.
  • Renamed sf::Window::GetEvent() to pollEvent()
  • Sizes are returned as vectors
Graphics package
  • Added low-level graphics API with sf::VertexArray, sf::Vertex, sf::Transform
  • Added sf::RenderTexture as another render target
  • Added viewport and rotation to sf::View
  • Split sf::Drawable functionality into sf::Drawable (stateless interface) and sf::Transformable (convenience base class for transformable entities)
  • Renamed sf::String to sf::Text
  • Renamed sf::PostFX to sf::Shader
  • Dynamic adaption of sf::Font, no more fixed size and character set
  • sf::Font requires the source (file, memory, ...) to remain valid throughout its lifetime
  • sf::RenderWindow::setView() now copies the sf::View
  • sf::Rect stores (left, top, width, height) instead of (left, top, right, bottom)
  • Changed sign of angles (concerns sf::Transformable rotations)
  • Split sf::Image into sf::Texture (OpenGL texture) and sf::Image (pure pixel container).
  • Renamed sf::Drawable::GetCenter(), SetCenter() to sf::Transformable::getOrigin(), setOrigin()
  • Made transformable interface to get size/bounds more uniform, now there are getLocalBounds() and getGlobalBounds()
Network package
  • Added more overloads for sf::Packet's operator<< and operator>>
  • Renamed sf::SocketTCP, sf::SocketUDP to sf::TcpSocket, sf::UdpSocket and made them non-copyable
Audio package
  • Added ability to seek in sound streams and musics
  • Fixed sf::Listener's target that was a relative direction instead of an absolute position

54
General discussions / Centralized resource handling
« on: July 07, 2011, 10:27:48 pm »
Hello,

I would like to ask the ones of you who use some kind of centralized resource management system in your projects/engines a few things. You probably have a manager who checks whether resources like sf::Image have already been loaded and permits access to them. But even if you don't use such a system and still have some ideas, just discuss!

1. Who owns the resource and is responsible of freeing it? The resource manager or the user?

2. How does the user eventually access the resources? Does the manager give back raw pointers? Shared pointers?

3. Do you find it important that a centralized manager has the full control, so that he can even force the release of resources that are in use? Or do resources have strong-reference semantics like shared_ptr, so that they can only be destroyed if no one refers to them?

The background is that in Thor, I plan to switch from thor::ResourcePtr to std::tr1::shared_ptr, because this smart pointer is widely known and can be used without a dependency to my Resources module. But I lose some flexibility by doing so, since I can no more track the users of a resource. What do you think about it?

55
Window / Resize event behavior
« on: June 28, 2011, 06:52:18 pm »
Hello, I work with Visual Studio 2010 and SFML 2 revision 175cdd... I have the following code:
Code: [Select]
#include <SFML/Window.hpp>
#include <iostream>

int main()
{
sf::Window window(sf::VideoMode(400, 300), "Resize test");

for (;;)
{
sf::Event event;
while (window.PollEvent(event))
{
if (event.Type == sf::Event::Resized)
std::cout << "Resize: w=" << event.Size.Width << ", h=" << event.Size.Height << std::endl;

else if (event.Type == sf::Event::KeyPressed)
return 0;
}

window.Display();
}
}

Two issues:

  • When I minimize the window and maximize it again, a Resize event is triggered.
  • When I draw the edges to resize the window manually, many Resize events are generated, although one would be enough.
Is this behavior intended? If so, why?

56
Graphics / Standalone header Graphics/Sprite.hpp doesn't compile
« on: June 14, 2011, 12:06:15 pm »
The famous minimal and complete example:
Code: [Select]
#include <SFML/Graphics/Sprite.hpp>

int main()
{
sf::Sprite s;
}

Error: You use the incomplete type sf::Image at line 60 of System/ResourcePtr.inl:
Code: [Select]
template <typename T>
ResourcePtr<T>::~ResourcePtr()
{
    if (myResource)
        myResource->Disconnect(*this); // <--
}

The problem is, sf::Sprite has no user-defined destructor, therefore the compiler generates one in the class definition. This leads to the instantiation of the function ResourcePtr<Image>::~ResourcePtr() inside Sprite.hpp, which requires the definition of sf::Image.

The other resource frontends (sf::Text, sf::Sound) work, although you didn't include the resource classes (sf::Font, sf::SoundBuffer). The solution is to declare a destructor in Sprite.hpp and to provide an empty implementation in Sprite.cpp.

57
General discussions / Best practices concerning time handling
« on: May 25, 2011, 03:06:50 pm »
The recent SFML change from float seconds to sf::Uint32 milliseconds leads to some trouble in my projects, especially Thor. The library must be more or less consistent with SFML, however at the same time it should be user-friendly and abstract from some basic concepts. For me, the old system was actually perfectly fine ;)

I have now changed thor::StopWatch, thor::Timer and thor::TriggeringTimer to use sf::Uint32 like sf::Clock, and I'm not sure whether this decision was a good one. While it is consistent with SFML itself, the price for this is high. On the other side, those classes are somehow higher-level than sf::Clock, hence a change towards user-friendliness (float seconds) might be appropriate.

The other place where I use times is for mechanisms that need steady updating like thor::ParticleSystem or thor::Animator. They take a parameter float dt which specifies the frame time difference. I don't want to change them to sf::Uint32 because:
  • Seconds are easier to imagine.
  • Floats make computations easier, because most other types are floats as well, and because you can store and calculate times "between" integral numbers (e.g. 0.8f * lastTime).
  • If I used milliseconds, all the dependent units like acceleration (particle affectors) should also be measured in milliseconds for consistency. This leads to very small, hard imaginable numbers.
However, the status quo is not ideal either, since conversions are omnipresent:
Code: [Select]
particleSystem.Update(window.GetFrameTime() / 1000.f);
stopWatch.Reset(static_cast<sf::Uint32>(seconds * 1000));

What do you think? Should I write wrappers that return floats? Should my time classes work with floats, although sf::Clock uses sf::Uint32? Other ideas?

58
Graphics / sf::Image subrect exceeds borders
« on: May 02, 2011, 12:54:48 am »
Good evening

In the following code, I create a red image and fill a rectangular part of it with blue color. Then, I create a sprite that takes the whole blue area as sub-rect. Therefore, if I draw the sprite, it should be entirely blue. However, this is not the case. I see a small red border on the left side of the sprite. When I set the X coordinate's decimal part to another value like .49 or .51, everything looks good. I thought the sub-rectangle would be independent of the sprite's position on the screen, how can this happen?

I use Windows 7 64Bit and the Git revision from 2011-04-18, the code has been compiled with Visual Studio 2010.
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Title");
window.SetFramerateLimit(30);

unsigned int x = 301;
unsigned int y = 303;
unsigned int s = 40;

sf::Image red, blue;
red.Create(400, 400, sf::Color::Red);
blue.Create(s, s, sf::Color::Blue);
red.Copy(blue, x, y);

sf::Sprite sprite(red);
sprite.SetSubRect(sf::IntRect(x, y, s, s));
sprite.Move(56.5f, 103.f);

for (;;)
{
sf::Event event;
while (window.PollEvent(event))
{
if (event.Type == sf::Event::Closed || event.Type == sf::Event::KeyPressed)
return 0;
}

window.Clear();
window.Draw(sprite);
window.Display();
}
}

59
General / Static link in MinGW
« on: April 27, 2011, 05:56:59 pm »
Hello,

Perhaps it's just me, but I haven't succeeded to link SFML statically on g++ with MinGW. I use the following CMake script and try to compile the SFML pong example:
Code: [Select]
cmake_minimum_required(VERSION 2.8)

project(PongExperiment)

set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2 COMPONENTS system window graphics audio)
message(STATUS "Libraries [${SFML_LIBRARIES}]")

include_directories(${SFML_INCLUDE_DIR})

add_executable(PongExperiment Pong.cpp)
add_definitions(-DSFML_STATIC)

target_link_libraries(PongExperiment ${SFML_LIBRARIES})
if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
    set_target_properties(PongExperiment PROPERTIES LINK_FLAGS "-static-libgcc")
endif()

install(TARGETS PongExperiment RUNTIME DESTINATION .)

While running CMake, I get the output of the following form, so the libraries have been chosen correctly.
Code: [Select]
debug;<PATH>/libsfml-system-s-d.a;optimized;<PATH>/libsfml-system-s.a;
When I execute Make, I get loads of undefined symbols, here an example:
Code: [Select]
C:\Program Files\C++ Libraries\SFML\MinGW\lib\libsfml-window-s.a(Window.cpp.obj)
:Window.cpp:(.text+0x445): undefined reference to `sf::Err()'

The same CMake script works fine with Visual Studio 2010 as generator. Do you know what might be wrong?

60
General discussions / Joystick enums and identifiers
« on: April 25, 2011, 11:12:44 pm »
Wouldn't it be more uniform if SFML provided an enum for Joystick buttons like for mouse (sf::Mouse::Button) or keys (sf::Key::Code)? Maybe the enumerators don't carry meaningful names, but at least you would have more type safety than with plain unsigned ints.

I noticed that when I wanted to write an overloaded function for my action event system. The joystick variant is far less expressive:
Code: [Select]
thor::Action keyAction(sf::Key::Y);
thor::Action mouseAction(sf::Mouse::Left);
thor::Action joystickAction(0, 1); // (joystick number, button number)

And the other question: Why do some identifiers contain "Joy" and some "Joystick"? Don't you want to use "Joystick" throughout the library? (Meanwhile, you must hate me for this kind of question :D)
Code: [Select]
sf::Joy
sf::Event::JoyButton
sf::Event::JoyMove
sf::Input::IsJoystickButtonDown
sf::Input::GetJoystickAxis

Pages: 1 2 3 [4] 5 6 7
anything