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

Pages: [1]
1
Graphics / Animated sprite in SFML
« on: February 03, 2012, 09:04:18 pm »
I'm planning a little animated sprite class for SFML. I think it makes sense to inherit from sf::Drawable or sf::Sprite (the first seems nicer in theory, but I think the second might work better, or at least more easily, in practice).

Anyway, I have two little questions to help me decide on implementation.

1. Is there much of a performance difference between loading lots of small textures as opposed to one large one?
2. Is either of sf::Sprite::SetTexture or sf::Sprite::SetSubRect likely to be significantly faster (I don't know if this question can be easily answered, if not I guess I could use a profiler if I really wanted to...)

Thanks,
Xander

2
Graphics / Using sf::RenderWindow::Capture() efficiently
« on: January 10, 2012, 09:48:33 pm »
I noticed today that sf::Image::CopyWindow has been replaced by sf::RenderWindow::Capture().

I wanted to ask how to use this function efficiently, given the performance overhead of copying an image.

Is there something better than this:
Code: [Select]

sf::Image screenshot = Window.Capture();


I know the copy related to the return of an sf::Image can be optimised out, but how can I get around the overhead of the assignment operation?

I suppose I could do this:
Code: [Select]

sf::Image& screenshot = Window.Capture();

but in some circumstances I imagine there would be issues of scope/lifetime of the returned temporary.

3
Graphics / Text Problem - Funny dotted lines
« on: November 05, 2011, 02:43:53 pm »
When displaying text in SFML, strange dotted lines can be seen as shown in the picture.



I pulled the latest SFML source from the Git repository just a few minutes ago and this did not fix the problem. The font I am using is FreeSerif.ttf (with a Unix system), but it similarly occurred with the SFML default font.

The code used to load the font:
Code: [Select]

    sf::Font Main;
    cout << "-> /usr/share/fonts/truetype/freefont/FreeSerif.ttf...";
    if (!Main.LoadFromFile("/usr/share/fonts/truetype/freefont/FreeSerif.ttf"))
        return 1;


The code used to create the text:
Code: [Select]

 // victory message
        sf::Text VictoryMessage("", Main, 100U * VMode.Height / 900);
        VictoryMessage.SetColor(sf::Color::White);

(plus an additional bit to set the string and centre the text). And finally it's drawn with sf::RenderWindow::Draw().

Any ideas what could be causing this?

PS: I'm right now trying a minimal example and will post back the results soon.

4
General / SFML 2.0 Dependencies - Ubuntu
« on: August 13, 2011, 12:41:13 pm »
Sorry if this has been asked before, but is there somewhere I could find a complete list of dependencies for SFML 2.0 on Ubuntu? (There's a dependency list in the 1.6 tutorial, but I was under the impression SFML has changed the libraries it uses quite a lot since then).

Thanks,
Xander

5
Some viewers of my blog and YouTube channel asked me if I could upload prebuilt SFML 2.0 binaries. What I was intending to do was upload the complete SFML 2.0 source from GitHub, but with the binaries added.

Having read SFML's license, it looks like I can do this, provided I leave the license.txt file in there. However, it would mean that I was also distributing binaries for OpenAL, libsndfile, FreeType, etc.

For example, GLEW is under the 2 clause BSD license which requires a copyright notice to be distributed with its binary. However, I could not find such a license. Laurent, how have you got around this when distributing the files with SFML? Do the license bits in the top of the extlibs/ header files suffice?

EDIT: Also, you say that SFML uses libpng, zlib, stb_vorbis and SOIL. There are no binaries or headers for any of these. Are they already linked to other external library binaries?

6
Audio / openal32.dll
« on: July 08, 2011, 10:33:07 am »
I had always assumed this file to be necessary to any application using audio, or at least those using positional audio. However, the following code runs perfectly happily when linked statically to SFML and provided only with libsndfile-1.dll, not openal32.dl.

When is openal32.dll necessary?

Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main()
{
sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");

sf::Image Image;
Image.LoadFromFile("image.png");
sf::Sprite Sprite(Image);
Sprite.Resize(800.0f, 600.0f);

sf::SoundBuffer Buffer;
Buffer.LoadFromFile("sound.wav");
sf::Sound Sound(Buffer, true);
  Sound.SetPosition(5.0f, 1.0f, 10.0f);
Sound.Play();
  sf::Listener::SetPosition(0.0f, 0.0f, 0.0f);

while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
default:
break;
}
}

Window.Clear();
Window.Draw(Sprite);
Window.Display();
}

return 0;
}

7
General discussions / SFML Logo License
« on: July 02, 2011, 12:49:19 pm »
I want to modify the SFML logo to use as the logo for my (mainly SFML related) blog and videos which may in the future be used for advertising my products as well as with Google Adsense, etc. Would that be permitted under the logo's license?

Thanks
-Xander

8
Graphics / SFML Default Font is Working
« on: June 27, 2011, 06:02:32 pm »
Peculiar title, I know ;)

Anyway, I was trying to reproduce some of the SFML font errors so I could point them out in the Fonts & Texts tutorial I am making. However, I was unable to do so.

Linking to static/dynamic and debug/release, the following code worked:
Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
sf::Text text("Hobo!");
sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "Hello World!");

while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
default:
break;
}
}

Window.Clear();
Window.Draw(text);
Window.Display();
}

return 0;
}


Are all the default font troubles and the related issues with dynamic linkage fixed now, or is this just an intermittent reprise?

9
Graphics / Video Modes and Colour Depth
« on: June 13, 2011, 04:55:32 pm »
For a video tutorial I am making on windowing and video modes, I was wondering what happens when we give our video mode something like 11bit colour.

It is invalid for fullscreen mode, but what happens for windowed applications?

Also, to clarify, when a bad video mode is passed to the window constructor, does it revert to sf::VideoMode::GetDesktopMode()?

10
SFML website / Post Reply button redirects to Forum Index
« on: May 28, 2011, 12:32:10 pm »
Frequently, when I click the "Post Reply" button at the bottom of a thread, I am simply redirected to the main forum index.

I am using Windows 7 & Google Chrome 11.0.696.71. I didn't seem to experience the issue with IE8.

Is anyone else having such a problem?

11
Graphics / Fitting Sprite to Window on Resize
« on: May 28, 2011, 12:13:20 pm »
I was resizing my sprite to fit my window using:
Code: [Select]
Sprite.Scale((float)Window.GetWidth()/(float)Sprite.GetImage()->GetWidth(), (float)Window.GetHeight()/(float)Sprite.GetImage()->GetHeight());
and then
Code: [Select]
Sprite.Resize(Window.GetWidth(), Window.GetHeight());
when the sf::Event::Resize event is dispatched.

However, I have noticed that when I resize the window smaller than the video mode, the sprite no longer fits the screen. Why is this? And is there anything I can do about it?

Also, for the sf::Event::Resize event, what is the relevance of the values Event::Size::Width and Event::Size::Height. Surely they are the same as the values returned by Window::GetWidth() and Window::GetHeight()?

12
General / Multithreading, splash screens and sf::Sprites
« on: May 20, 2011, 03:36:40 pm »
I am writing a splash screen class to display while loading. I want it to be created on the main thread and then display itself on a separate thread until I tell it to quit.

This was working fine. However, I also want to display an image in this splash screen window, so I need an sf::Sprite. However, whenever I add the sf::Sprite, the program crashes when it's destructor is called (saying Windows has triggered a breakpoint).

Here is my code; any help fixing this problem would be greatly appreciated :D

Code: [Select]

class SplashScreen {
sf::Image Image;
sf::Font Font;
sf::Thread* Thread;
bool Running;
unsigned Width, Height;
const std::string Caption, Heading;

void Execute()
{
sf::Sprite bg(Image);
bg.Scale((float)Width/(float)Image.GetWidth(), (float)Height/(float)Image.GetHeight());
Running = true;
sf::RenderWindow Window(sf::VideoMode(Width, Height, 32), Caption, sf::Style::None);
while (Running)
{
Window.Draw(bg);
Window.Display();
}
}

public:
SplashScreen(unsigned Width, unsigned Height, const std::string& Heading, const std::string& Caption, const std::string& ImageFilename, const std::string& FontFilename = "arial.ttf")
: Width(Width), Height(Height), Caption(Caption), Heading(Heading)
{
if (!Image.LoadFromFile(ImageFilename))
throw Exceptions::BadFile(ImageFilename);

if (!Font.LoadFromFile(FontFilename))
throw Exceptions::BadFile(FontFilename);

Thread = new (std::nothrow) sf::Thread(&SplashScreen::Execute, this);
if (!Thread)
throw Exceptions::BadAllocation();
}
~SplashScreen()
{
Stop();
delete Thread;
}
void Run()
{
Thread->Launch();
}
void Stop()
{
Running = false;
Thread->Wait();
}
};

13
General / SFML Static libraries and /NODEFAULTLIB
« on: May 14, 2011, 03:16:26 pm »
I built the static SFML binaries in Visual Studio. However, when I try to link them get a warning:
warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library   

Having done a bit of research, I checked the runtime libraries used in each case. However both the SFML projects and my project use multithreaded debug DLL for debug config, and multithreaded DLL for release config.

So the used runtime libraries match and yet I still get this error. Does anyone have any idea why?

Thanks in advance for your help, and sorry if this has been asked before and I missed the answer: I did look around, but nowhere did there seem to be a straightforward solution...

14
System / Overhead of sf::Thread::Launch
« on: April 23, 2011, 01:48:25 pm »
I am writing a class to handle 'per frame' multithreading, i.e. graphics, physics, audio etc operations to be run each frame. I then call this every frame:
Code: [Select]
for (unsigned itr=0; itr<ProcessLists.size(); itr++)
    ProcessLists[itr].first->Launch();


where ProcessLists is a map:
Code: [Select]
std::map<sf::Thread*, ProcessList*>
and ProcessList is a class I wrote which defines the list of operations to be carried out on that thread.

My question is: is it inefficient to call sf::Thread::Launch every fram?. Does this function create the actual (Win32) thread etc., or is that done in the constructor? Is there a large overhead associated with sf::Thread::Launch?

Thanks in advance for any help.

15
General / Bulding SFML in VS2010
« on: March 20, 2011, 11:03:38 am »
I am trying to build SFML 1.6 from the sources, but I am having problems getting Visual C++ 2010 Express to create the import libraries. i saw another thread about this and tried what it suggested: correcting the output directory and adding the names of the import libraries.

However, this still doesn't work. The only way I could get VC++ to build import libraries was by putting the full directory path and filename in the import library property. This doesn't seem like the best way to do it.

Does anyone have any suggestions?

Pages: [1]