PDA

View Full Version : PGD Annual 2007 - Questions to Sascha Willems



Sascha Willems
01-02-2007, 11:50 PM
In order to make communication between the entrants and myself easier I open up this thread were you can ask questions directd at my judging and system. I'll also try to later on report and answer to problems that entries cause on my system, so you have a direct feedback during the competition.

Note : Please refrain from discussing the competition itself here, we have different threads for that, only questions directed at me in here please ;)

Specifications of my main desktop system which I'll mostly use for testing your entries, the second one will only be used if there are problems. Please read the notes when appropriate, it'll maybe spare you some troubles :

CPU : AMD Athlon 64 X2 4200+
Note : This is a Dual-Core CPU. So it's possible that when you use time-based movement it'll have problems on dual cores and cause choppy or wrong movement. So please try to use hi-speed timers like QueryPerformanceCounter as they work. If you're unsure about this please ask, and I'll tell how to use that one for proper timing
Memory : 1 GByte
Graphics : Leadtek GF 7900GS with 256 MBytes of VRAM
Note : I always use the newest drivers available. The card itselfs supports Shaders up to SM3.0 and also glSlang
Monitor : BenQ FP202W 20.1" Widescreen(!) TFT
Note : The native resolution is 1680x1050 at 32BPP with 60Hz. This has a ratio of 16:10 (usual monitors are 4:3), so please add a form of widescreen support to your game, cause otherwise everything will looked stretched which isn't good looking. So either detect 16:10 and make your game have black bars when running at that res or better make it also look right at that resolution (e.g. changing FOV in a 3D-game)
Sound : Soundblaster X-Fi! Extreme Music
Note : It's connected to a nice 5.1 surroundsetup (with a Yamaha RX-V457) so I'd love to "see" some nice music and sound with a high bitrate. Bad sounds sound even worse on a good setup, please keep that in mind. The soundcard also supports all new standards, up to EAX5.0 and OpenAL.
OS : Windows XP Pro with SP2
Gamepad : Logitech Cordless Rumblepad 2
It has one digital Pad, 2 analog pad (which means 3 axis), 6 buttons on the front and 4 shoulder buttons. It supports force feedback, though rarely any PC game uses it.
Joystck : Saitek Cyborg Evo
More-or-less standard stick (except it can be adjusted in all weird ways) with a Coolie-Hat, 12 Buttons and 3 axis. It also has a throttlecontrol as a fourth axis.

Specs of my second system :
Athlon XP 2600+, 1GByte of Memory, Leadtek GF6800 (256 MBytes), 22" CRT (4:3) with desired res of 1600x1200 at 85Hz (32BPP), Sound is NForce Soundstorm (which is actually very advanced for onboard sound). OS is the same as above, input devices too.

And since I'm from germany please take a look at this thread (http://www.pascalgamedevelopment.com/viewtopic.php?t=4098) if you want to make a game that is e.g. set in World War 2. We have strict laws about most third reich symbols so make sure you comply to the above thread or otherwise I'm not allowed to download your entry.

IlovePascal
03-02-2007, 09:48 PM
Hey there!

Here is your first question:



Note : This is a Dual-Core CPU. So it's possible that when you use time-based movement it'll have problems on dual cores and cause choppy or wrong movement. So please try to use hi-speed timers like QueryPerformanceCounter as they work. If you're unsure about this please ask, and I'll tell how to use that one for proper timing

and Im not sure what you mean.
I usually write games in this type of set up in the main loop:


...
gettime(...);
timenow := s100 + sec*100 + min*100*60 + hr*100*60*60;
if timenow-timebefore >= timedelay then
begin
Move_Guy;
timebefore:=timenow;
end;
...


Is this what I'm NOT supposed to do, or is it something completely different?

Cheers ;)

Sascha Willems
03-02-2007, 10:05 PM
The method you use is not time-based movement, with time-based movement you don't wait for a certain time to pass but update movements each frame based on time between the current and the last frame. And many people still use functions like GetTickCount which are not fine-grained enough for measuring speeds at high frame rates (GetTickCount works on milliseconds and with frametimes below 10ms won't give you correct results) and may cause troubles on modern multi-core systems.

So I added the above note, as I also had some problems with correct timing after switching to a dual-core system, as it's possible that your thread get's moved to another core without noticing and you then could have a time-gap. So I e.g. stopped using the OnIdle-Event but rather start up my own loop after game init and do timing only with high-performance funtions like QueryPerformanceCounter.

If you need more information, take a look at this link from Microsoft (http://msdn2.microsoft.com/en-us/library/bb173458.aspx) that shows how to do correct timing on multi-core systems.

IlovePascal
03-02-2007, 10:24 PM
Ok I get the idea.
The routines described in tht link, are they for DirectX only? Is it the same for OpenGL? Or does it actually use neither and I'm just making a fool of myself? :oops:

Sascha Willems
03-02-2007, 10:35 PM
They are from the Windows API and are in no way linked to any graphics API. So as long as you use windows the functions in that article can be used.

IlovePascal
03-02-2007, 10:43 PM
Ok :roll:
I jst thought I'd ask because their is a large DirectX sign at the top of the page...but tht's probably jst some advertising :wink:

LP
03-02-2007, 10:50 PM
So I added the above note, as I also had some problems with correct timing after switching to a dual-core system, as it's possible that your thread get's moved to another core without noticing and you then could have a time-gap.
Sorry if it's a little off-topic, but... on dual-core when running a single process that tries to take 100% of the CPU, in Task Manager I see that the total CPU usage is 50% (ok, one core is used fully) but both cores are used at 25%! Is Windows constantly switching the process between two cores? Because if I set affinity to only one CPU, then indeed it gets used to 100% while the other one being idle. Is this true? If yes, then what is the reason for this constant switching?

P.S. The above happens on my Intel Core 2 Duo...

Sascha Willems
04-02-2007, 01:10 AM
What you see also happens on my AMD Dualcore, but only after installing the dual-core optimizer from AMD. Otherwise (if I remember correct) without that one and the CPU driver a single-threaded app only runs on one core.
But with a specialized driver, the workload will get split between the CPUs, though I can't tell how that's exactly done. It also does that in most of the games that use only one core where they then only take up 50% CPU time on each of the cores. So I think it's a driver thing.
But actually this doesn't change any behaviour within the application itself, so except for correct timing you don't need to take care for multi cores.

Mirage
04-02-2007, 07:29 AM
As I know QueryPerformanceCounter sometimes doesn't work correctly on Athlon 64 X2 processors. AMD has released a driver update to fix this issue. But I'm not sure that this update was installed by all my users.:(

I use the following code and had no problems(Globals.CurrentMs uses GetTickCount()):



const Interval = 30; // 30 ms
...
while LastProcessingMs + Interval <= Globals.CurrentMs do begin
Process&#40;&#41;; // some processing
Inc&#40;LastProcessingMs, Interval&#41;;
end;


As you can see I do not compare GetTickCount results.

vgo
04-02-2007, 11:42 AM
Here's what I wrote for my engine:

var
QPCFrequency: Int64;
QPCEnabled: Boolean;
CurrentTime, LastTime, CurrentDeltaTime, TotalTime: Single;

procedure UpdateDeltaTime;
var
Time: Int64;
begin
if QPCEnabled then
begin
QueryPerformanceCounter(Time);
CurrentTime := (Time / QPCFrequency);
if LastTime = 0 then
CurrentDeltaTime := 0
else
CurrentDeltaTime := CurrentTime - LastTime;
end
else
begin
CurrentTime := TimeGetTime;
if LastTime = 0 then
CurrentDeltaTime := 0
else
CurrentDeltaTime := (CurrentTime - LastTime) / 1000;
end;
gDeltaTime := CurrentDeltaTime;
LastTime := CurrentTime;
TotalTime := TotalTime + CurrentDeltaTime;
end;


I check for QueryPerformanceCounter/Frequency on initialization phase and use it if possible, if the check fails then I use TimeGetTime which seems to work quite well even on my AMD Athlon X2.

Sascha Willems
04-02-2007, 11:49 AM
QueryPerformanceCounter actually works on any processor since the original Pentium, so checking wether it's available or not is a waste of time.
As I said it also works perfect on AMDs dual-core CPUs as long as you install current drivers for the CPU.

Eric
06-02-2007, 07:16 PM
There is also a cheap solution to avoid multi-core issues if you will never be able to test, it's not elegant, but it will effectively restrict your process to running on the first core only:


SetProcessAffinityMask&#40;GetCurrentProcess, 1&#41;;

at the beginning of your dpr or whatever main unit. It will take care of every inconsistencies due to flipping between cores (including time ones). There is also a SetThreadAffinityMask which can be useful if you'll be running multiple threads and want them on a particular core, but if you're doing that, then you probably already knew about it in the first place :twisted:

Sascha Willems
10-02-2007, 10:08 PM
After Athena posted her OpenGL-Subsystem information Will asked me to also upload the report from glInfo, and here it is (http://www.delphigl.de/misc/saschawillems_glspecs.htm).

As I'm doing OpenGL-developement myself and also use glsl-shaders and other recent techniques there shouldn't be any real troubles with even advanced OpenGL games on my system.

pstudio
11-02-2007, 12:12 AM
Monitor : BenQ FP202W 20.1" Widescreen(!) TFT
Note : The native resolution is 1680x1050 at 32BPP with 60Hz. This has a ratio of 16:10 (usual monitors are 4:3), so please add a form of widescreen support to your game, cause otherwise everything will looked stretched which isn't good looking. So either detect 16:10 and make your game have black bars when running at that res or better make it also look right at that resolution (e.g. changing FOV in a 3D-game)

Do you now an easy way to detect if it's 16:10 or 4:3?

Sascha Willems
11-02-2007, 12:22 AM
Switch to fullscreen, get width and height of the set resolution and divide them and check the ratio.

E.g. if it's set to 1680x1050 it's a ratio of 1,6 (16:10), whereas 1024x768 gives 1,333... (4:3) and e.g. 1600x900 is 1,77.... (16:9). Those three are the most common resolution ratios (with 16:9 being the least usual for the PC) so checking for those three should be enough.

And if your game is 3D you can use this FOV-calculator (http://www.widescreengamingforum.com/fovcalc.php) to see what your normal FOV calculates to in a widescreen resolution. Note that for 3D you don't necessarily need to support a widescreen resolution but rather the ratio. This is done in e.g. Armed Assualt which only allows 4:3 resolutions (like 1280x1024) and then let's you select your screens ratio. The game then just changes the FOV.

Note that I don't see widescreen resolution as necessary, but games look stretched in width if they are not fitted to use that resolutions, that's e.g. the cause for why I will never ever buy a commercial game that does not support WS (like the new Rainbow Six). But don't be afraid, I won't boycot your entry just cause of a lack for widescreens ;)

Huehnerschaender
11-02-2007, 12:59 AM
Just to bring more confusion into the WS topic, 1280x1024 is none of the above mentioned aspect ratios.... it's some kind of special resolution with a ratio of 1.25 :)

WILL
11-02-2007, 02:19 AM
Well on my laptop which is a widescreen I have 1280x800. Which is common for some of the newer wide laptop screens.

Huehnerschaender
18-02-2007, 12:46 PM
I have a question concerning Saschas role in the competition.

Am I allowed to ask him questions concerning Newton Game Dynamics?

I mean, on one hand he is the contact person for Newton (at least the one I would ask my questions) and on the other hand he is a judge in the competition, so if he helps out with answers, I don't know if this is correct...

3_of_8
18-02-2007, 01:33 PM
You said I shouldn't use GetTickCount... Well, actually I'm using SDL_GetTicks(). QueryPerformanceCounter wouldn't work as it's intended to bei platform independent.

technomage
18-02-2007, 02:00 PM
I have a question concerning Saschas role in the competition.

Am I allowed to ask him questions concerning Newton Game Dynamics?

I mean, on one hand he is the contact person for Newton (at least the one I would ask my questions) and on the other hand he is a judge in the competition, so if he helps out with answers, I don't know if this is correct...

I had a similar situation regarding SDL_net in one of the competitions. I would suggest that you post your questions on the Newton Forum, that way Sascha can answer, but also other members of the forum might be able to help as well.

I guess as long as everyone has the option to ask questions (which we do ) it shouldn't be seen as helping out..

savage
18-02-2007, 06:55 PM
I agree, as long as the questions about Newton are made public, then I don't think there can be any question as to the legality of a Judge helping out.

Huehnerschaender
18-02-2007, 08:26 PM
This sounds fine to me...

Right now I don't need any help. I was able to solve most of my problems by trial and error and reading the SDK.

It was just some kind of preventive question, if I get totally stuck on something...

Thanks for the answers so far.

Greetings,
Dirk

Sascha Willems
19-02-2007, 10:54 AM
You said I shouldn't use GetTickCount... Well, actually I'm using SDL_GetTicks(). QueryPerformanceCounter wouldn't work as it's intended to bei platform independent.
As I said you should use a high-precision timer and QPC is the one for windows. But I'm sure there is also one for linux, so maybe it would be best to use compiler directives to do timing with the high precision timer for the approprite OS. Though I'm not totally sure if SDL_GetTicks isn't already doing that.


Am I allowed to ask him questions concerning Newton Game Dynamics?
Well, Savage already said it : If you have any questions ask them public, either over here or at the newton forums (though I visit PGD more often). Just make it public somehow and refrain from PM'ing me, as I won't answer any PMs during the contest regarding to contest entries cause that wouldn't be fair to the other entrants.

IlovePascal
02-04-2007, 06:56 AM
Hey there, I know I have no right to complain about the judging in the competition, and it is in no way what i want to do.

I would like to ask, however, why is it that you did not give me points for the second goal ('Update your Readme.txt files explaining more about your entry's gameplay and how it will bring together all 2+ genre types into your game').
I know I did not implement my second genre yet, but I did write about how it will be put together and the other judges did give me those points.

Thank you for your patience... (nt tht I care about 5 pts!)

Huehnerschaender
05-04-2007, 08:44 AM
Hi Sascha,

in your comments to my stage 3 entry you mentioned that the buttons in cannon mode did not work properly.

Can you please tell me what exactly did not work? Did the collision seem to be misplaced? Did you change the resolution (Did you set a 16/10 resolution)? I tried several settings here and I cannot find anything bad with button collision. But I have no possibility to test 16/10 resolutions. It's working well here. So I need your help to find this bug :)

I think I "repaired" the broken physics. Driving bulldozer is smooth now. But I still need to find a way to control newtons calculations framerate-independend. The way 3_of_8 posted in his MechaChess Thread caused the problems you have seen in stage3 entry.
It's exactly the behaviour I posted there as one of my answers... if the PC is not fast enough to render the scene with a good framerate, the calculations of newton will punish the CPU, resulting in bigger and bigger lags each frame. Thats why Christina got performance problems with this version.

jdarling
05-04-2007, 02:45 PM
But I have no possibility to test 16/10 resolutions.
Dirk, why can't you test 16/10? Just run the game in windowed mode and force the w/h to fit 16/10 standards within your max screen res. This is what I've done the few times I couldn't get to a widescreen.

WILL
05-04-2007, 03:08 PM
Window mode runs much slower than fullscreen. This might be more of a pain in the arse then helpful for debugging, depending on his system's performance capabilities. :?

However it might be worth a try if he has a high-end system.

Sascha Willems
05-04-2007, 03:16 PM
I tried the game in windowed mode and not in 16:10 fullscreen. But after looking at it again it might be more of a problem with an irritating cursor. In artillery mode your cursor looks like a steering wheel and from it's look the cursor's center should be in the center of the texture but somehow that's not the case so the buttons feel like being offset. Dunno if it's the cursor or a problem with the UI, but maybe dump that cursor for a cursor where the user is actually able to tell where the hit point is.

Huehnerschaender
05-04-2007, 04:51 PM
Ah! thank you very much for this "little but big" hint! You had the wrong cursor.... There is a bug which sometimes chooses the wrong cursor. The steering wheel is for the normal view only. When cursor moves over a steerable vehicle/item it should change to the wheel-cursor (the doubleclick feature to go into steer mode is not finished yet). But in the cannon UI you should have the arrow cursor, which has its clickpoint to the upper left corner... with the wrong cursor you also have the clickpoint upper left corner, but the graphic does not point to that click point. Now I understand your problems. Thanks. This will be fixed...


And thanks for the simple "trick" to test 16/10... I wonder why I did not had this idea myself :)

And Will, I always run the games in windowed mode here. I wonder how you debug your games in fullscreen?! When I try this (with my DirectX apps) and the game/app stops due to an error, I mostly have no chance to get back to the IDE... In nearly all cases I have to kill the game or BDS itself by the taskmanager.

And yes, my system is able to run games smooth in windowed mode (X1600 Pro, Athlon 64 4000, 1 GB RAM)

Greetings,
Dirk