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

Pages: [1]
1
General / Re: State machines and map transitions
« on: November 12, 2015, 09:57:15 pm »
How does your worker thread know what it has to do? Sounds like you're notifying the worker that there's stuff to do, so shouldn't the worker trigger the loading screen, because it knows how long it should take?

The worker thread youre talking about is the one that the assets are being loaded? Also, there are 2 types of "loadings". The one that loads the assets (which is in LoadingState) and the map loading, which I am still thinking how to do that (for instance, I created the TransitionState that will load the map pointer and pop the machine stack afterwards when the loading is finished). You can see here: https://github.com/YvesHenri/Chico/tree/master/Game

2
General / Re: State machines and map transitions
« on: November 12, 2015, 08:01:54 pm »
This is a sort of 'internal' or minor state within a major state?
You could use a flag or enum to keep track of current minor state and perform certain functions based on that enum/bool. e.g. if the enum states that map is loading, don't perform updates on gameplay.

Hey, Hapax. From what I understood, this might be an internal or a small state. All it does is show a "Loading map. Please wait..." screen for as long the map is being loaded, as stated before a few times. If you looked at my github you would of have seen the state machine working flawlessly (as stated before as well), so opting for enums or whatever else is not what I'm struggling with.

There are many different approaches for something like that. IMO you shouldn't even have to load your stuff asynchronously, unless it really takes a while and is hidden behind something else, like gameplay. If you've got a loading screen, just do it in your main thread.

One approach I'd try, is to keep other states clean of your loading mechanic:
  • States queue their preloaded resources in their init() or enter() function, which is called once the state activates.
  • Once that call is done, you could check how many resources there are to load, if it's above some threshold, a loading state is automatically pushed/entered, which will render the loading screen and load assets.
  • The loading state is left once all resources have been loaded/processed, returning control to the "new" state entered before.
As for transitions and such, this really depends on what kind of transitions you want (like fading to/from black or alpha blending).

Hi, Mario. About asynchronous calls, I believe this is not "optional" but a must have. You should never have your game window frozen, not even for a few half seconds, but that just my opinion. However, in this case, the map loading does take a while (13 seconds in debugging and ~700 milliseconds on release) and is hidden behind the PlayingState, if that's what you meant.
The states themselves does load or do whatever else on their "init/enter" functions, but that applies only for the LoadingState (which is not the same as map loading) and it does work as expected (asynchronously with a progress bar). Having fade effects right now would just be a "plus". I'm making it very simple and focusing on only showing that "Loading...." string on screen.

I believe none of you got me right so I'll just try to explain clearer and again:
I'm stuck on the part that I will have to display the map loading screen (lets call it TransitionState) when the map loads, either from map.load() (forced) or from the map.update() function (dynamic), when the player enters in a teleport, for example. Like I said before, the only way I could come up with is to use the observer pattern. Map would be a LoadingNotifier and the PlayingState a LoadingListener. Is that right or are there any easier/other ways people usually do that? Hope its clearer now.

Thanks for all the input, all of you.

3
General / Re: State machines and map transitions
« on: November 11, 2015, 10:27:50 pm »
Hi there, BlueCobold. Thanks for the input.
I've seen a couple opinions over the internet about FSMs: stacks vs single states. Each of them have their cons and pros. Indeed I could opt for single states and have a pointer to the current state and it would be passed to any other state that needs them (PausedState, for example). This is basically how I've done but thats not the problem here. The problem is that I have no idea how to, or even if I have to, show transition effects (such as displaying the "Loading map. Please wait..." string), given that the PlayingState has a game Map object and it contains "teleports" that will trigger a map load. This is also supposed to work on forcibly load calls (when loading the game from a file, for example). Since the Map knows nothing about States, thats why I thought about using the Observer pattern, but I'm unsure if thats how people do that. By the way, you did not answer my question  :P

4
General / State machines and map transitions
« on: November 11, 2015, 10:07:59 pm »
Hello there, I've implemented a [basic] FSM in my game and it currently does its job very well. Recently I have come across a "problem" that I need to show a "Loading map. Please wait..." screen for as long the map is being loaded asynchronously. How do people usually do this? Is it considered a State?

For instance, these are the current states (in order):
IntroState (splash) -> LoadingState (loads textures, sounds...) -> PlayingState (optionally goes to PausedState)

The above LoadingState shows some kind of a progress bar while the assets are being loaded in another thread. Another information that might be important is that states operate the machine, for example, when the LoadingState finishes loading all the assets, it tells the machine to go to the playing state. The PlayingState has a Map object. For reference, see here: https://github.com/YvesHenri/Chico/tree/master/Game/Includes/Core/Engine/State

My current approach (which is not yet commited to github) is to make the Map object a "LoadingObservable" and the PlayingState a "LoadingListener" (observer pattern), so that inside the load call it will notify all of its listeners and theyre responsible of telling the FSM to go to the next or to go back to the previous state in the queue. Is this how people usually do that? Are there any easier/better ways to do that?

If this sounds a bit confusing please feel free to ask. Also, I'm always open for criticisms, if you have any, on my code.


5
General / Re: Static linking with Visual Studio 2012
« on: April 24, 2015, 10:41:37 pm »
I have finally managed to solve it with your hint. I did not think about it. Really.

If you google any of the functions from the posted log, you'll end up on the MSDN page and it will show that they are part of User32.lib and Advapi32.lib. Since they are usually inherited or listed as "additional libraries", I assume you must have accidentally removed them.

You were indeed right. For some reasons, the 'inherit from parent' (in the additional dependencies, if you, reader, were having the same problem) was not selected for some reason, but still, looking for the function names in the MSDN did it. I just think this post deserves a stick or the documentation/tutorial should be updated for your information to be added. It is just too confusing whether the libraries linking order matters or not and which libraries have to be linked (in my case, the 'inherit' caused the whole problem).

If you, reader, had the same problem, see the solution below.

Additional Dependencies are (just keep the order for safety):
sfml-graphics-s.lib
freetype.lib
glew.lib
jpeg.lib
sfml-window-s.lib
opengl32.lib
sfml-system-s.lib
winmm.lib
sfml-audio-s.lib
openal32.lib
sndfile.lib
sfml-network-s.lib
ws2_32.lib

Also, make sure the 'Inherit from parent or project defaults' is selected.

Thanks both of you.


6
General / Re: Static linking with Visual Studio 2012
« on: April 24, 2015, 03:08:28 am »
These are one of the things I have already done, exploiter. It's in my first post. The only problem is exactly WHICH are the missing libs and why (my fault? did they come with the SFML 2.2 zip? etc). I changed the "start up banner supressing", as the above link says and here's the log:

(click to show/hide)


In the same link above, we can see that the dependencies are as follows (http://www.sfml-dev.org/faq.php#build-link-static):

sfml-system
winmm
sfml-network
ws2_32
sfml-system
sfml-audio
openal32
sndfile
sfml-system
sfml-window
opengl32
winmm
gdi32
sfml-system
sfml-graphics
freetype
glew
jpeg
opengl32
sfml-window
sfml-system

So, this is my additional dependencies, according to the above link (can be seen the command build output above):

sfml-audio-s.lib (path to this file has been set in "additional library directories")
sfml-graphics-s.lib (path to this file has been set in "additional library directories")
sfml-network-s.lib (path to this file has been set in "additional library directories")
sfml-system-s.lib (path to this file has been set in "additional library directories")
sfml-window-s.lib (path to this file has been set in "additional library directories")
glew.lib (path to this file has been set in "additional library directories")
jpeg.lib (path to this file has been set in "additional library directories")
freetype.lib (path to this file has been set in "additional library directories")
openal32.lib (path to this file has been set in "additional library directories")
sndfile.lib (path to this file has been set in "additional library directories")
winmm.lib (this lib is stored somewhere in my computer?)
ws2_32.lib (this lib is stored somewhere in my computer?)
gdi32.lib (this lib is stored somewhere in my computer?)
opengl32.lib (this lib is stored somewhere in my computer?)


I can't find anywhere what else to be done, this is why I am here.

7
General / Re: Static linking with Visual Studio 2012
« on: April 24, 2015, 01:45:13 am »
Hey, zsbzsb. Like I said, I did also try linking with the other libs, other than the 5 SFML libs (for each module). As an information, here are the linked libs:

$(SolutionDir)Dependency\Libraries\SFML\sfml-audio-s.lib
$(SolutionDir)Dependency\Libraries\SFML\sfml-graphics-s.lib
$(SolutionDir)Dependency\Libraries\SFML\sfml-network-s.lib
$(SolutionDir)Dependency\Libraries\SFML\sfml-system-s.lib
$(SolutionDir)Dependency\Libraries\SFML\sfml-window-s.lib
$(SolutionDir)Dependency\Libraries\SFML\glew.lib
$(SolutionDir)Dependency\Libraries\SFML\jpeg.lib
$(SolutionDir)Dependency\Libraries\SFML\freetype.lib
$(SolutionDir)Dependency\Libraries\SFML\openal32.lib
$(SolutionDir)Dependency\Libraries\SFML\sndfile.lib

Note 1: these are the ONLY libs that comes with the x86 SFML 2.2 (in the download section of this website)


The inherited libs:

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib

Note 2: The 2.2 tutorial says to link the opengl32.lib and some others I cant remember right now, however these dont come with the SFML 2.2 zip. Am I missing something?


If you meant the "build log", heres is the FULL build log with all the 10 libs above:

(click to show/hide)


Otherwise, if by "command" you mean the linker "command line", here it is:

(click to show/hide)

8
General / Static linking with Visual Studio 2012
« on: April 23, 2015, 11:34:00 pm »
Hello there. First of all, this is my first post here.
Well, as the tittle says, I can't dynamic link the SFML 2.2 libraries into my project. I'm using Visual Studio 2012 and the respective SFML 2.2 x86 files. My project has a few custom settings and I did pay attention to:

- set the SFML_STATIC for the preprocessor
- set the path to the libraries folder (so its not necessary to put the full path to every lib file)
- set the -d libs for debug and no -d libs for release
- tried linking with the "freetype, glew, jpeg, openal32 and sndfile" lib files which come with the SFML 2.2 I downloaded from this site (note that "opengl32, ws2_32 and some others lib" are not in this list) and without them

However, it still did not work. Here's a small part of the build log:

1>------ Build started: Project: Game, Configuration: Release Win32 ------
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
1>sfml-graphics-s.lib(Texture.cpp.obj) : error LNK2001: unresolved external symbol __imp__glBindTexture@8
1>sfml-graphics-s.lib(TextureSaver.cpp.obj) : error LNK2001: unresolved external symbol __imp__glBindTexture@8
1>sfml-graphics-s.lib(Texture.cpp.obj) : error LNK2001: unresolved external symbol __imp__glCopyTexSubImage2D@32
...

So, what am I doing wrong? Also, does it have something to do with the "/LTCG" warning above? If so, how do I fix it?
Thanks in advance

Pages: [1]