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

Pages: 1 2 [3] 4
General discussions / [IDEA] Move sf::Rect into System Module?
« on: August 22, 2011, 05:25:47 am »
Hello SFML Community!

I was looking over the library and every time I use sf::Rect I always include the system module. However I always forget its in the Graphics Module. Wouldn't it make more sense to put it in the systems module? Just an idea. Nothing to important. Just in my opinion I think it would have a better home in the system module.


General discussions / Window drag keep rendering (solution) [SFML 2.0]
« on: August 05, 2011, 03:41:36 am »
Quote from: "Disch"
I'd be very interested in knowing how you could make it safe without a lock.  I have been thinking about it, and the more I think about it, the more I'm convinced a lock would be necessary.  But I've been wrong before.

Can you show an example?

I've been researching these 'lock-free' queues. Very interesting. Haven't tested one but I learned sometimes lock-free doesn't mean there are no locks. It could mean non-blocking? Pretty interesting stuff indeed. I hate feeling like a noob!

General discussions / Window drag keep rendering (solution) [SFML 2.0]
« on: August 04, 2011, 02:51:35 am »
Quote from: "OniLink10"
Seems like a reasonable solution. I don't know much about the internals, but I'm guessing it works because as long as the window is resizing, you won't run out of resize events, and this separates rendering from events, correct?

Kind of... Windows pauses the main thread when the window is being dragged or resized. Therefore to keep rendering you need to do it in another thread. Now if you where to use that thing above I'd recommend taking all the events in the main thread and push them into a vector. Put it back into the rendering thread. Just make sure its thread-safe! I'll post an example if needed.

Can someone try this on linux?

General discussions / Window drag keep rendering (solution) [SFML 2.0]
« on: August 01, 2011, 04:26:59 pm »
Hello there! After doing research on why the SFML window is paused when you dragged I think I found a decent solution. It works on windows, maybe linux. I don't think it will on mac tho. Anyways I just wanted to see what you guys thought of this code I wrote up.

If you were to use this, I'd recommended creating a thread safe event manager to pass the events on into the other thread.

Code: [Select]

#include <iostream>
#include <math.h>
#include <SFML/Graphics.hpp>

void GameThread(sf::RenderWindow *window)
sf::Image sfmlLogo;

sf::Sprite sprLogo;
sprLogo.SetOrigin(floor(sfmlLogo.GetWidth() / 2.f), floor(sfmlLogo.GetHeight() / 2.f));

while (window->IsOpened())


int main()
sf::RenderWindow window;
sf::Thread gameThread(&GameThread, &window);
sf::Event event;

window.Create(sf::VideoMode(800,600,32), "Test");


if (event.Type == sf::Event::Closed)



Party on,
Preston Alvarado

p.s. I didn't know where to post this to be honest. This forum category seemed good enough.

Graphics / Blurry Font
« on: July 26, 2011, 06:38:40 am »
Quote from: "Laurent"
Yeah... I just want to make sure it is really necessary before implementing it. My previous tests showed that unsmoothed fonts always looked worse than smoothed ones, so I'm a little surprised.

I would be game for sf::Font::SetSmooth. That little trick posted above fixed everything in my project. :)

General discussions / New global inputs in SFML 2
« on: July 15, 2011, 06:56:49 am »
Very nice! I love the new API for inputs. I went to update to the latest commit (since I was behind a few) and it totally broke my engine. I was wondering where some of the functions went haha I guess that's the price of development releases. Keep it up.

General discussions / A new logo for SFML
« on: June 14, 2011, 12:39:20 am »
I like Cpl.Bator's logo a lot. Only thing I would change on it is the gear colors. Make the SFML text popout more.  :D

Feature requests / [Request] sf::Sprite Flip Methods
« on: March 21, 2011, 11:43:59 pm »
Hello everyone,

After using SFML for a while now I realized the sf::Sprite::FlipX and FlipY doesn't really fit in with the rest of the sprite class. All of the other methods are mainly Get and Set. I think we should do a SetFlipX, SetFlipY, SetFlip (X + Y). Also add a GetFlipX and GetFlipY.

Also I don't know if this would be something else to add but when you flip a image also flip the origin with it. Maybe make that another method,,, I don't know lol

General discussions / My plans for the website tools
« on: March 19, 2011, 07:43:17 pm »
This is awesome! GIT is so much better then SVN. I used to like SMF but now I like MyBB (Free) and XenForo (Paid) for forum system. Oh well at least SMF is better then phpbb!  :D

Graphics / sf::Sprite / sf::Image pointer...
« on: April 19, 2010, 04:43:03 am »
Quote from: "Svenstaro"
See this fine tutorial for game states: http://gamedevgeek.com/tutorials/managing-game-states-in-c/

See here for singletons and other awesome game programming patterns and tips: http://gameprogrammingpatterns.com/singleton.html

Also, as always, do not overengineer. Do not use a design pattern for everything you do. If a function with a few overloads does fine, use that. There are, however, a bunch of examples in game programming where you almost always apply the same patterns, like singletons for resource managers.

Okay so im still a little confused about what design patterns to use. I did a lot more research and I kind of like the Service Locator one. However I like the concept of my structure.

I have an engine class that creates an instance of a ImageManager and ScreenManager. Then in the main thread you add the screens to the manager and use the run command. The rest is done in the Screen classes.

You opened my head to different ways of structuring and the hardest part is figuring out which one best fits my needs.

Edit: p.s. looks like im changing the subject and probably should create a new topic on game structure XD

General / Re: LNK-Error: Unresolved external... when using sf:window
« on: April 17, 2010, 12:50:15 am »
Quote from: "Incubbus"
Error   12   error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)   c:\Users\Incubbus\documents\visual studio 2010\Projects\sfml-window\sfml-window\sfml-window-s.lib(WindowImplWin32.obj)

what the hack?... i did link wiht ANY library and it still does not work...
i only succeeded in compiling the clock-example... hahahah... (yes i have the right directorys included)... i did just copy the examples for creating a window...

anyone may know what i did misconfigure?...

Okay I can only think of two things thats wrong.

1. Your order of the librarys are messed up (but I dont think that happens anymore. I dont know. I had a weird problem like that a long time ago. I use sfml-graphics-s.lib

2. I see your using Visual Studios 2010. I dout you compiled your librarys with visual studios 2010 therefore you need to tell visual studios to use the compiler from 2008.

Project -> Properties -> Platform Toolset -> Set to v90.

Hope this helps.

Graphics / sf::Sprite / sf::Image pointer...
« on: April 17, 2010, 12:41:46 am »
Quote from: "Svenstaro"
I'd recommend you rethink your architecture. Keep in mind this is all meant as constructive criticism :).

Use a singleton for all your global manager so that they are constructed first (even before a call to main()) and destructed last.
Use a Boost.Ptr_container for storing dynamically allocated data (stuff you constructed with new).
Use a stack of states that does not need to destroy another state on change (for example by going from intro to menu to game and back to menu) but rather suspend and resume those states.

Manual allocation and deallocation of memory is probably not a thing you want to worry about when doing very high-level C++ in a game or such.

Thanks for the suggestions. Im going to learn about singleton. Do you know any good tutorials or examples for this? Also I heard about factories? Are those design patterns any good?

Im going to try the boost map pointer container.

Well the stack thing the construct should only be ran once during the game and destruct at the end.

Graphics / sf::Sprite / sf::Image pointer...
« on: April 16, 2010, 06:19:58 am »
Quote from: "Svenstaro"
Is Images a private member map/set of ImageManager? Does Images.begin()->first/second point to anything valid (not 0x00000000)?

Also, since you are apparently dynamically allocating the images, why are you not using a safe_ptr like boost::shared_ptr or even better boost::ptr_map? It would spare you from even having to manually delete all the images.

Umm the images map is private... but everyone draws? Could this be the issue? I dont know never used those before. Really just creating a loop to delete them works just as fine... (or does it lol)

p.s. If you dynamically create sprites this issue also doesn't happen. Im starting to think it has to do with sfml and image pointers.

Graphics / sf::Sprite / sf::Image pointer...
« on: April 16, 2010, 06:11:51 am »
Quote from: "Svenstaro"
Can you post the callstack at the moment of the segfault then to let us see where exactly the problem occurs?

Well if I release screens first then image manager the error is located here.

Code: [Select]
ImageManager::~ImageManager() {
std::cout << "[ImageManager] Releasing Images,,," << std::endl;
while( Images.begin() != Images.end() ) {
std::cout << "[ImageManager] Releasing " << Images.begin()->first << std::endl;
delete Images.begin()->second;
Images.erase( Images.begin() );
std::cout << "[ImageManager] Releasing Done" << std::endl;

At the delete Images.begin()->second;

and some more code
Code: [Select]
void MenuScreen::Construct() {
this->im->LoadImage("background", "./menuback.png");

void MenuScreen::Destruct() {
//sprBackground = sf::Sprite();
std::cout << "Good bye mean world!" << std::endl;

void MenuScreen::Update(float Delta) {


void MenuScreen::Draw() {

If I do it that way I need to uncomment the sprBackground in Destruct.

Graphics / sf::Sprite / sf::Image pointer...
« on: April 16, 2010, 05:52:34 am »
Quote from: "Svenstaro"
It works the way because after you delete the ImageManager your image pointers are obviously invalidated and when drawing a Sprite you are drawing an invalid image.

I understand that but there is no drawing this is at the end of the game execution. I have to delete the image manager before the screen manager even tho the screen manager isn't accessing any members of image manager in that destructor. If I want to delete the screen manager then the image manager i had to set every sprite to a new sf::Sprite. I dont understand why shouldn't it just delete >.<

Code: [Select]
delete this->sm;
delete this->im;

Wont work...

Code: [Select]
delete this->im;
delete this->sm;

will lol.

Pages: 1 2 [3] 4