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

Pages: [1]
1
Graphics / Width of a space in sf::Text
« on: March 18, 2012, 11:03:07 pm »
I am finishing my TextArea widget and to make things easier for me to implement quickly I treat each word in my TextArea as a separate object. I know the space I should leave between the lines thanks to the sf::Font::getLineSpacing(characterSize) and I figured out I could get the space I should leave between the words just by getting the width of the "space" Glyph. But...

Code: [Select]
 float space_size = 1.0f * font.getGlyph(0x20, characterSize, false).bounds.width;
  float bold_space_size = 1.0f * font.getGlyph(0x20, characterSize, true).bounds.width;

  std::cout << "spaces " <<  space_size << " " << bold_space_size <<std::endl;


...it turns out the space character (0x20) has width of a zero.

Is there a good way of getting the width of a space I should leave between two words? Apart from imperfect ideas such as "getting the width of an 'a' glyph" or "getting width of of two words separated with a space and subtracting the sum of the lengths of the individual words"?

2
Just a quick question: is the fact, that Music's loading functions begin with "open" and all the other classes (Image, Font, SoundBuffer) have their corresponding functions beginning with "load" deliberate? Why the inconsistency? Is there a reason behind it I failed to grasp?

By the way: if all the Image, Font, Music... classes inherited the same abstract interface class like "Loadable" it could sometimes save people from writing the repetitive cod for each of them individually - but it might be another thing Laurent thought through and decided against :)

3
Feature requests / float operator/ (const Time &left, const Time &right
« on: February 28, 2012, 08:14:20 pm »
Just a brief feature request: I love the Time functionality so far, but I realized I could find such an operator quite useful:
Code: [Select]
float operator/ (const Time &left, const Time &right)
//or, for my particular use, even better
int operator/ (const Time &left, const Time &right)

This way I could, for example, do

Code: [Select]
int frames_to_advance = diffTime / frameTime

without resorting to AsMilliseconds() or perhaps multiple substraction. Plus It might be faster if it was implemented inside the class instead of by the users.

Does this make any sense to anyone?

4
System / [solved] error: ‘sf::Time’ has not been declared
« on: February 12, 2012, 05:17:14 pm »
I am using the latest 2.0 version and everything works fine except for the sf::Time class, which isn't getting imported
Code: [Select]
#include <SFML/System.hpp>
class Widget {
  public:
    //...
    virtual void repaint(sf::RenderTarget *renderTarget, sf::Time sinceLastFrame) = 0;
};


and during compilation i get the following error:
Quote
[100%] Building CXX object renderer/CMakeFiles/renderer.dir/Widget.cpp.o
cd /home/nietaki/zpp/TheGameShow_build/renderer && /usr/bin/c++    -I/home/nietaki/zpp/TheGameShow_build -I/home/nietaki/zpp/TheGameShow/libs -I/home/nietaki/zpp/TheGameShow -I/home/nietaki/zpp/TheGameShow/google_mock/include -I/home/nietaki/zpp/TheGameShow/google_mock/gtest/include -I/usr/local/include   -o CMakeFiles/renderer.dir/Widget.cpp.o -c /home/nietaki/zpp/TheGameShow/renderer/Widget.cpp
In file included from /home/nietaki/zpp/TheGameShow/renderer/Widget.cpp:8:
/home/nietaki/zpp/TheGameShow/renderer/Widget.h:26: error: ‘sf::Time’ has not been declared


I'm sure it has something to do with the SFML_SYSTEM_API macro, but despite looking through the code I don't really understand how it works.

Any thoughts?

I'm using the latest 2.0 version from github under Linux, building shared libs.

5
General discussions / cross-platform c++ resource container library?
« on: January 07, 2012, 03:20:54 pm »
I spent a better part of today searching the web for a good library/way to store resource files in packages in my project. There were many nice leads, but none of them seemed right for me.

Here's what I mean by good:

- cross-platform (my team already develops on linux, windows and OSX)
- c++, not c - I've got enough problems as it is without linking my c++ code to c
- the compression isn't a priority, the main objective is to minimize the number of reads from hdd
- easy to use/build automatically with CMake (?)

and what I found:
- the hailed zlib doesn't seem to have cross platform c++ wrapper
- zipios++ is a long dead beta project
- http://icculus.org/physfs/ looks great, but also lacks the wrappers

...and so on and on.

Surely one of you guys knows/has used a good alternative. As I said, I don't specifically need zip, just a way to store multiple files in one file (preferably in a semi-structured way).

6
General / [CMAKE] getting access to the .dlls
« on: December 18, 2011, 12:23:36 am »
I recently moved on to try if SFML would work on Windows too ;), and along the way I went to rewrite the CMakeLists.txt for my project.

I was following this tutorial, slightly modifying it for my needs and everything went just as planned, it all works great with VS 2010, but I have one question.

The important part of my CMakeLists.txt:
Code: [Select]

find_package(SFML 2.0 REQUIRED system window graphics network audio)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()

# Install
install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${PROJECT_BINARY_DIR}/bin)
install(FILES ${SFML_LIBRARIES} DESTINATION ${PROJECT_BINARY_DIR}/bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/resources DESTINATION ${PROJECT_BINARY_DIR}/bin/resources)


As you can see I wanted to create a directory with the standalone program (executable, resources and the shared libraries) in the "install" target. But as you might also suspect, the
Code: [Select]
install(FILES ${SFML_LIBRARIES} DESTINATION ${PROJECT_BINARY_DIR}/bin) copies the .lib files, not the .dll files, when used under Windows with VS. Is there a better way of doing it?

I know I could
a) install SFML to somewhere inside the PATH, like a normal person would
b) modify the PATH (at least before launching the executable)
c) do a windows if (if(CMAKE_HOST_WIN32)) and rework the ${SFML_LIBRARIES} and change lib -> bin and .lib -> .dll and install those files that way

...but I would like to have a universal, one-step solution that would work on any system (even if I can't install SFML to the system directories) without any needless tinkering with the paths and the makefile. Plus I guess having such a "ready to go" directory would be nice if at any time I wanted to make a simple installer ;)

Am I missing something? How should I go about doing it?

7
General / SFML 2.0 building with cmake almost working
« on: November 22, 2011, 12:10:59 am »
Hi,
I recently started to dig into SFML and I was happy to see the 2.0 version is cmake-enabled. I installed the required packages (debian squeeze x64)
Code: [Select]
libglew1.5-dev libxrandr-dev libfreetype6-dev libjpeg8-dev libsndfile1-dev libopenal-dev libpthread-stubs0-dev libxrandr2-dbg libx11-dev doxygen
and built it (with examples and docs) according to the example. Now the thing is, when I build it with shared libs chosen it works allright (or so it seems), but when I choose static libs I get an error building the OpenGL example.

Code: [Select]
Scanning dependencies of target opengl
[ 85%] Building CXX object examples/opengl/CMakeFiles/opengl.dir/OpenGL.cpp.o
Linking CXX executable opengl
../../lib/libsfml-graphics-s.a(Font.cpp.o): In function `sf::Font::SetCurrentSize(unsigned int) const':
Font.cpp:(.text+0x181): undefined reference to `FT_Set_Pixel_Sizes'
../../lib/libsfml-graphics-s.a(Font.cpp.o): In function `sf::Font::GetLineSpacing(unsigned int) const':
Font.cpp:(.text+0x441): undefined reference to `FT_Set_Pixel_Sizes'
../../lib/libsfml-graphics-s.a(Font.cpp.o): In function `sf::Font::GetKerning(unsigned int, unsigned int, unsigned int) const':
Font.cpp:(.text+0x8d7): undefined reference to `FT_Set_Pixel_Sizes'
Font.cpp:(.text+0x8e5): undefined reference to `FT_Get_Char_Index'
Font.cpp:(.text+0x8f2): undefined reference to `FT_Get_Char_Index'
Font.cpp:(.text+0x903): undefined reference to `FT_Get_Kerning'
../../lib/libsfml-graphics-s.a(Font.cpp.o): In function `sf::Font::Cleanup()':


...and a lot more lines like those, the full transcript here. When I try to build other example targets individually they fail similarly.

However if I choose to build with shared libs, it looks like it finishes allright, but when I try to launch any of the example executables I get a shared library loading error:

Code: [Select]
nietaki@logical:~/zpp/SFMLbuild/examples/pong$ ./pong
./pong: error while loading shared libraries: libsfml-audio.so.2: cannot open shared object file: No such file or directory
nietaki@logical:~/zpp/SFMLbuild/examples/sockets$ ./sockets
./sockets: error while loading shared libraries: libsfml-network.so.2: cannot open shared object file: No such file or directory


Am I doing something wrong? Or is it the charm of the pre-release version ;)? I've seen Nexus stating he's using it already...

PS. This is also my "hello" post, I am now checking out SFML and if I end up choosing it over SDL for my BS project you'll end up stuck with me for a few months ;)

edit: I tried it on my x86 netbook just to make sure and the results were exactly the same, I might try it under windows tommorow but if I don't get this solved I won't be able to get the platform independence my team was hoping for ;)

Pages: [1]
anything