Jump to content
  • Advertisement
Sign in to follow this  
space_cadet

Frame-based jump'n'run - not smooth, ugly tearing

This topic is 4902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, for my little jump'n'run I measure the time between the last frame and the current one, then I scale each movement accordingly. Now in practice, this doesn't look very good: the movement is uneven and there is tearing. Have a look at the current game (needs DirectX9). Use the arrow keys to move. 1. Why is the movement uneven? Is this normal for frame-based games, or did I overlook something? 2. Somewhere I read it's generally more feasible for jump'n'run-type games to choose a fixed framerate (e.g. 60hz). Is this true, and why? Regards, Sebastian

Share this post


Link to post
Share on other sites
Advertisement
have you been checking the results of your frame timing? All it take is an integer division in the wrong spot to really mess up your timing. Make sure that is correct first. How are you timing between frames?

Share this post


Link to post
Share on other sites
Hmm, double-checked everything and it seems fine. I have a timer object which is called once at the very end of every frame, after rendering. The object does a QueryPerformanceCounter() and stores the time that has passed since the last call (in seconds):

float nFactor = (float)(m_nTimeNow - m_nTimeLast) / (float)m_nCountsPerSec;

That's it. All movements are multiplied by nFactor. My logfile shows a printout of nFactor:


seconds: 0.127996
seconds: 0.005832
seconds: 0.000941
seconds: 0.000788
seconds: 0.000735
seconds: 0.000719
seconds: 0.000927
seconds: 0.001523
seconds: 0.000755
seconds: 0.001061
seconds: 0.001577
seconds: 0.000802
seconds: 0.000951
seconds: 0.001003
seconds: 0.001109
seconds: 0.001117
seconds: 0.001107
seconds: 0.001112
seconds: 0.001108
seconds: 0.001103
seconds: 0.001358
seconds: 0.000881
seconds: 0.001138
seconds: 0.001063
seconds: 0.001109
seconds: 0.001105
seconds: 0.001107
seconds: 0.001110
seconds: 0.001003
seconds: 0.001336
seconds: 0.000902
seconds: 0.001092
seconds: 0.001114
seconds: 0.001113
seconds: 0.001107
seconds: 0.001113
seconds: 0.001112
seconds: 0.001109
seconds: 0.001119
seconds: 0.001111
seconds: 0.001100
seconds: 0.001116
seconds: 0.001109
seconds: 0.001012
seconds: 0.001102
seconds: 0.001110
seconds: 0.001112
seconds: 0.001275
seconds: 0.000957
seconds: 0.001103
seconds: 0.001111
seconds: 0.001110
seconds: 0.001112
seconds: 0.001109
seconds: 0.001112
seconds: 0.001114
seconds: 0.001114
seconds: 0.001107
seconds: 0.001043
seconds: 0.001112
seconds: 0.001119
seconds: 0.001106
seconds: 0.001110
seconds: 0.001112
seconds: 0.001107
seconds: 0.001258
seconds: 0.000972
seconds: 0.001107
seconds: 0.001112
seconds: 0.001107
seconds: 0.001113
seconds: 0.001115
seconds: 0.001108
seconds: 0.001069
seconds: 0.001114
seconds: 0.001109
seconds: 0.001105
seconds: 0.001110
seconds: 0.001111
seconds: 0.001112
seconds: 0.001110
seconds: 0.001111
seconds: 0.001112
seconds: 0.001273
seconds: 0.000972
seconds: 0.001104
seconds: 0.001111
seconds: 0.001120
seconds: 0.001074
seconds: 0.001108
seconds: 0.001113
seconds: 0.001113
seconds: 0.001251
seconds: 0.000990
seconds: 0.001108
seconds: 0.001110
seconds: 0.001109
seconds: 0.001118
seconds: 0.001108
seconds: 0.001112
seconds: 0.001107
seconds: 0.001307
seconds: 0.000940
seconds: 0.001081
seconds: 0.001111
seconds: 0.001105
seconds: 0.001109
seconds: 0.001114
seconds: 0.001113
seconds: 0.001114
seconds: 0.001191
seconds: 0.001043
seconds: 0.001106
seconds: 0.001115
seconds: 0.001117
seconds: 0.001112
seconds: 0.001115
seconds: 0.001115
seconds: 0.001088
seconds: 0.001276
seconds: 0.000969
seconds: 0.001110
seconds: 0.001114
seconds: 0.001115
seconds: 0.001115
seconds: 0.001120
seconds: 0.001109
seconds: 0.001114
seconds: 0.001492
seconds: 0.000970
seconds: 0.000900
seconds: 0.001112
seconds: 0.001107
seconds: 0.001082
seconds: 0.001116
seconds: 0.001110
seconds: 0.001113
seconds: 0.001305
seconds: 0.000931
seconds: 0.001109
seconds: 0.001114
seconds: 0.001117
seconds: 0.001116
seconds: 0.001113
seconds: 0.001113
seconds: 0.001115
seconds: 0.001122
seconds: 0.001296
seconds: 0.000896
seconds: 0.001112
seconds: 0.001117
seconds: 0.001118
seconds: 0.001114
seconds: 0.001115
seconds: 0.001116
seconds: 0.001271
seconds: 0.000975
seconds: 0.001111
seconds: 0.001113
seconds: 0.001106
seconds: 0.001114
seconds: 0.001112
seconds: 0.001115
seconds: 0.001082
seconds: 0.001135
seconds: 0.001108
seconds: 0.001114
seconds: 0.001114
seconds: 0.001112
seconds: 0.001110
seconds: 0.001111
seconds: 0.001117
seconds: 0.001113
seconds: 0.001282
seconds: 0.000964
seconds: 0.001115
seconds: 0.001120
seconds: 0.001111
seconds: 0.001071
seconds: 0.001121
seconds: 0.001116
seconds: 0.001124
seconds: 0.001183
seconds: 0.001057
seconds: 0.001119
seconds: 0.001112
seconds: 0.001114
seconds: 0.001114
seconds: 0.001110
seconds: 0.001107
seconds: 0.001116
seconds: 0.001295
seconds: 0.000955
seconds: 0.001061
seconds: 0.001112
seconds: 0.001115
seconds: 0.001109
seconds: 0.001110
seconds: 0.001114
seconds: 0.001115
seconds: 0.001133
seconds: 0.001111
seconds: 0.001113
seconds: 0.001115
seconds: 0.001111
seconds: 0.001105
seconds: 0.001110
seconds: 0.001116
seconds: 0.001072
seconds: 0.001346
seconds: 0.000929
seconds: 0.001074
seconds: 0.001116
seconds: 0.001111
seconds: 0.001109
seconds: 0.001113
seconds: 0.001112
seconds: 0.001112
seconds: 0.001126
seconds: 0.001108
seconds: 0.001108
seconds: 0.001116
seconds: 0.001110
seconds: 0.001074
seconds: 0.001112
seconds: 0.001116
seconds: 0.001109
seconds: 0.001276
seconds: 0.000953
seconds: 0.001107
seconds: 0.001104
seconds: 0.001116
seconds: 0.001111
seconds: 0.001113
seconds: 0.001104
seconds: 0.001109
seconds: 0.001118
seconds: 0.001113
seconds: 0.001087
seconds: 0.001103
seconds: 0.001110
seconds: 0.001109
seconds: 0.001112
seconds: 0.001111
seconds: 0.001107
seconds: 0.001300
seconds: 0.000929
seconds: 0.001106
seconds: 0.001113
seconds: 0.001115
seconds: 0.001103
seconds: 0.001115
seconds: 0.001112
seconds: 0.001103
seconds: 0.001110
seconds: 0.001105
seconds: 0.001107
seconds: 0.001114
seconds: 0.001112
seconds: 0.001113
seconds: 0.001109
seconds: 0.001111
seconds: 0.001107
seconds: 0.001247
seconds: 0.000964
seconds: 0.001108
seconds: 0.001110
seconds: 0.001098
seconds: 0.001100
seconds: 0.001103
seconds: 0.001101
seconds: 0.001107
seconds: 0.001224
seconds: 0.000999
seconds: 0.001099
seconds: 0.001105
seconds: 0.001100
seconds: 0.001109
seconds: 0.001107
seconds: 0.001099
seconds: 0.001107
seconds: 0.001388
seconds: 0.000924
seconds: 0.000986
seconds: 0.001103
seconds: 0.001097
seconds: 0.001105
seconds: 0.001099
seconds: 0.001098
seconds: 0.001109
seconds: 0.001332
seconds: 0.000932
seconds: 0.001066
seconds: 0.001093
seconds: 0.001100
seconds: 0.001103
seconds: 0.001105
seconds: 0.001091
seconds: 0.001082
seconds: 0.001036
seconds: 0.005179
seconds: 0.000750
seconds: 0.000725
seconds: 0.000730
seconds: 0.000934
seconds: 0.001098
seconds: 0.001103
seconds: 0.001093
seconds: 0.001092
seconds: 0.001095
seconds: 0.001094
seconds: 0.001091
seconds: 0.001094
seconds: 0.001099
seconds: 0.001091
seconds: 0.001316
seconds: 0.000924
seconds: 0.001049
seconds: 0.001095
seconds: 0.001093
seconds: 0.001100
seconds: 0.001093
seconds: 0.001092
seconds: 0.001094
seconds: 0.001294
seconds: 0.000928
seconds: 0.001061
seconds: 0.001055
seconds: 0.001138
seconds: 0.001041
seconds: 0.001091
seconds: 0.001092
seconds: 0.001094
seconds: 0.001086
seconds: 0.001414
seconds: 0.000812
seconds: 0.001057
seconds: 0.001098
seconds: 0.001090
seconds: 0.001089
seconds: 0.001088
seconds: 0.001089
seconds: 0.000982
seconds: 0.001100
seconds: 0.001089
seconds: 0.001097
seconds: 0.001098
seconds: 0.001093
seconds: 0.001099
seconds: 0.001090
seconds: 0.001101
seconds: 0.001095
seconds: 0.001276
seconds: 0.000939
seconds: 0.001089
seconds: 0.001091
seconds: 0.001097
seconds: 0.001047
seconds: 0.001097
seconds: 0.001097
seconds: 0.001092
seconds: 0.009436
seconds: 0.000825
seconds: 0.001543
seconds: 0.000816
seconds: 0.000798
seconds: 0.000826
seconds: 0.000733
seconds: 0.000870
seconds: 0.001106
seconds: 0.001095
seconds: 0.001101
seconds: 0.001466
seconds: 0.001247
seconds: 0.000784
seconds: 0.001423
seconds: 0.000743
seconds: 0.000987
seconds: 0.001096
seconds: 0.001106
seconds: 0.001099
seconds: 0.001128
seconds: 0.001555
seconds: 0.000832
seconds: 0.001389
seconds: 0.000747
seconds: 0.000921
seconds: 0.001112
seconds: 0.001110
seconds: 0.001100
seconds: 0.001107
seconds: 0.002110
seconds: 0.000896
seconds: 0.000826
seconds: 0.000732
seconds: 0.000992
seconds: 0.001078
seconds: 0.001105
seconds: 0.001102
seconds: 0.001112
seconds: 0.001263
seconds: 0.000963
seconds: 0.001106
seconds: 0.001114
seconds: 0.001115
seconds: 0.001108
seconds: 0.001108
seconds: 0.001115
seconds: 0.001111
seconds: 0.001123
seconds: 0.001100
seconds: 0.001095
seconds: 0.001108
seconds: 0.001116
seconds: 0.001108
seconds: 0.001114
seconds: 0.001108
seconds: 0.001114
seconds: 0.001302
seconds: 0.000927
seconds: 0.001106
seconds: 0.001112
seconds: 0.001109
seconds: 0.001114
seconds: 0.001111
seconds: 0.001109
seconds: 0.001103
seconds: 0.001206
seconds: 0.001024
seconds: 0.001112
seconds: 0.001112
seconds: 0.001109
seconds: 0.001110
seconds: 0.001114
seconds: 0.001110
seconds: 0.001111
seconds: 0.001328
seconds: 0.000933
seconds: 0.001095
seconds: 0.001126
seconds: 0.001112
seconds: 0.001109
seconds: 0.001117
seconds: 0.001118
seconds: 0.001198
seconds: 0.001209
seconds: 0.000962
seconds: 0.001116
seconds: 0.001121
seconds: 0.001114
seconds: 0.001125
seconds: 0.001128
seconds: 0.001124
seconds: 0.001119
seconds: 0.001223
seconds: 0.001055
seconds: 0.001068
seconds: 0.001135
seconds: 0.001131
seconds: 0.001132
seconds: 0.001135
seconds: 0.001127
seconds: 0.001135
seconds: 0.001146
seconds: 0.001134
seconds: 0.001140
seconds: 0.001131
seconds: 0.001140
seconds: 0.001132
seconds: 0.001137
seconds: 0.001139
seconds: 0.001027
seconds: 0.001368
seconds: 0.000911
seconds: 0.001141
seconds: 0.001133
seconds: 0.001139
seconds: 0.001144
seconds: 0.001140
seconds: 0.001137
seconds: 0.001136
seconds: 0.001213
seconds: 0.001068
seconds: 0.001144
seconds: 0.001143
seconds: 0.001129
seconds: 0.001073
seconds: 0.001131
seconds: 0.001143
seconds: 0.001141
seconds: 0.001426
seconds: 0.000861
seconds: 0.001137
seconds: 0.001145
seconds: 0.001143
seconds: 0.001143
seconds: 0.001143
seconds: 0.001143
seconds: 0.001251
seconds: 0.001050
seconds: 0.001130
seconds: 0.001139
seconds: 0.001140
seconds: 0.001143
seconds: 0.001141
seconds: 0.001144
seconds: 0.001142
seconds: 0.001390
seconds: 0.000895
seconds: 0.001141
seconds: 0.001144
seconds: 0.001144
seconds: 0.001144
seconds: 0.001140
seconds: 0.001145
seconds: 0.001166
seconds: 0.001233
seconds: 0.000933
seconds: 0.001143
seconds: 0.001143
seconds: 0.001143
seconds: 0.001141
seconds: 0.001146
seconds: 0.001140
seconds: 0.001140
seconds: 0.001428
seconds: 0.000875
seconds: 0.001140
seconds: 0.001140
seconds: 0.001127
seconds: 0.001100
seconds: 0.001140
seconds: 0.001145
seconds: 0.001556
seconds: 0.000909
seconds: 0.000962
seconds: 0.001145
seconds: 0.001143
seconds: 0.001140
seconds: 0.001145
seconds: 0.001139
seconds: 0.001143
seconds: 0.001409
seconds: 0.001096
seconds: 0.000907
seconds: 0.001142
seconds: 0.001142
seconds: 0.001142
seconds: 0.001143
seconds: 0.001140
seconds: 0.001145
seconds: 0.001260
seconds: 0.001027
seconds: 0.001144
seconds: 0.001141
seconds: 0.001139
seconds: 0.001147
seconds: 0.001139
seconds: 0.001143
seconds: 0.001041
seconds: 0.001386
seconds: 0.000910
seconds: 0.001140
seconds: 0.001139
seconds: 0.001143
seconds: 0.001144
seconds: 0.001141
seconds: 0.001142
seconds: 0.001145
seconds: 0.001328
seconds: 0.000971
seconds: 0.001142
seconds: 0.001146
seconds: 0.001119
seconds: 0.001129
seconds: 0.001149
seconds: 0.001146
seconds: 0.001707
seconds: 0.000814
seconds: 0.000933
seconds: 0.001140
seconds: 0.001144
seconds: 0.001140
seconds: 0.001146
seconds: 0.001144
seconds: 0.001147
seconds: 0.001160
seconds: 0.001134
seconds: 0.001071
seconds: 0.001146
seconds: 0.001144
seconds: 0.001141
seconds: 0.001140
seconds: 0.001148
seconds: 0.001141
seconds: 0.001394
seconds: 0.000892
seconds: 0.001145
seconds: 0.001143
seconds: 0.001143
seconds: 0.001146
seconds: 0.001149
seconds: 0.001143
seconds: 0.001036
seconds: 0.001187
seconds: 0.001110
seconds: 0.001145
seconds: 0.001141
seconds: 0.001143
seconds: 0.001145
seconds: 0.001152
seconds: 0.001143
seconds: 0.001143
seconds: 0.001454
seconds: 0.000848
seconds: 0.001148
seconds: 0.001155
seconds: 0.001129
seconds: 0.001152
seconds: 0.001141
seconds: 0.001147
seconds: 0.001449
seconds: 0.000867
seconds: 0.001146
seconds: 0.001154
seconds: 0.001144
seconds: 0.001143
seconds: 0.001142
seconds: 0.001142
seconds: 0.001145
seconds: 0.001498
seconds: 0.000815
seconds: 0.001018
seconds: 0.001141
seconds: 0.001143
seconds: 0.001145
seconds: 0.001137
seconds: 0.001142
seconds: 0.001142
seconds: 0.001246
seconds: 0.001043
seconds: 0.001143
seconds: 0.001146
seconds: 0.001139
seconds: 0.001142
seconds: 0.001141
seconds: 0.001132
seconds: 0.001064
seconds: 0.001311
seconds: 0.000988
seconds: 0.001143
seconds: 0.001141
seconds: 0.001143
seconds: 0.001136
seconds: 0.001141
seconds: 0.001141
seconds: 0.001545
seconds: 0.000750
seconds: 0.001143
seconds: 0.001134
seconds: 0.001141
seconds: 0.001138
seconds: 0.001148
seconds: 0.001144
seconds: 0.001144
seconds: 0.001496
seconds: 0.000805
seconds: 0.001142
seconds: 0.001198
seconds: 0.001090
seconds: 0.001142
seconds: 0.001140
seconds: 0.001141
seconds: 0.001145
seconds: 0.001154
seconds: 0.001137
seconds: 0.001044
seconds: 0.001144
seconds: 0.001143
seconds: 0.001143
seconds: 0.001147
seconds: 0.001148
seconds: 0.001143
seconds: 0.001269
seconds: 0.001030
seconds: 0.001144
seconds: 0.001144
seconds: 0.001141
seconds: 0.001142
seconds: 0.001144
seconds: 0.001118
seconds: 0.001112
seconds: 0.001159
seconds: 0.001148
seconds: 0.001145
seconds: 0.001149
seconds: 0.001151
seconds: 0.001146
seconds: 0.001154
seconds: 0.001141
seconds: 0.001623
seconds: 0.000698
seconds: 0.001126
seconds: 0.001154
seconds: 0.001141
seconds: 0.001083
seconds: 0.001144
seconds: 0.001143
seconds: 0.001146
seconds: 0.001171
seconds: 0.001126
seconds: 0.001149
seconds: 0.001148
seconds: 0.001145
seconds: 0.001141
seconds: 0.001144
seconds: 0.001143
seconds: 0.001146
seconds: 0.001286
seconds: 0.001024
seconds: 0.001036
seconds: 0.001144
seconds: 0.001140
seconds: 0.001144
seconds: 0.001149
seconds: 0.001146
seconds: 0.001147
seconds: 0.001151
seconds: 0.001146
seconds: 0.001145
seconds: 0.001143
seconds: 0.001142
seconds: 0.001146
seconds: 0.001155
seconds: 0.001134
seconds: 0.001769
seconds: 0.000694
seconds: 0.001002
seconds: 0.001146
seconds: 0.001144
seconds: 0.001155
seconds: 0.001146
seconds: 0.001152
seconds: 0.001148
seconds: 0.006138
seconds: 0.000707
seconds: 0.000592
seconds: 0.000747
seconds: 0.001158
seconds: 0.001159
seconds: 0.001345
seconds: 0.000970
seconds: 0.001159
seconds: 0.001157
seconds: 0.001147
seconds: 0.001153
seconds: 0.001146
seconds: 0.001150
seconds: 0.001471
seconds: 0.000833
seconds: 0.001131
seconds: 0.001150
seconds: 0.001141
seconds: 0.001147
seconds: 0.001147
seconds: 0.001148
seconds: 0.001147
seconds: 0.001400
seconds: 0.000904
seconds: 0.001153
seconds: 0.002619
seconds: 0.000749
seconds: 0.000719
seconds: 0.000723
seconds: 0.001109
seconds: 0.001086
seconds: 0.001197
seconds: 0.001121
seconds: 0.001156
seconds: 0.001160
seconds: 0.001155
seconds: 0.001162
seconds: 0.001155
seconds: 0.001159
seconds: 0.002180
seconds: 0.000962
seconds: 0.000751
seconds: 0.000769
seconds: 0.001119
seconds: 0.001078
seconds: 0.001148
seconds: 0.001143
seconds: 0.001141
seconds: 0.001925
seconds: 0.000822
seconds: 0.000741
seconds: 0.001127
seconds: 0.001149
seconds: 0.001159
seconds: 0.001155
seconds: 0.001146
seconds: 0.001149
seconds: 0.001453
seconds: 0.000850
seconds: 0.001059
seconds: 0.001151
seconds: 0.001145
seconds: 0.001153
seconds: 0.001148
seconds: 0.001155
seconds: 0.001152
seconds: 0.001235
seconds: 0.001067
seconds: 0.001145
seconds: 0.001682
seconds: 0.000824
seconds: 0.000938
seconds: 0.001141
seconds: 0.001134
seconds: 0.001892
seconds: 0.000816
seconds: 0.000748
seconds: 0.001151
seconds: 0.001145
seconds: 0.001146
seconds: 0.001156
seconds: 0.001154
seconds: 0.001150
seconds: 0.001195
seconds: 0.001105
seconds: 0.001152
seconds: 0.001146
seconds: 0.001158
seconds: 0.001041
seconds: 0.001148
seconds: 0.001149
seconds: 0.001153
seconds: 0.001447
seconds: 0.000855
seconds: 0.001146
seconds: 0.001147
seconds: 0.001140
seconds: 0.001141
seconds: 0.001141
seconds: 0.001146
seconds: 0.001255
seconds: 0.001109
seconds: 0.001058
seconds: 0.001206
seconds: 0.001086
seconds: 0.001139
seconds: 0.001153
seconds: 0.001152
seconds: 0.001148
seconds: 0.001571
seconds: 0.000816
seconds: 0.001099
seconds: 0.001147
seconds: 0.001152
seconds: 0.001147
seconds: 0.001153
seconds: 0.001149
seconds: 0.001049
seconds: 0.001346
seconds: 0.000968
seconds: 0.001141
seconds: 0.001145
seconds: 0.001152
seconds: 0.001143
seconds: 0.001144
seconds: 0.001145
seconds: 0.001152
seconds: 0.001432
seconds: 0.000874
seconds: 0.001144
seconds: 0.001158
seconds: 0.001119
seconds: 0.001114
seconds: 0.001147
seconds: 0.001150
seconds: 0.001176
seconds: 0.001142
seconds: 0.001148
seconds: 0.001159
seconds: 0.001160
seconds: 0.001154
seconds: 0.001150
seconds: 0.001155
seconds: 0.001153
seconds: 0.001459
seconds: 0.000867
seconds: 0.001065
seconds: 0.001146
seconds: 0.001148
seconds: 0.001151
seconds: 0.001151
seconds: 0.001147
seconds: 0.001142
seconds: 0.001201
seconds: 0.001098
seconds: 0.001143
seconds: 0.001143
seconds: 0.001147
seconds: 0.001146
seconds: 0.001154
seconds: 0.001141
seconds: 0.001074
seconds: 0.001521
seconds: 0.000792
seconds: 0.001159
seconds: 0.001157
seconds: 0.001158
seconds: 0.001157
seconds: 0.001158
seconds: 0.001159
seconds: 0.001452
seconds: 0.000868
seconds: 0.001155
seconds: 0.001158
seconds: 0.001155
seconds: 0.001097
seconds: 0.001158
seconds: 0.001157
seconds: 0.001157
seconds: 0.001447
seconds: 0.000858
seconds: 0.001154
seconds: 0.001149
seconds: 0.001148
seconds: 0.001144
seconds: 0.001147
seconds: 0.001158
seconds: 0.001152
seconds: 0.001227
seconds: 0.001083
seconds: 0.001076
seconds: 0.001159
seconds: 0.001159
seconds: 0.001157
seconds: 0.001160
seconds: 0.001157
seconds: 0.001162
seconds: 0.001385
seconds: 0.000927
seconds: 0.001157
seconds: 0.001159
seconds: 0.001156
seconds: 0.001154
seconds: 0.001149
seconds: 0.001094
seconds: 0.001296
seconds: 0.001015
seconds: 0.001145
seconds: 0.001152
seconds: 0.001144
seconds: 0.001152
seconds: 0.001150
seconds: 0.001151
seconds: 0.001150
seconds: 0.001517
seconds: 0.000812
seconds: 0.001155
seconds: 0.001153
seconds: 0.001159
seconds: 0.001085
seconds: 0.001154
seconds: 0.001155
seconds: 0.001176
seconds: 0.001154
seconds: 0.001154
seconds: 0.001155
seconds: 0.001154
seconds: 0.001161
seconds: 0.001154
seconds: 0.001157
seconds: 0.001158
seconds: 0.001621
seconds: 0.000885
seconds: 0.000903
seconds: 0.001149
seconds: 0.001154
seconds: 0.001156
seconds: 0.001157
seconds: 0.001148
seconds: 0.001153
seconds: 0.001264
seconds: 0.001051
seconds: 0.001163
seconds: 0.001160
seconds: 0.001154
seconds: 0.001162
seconds: 0.001159
seconds: 0.001146
seconds: 0.001164
seconds: 0.001508
seconds: 0.000862
seconds: 0.001035
seconds: 0.001155
seconds: 0.001159
seconds: 0.001156
seconds: 0.001161
seconds: 0.001152
seconds: 0.001468


Share this post


Link to post
Share on other sites
Can't see any tearing or uneven movement...
Maybe that's because the framerate (? <- number in the upper right corner) is >> 1000.

Share this post


Link to post
Share on other sites
Yeah seemed fine for me. Frame Rate (number in top right) was around 5k, if that helps.

Maybe post an image of the tearing.

Matt Hughson

Share this post


Link to post
Share on other sites
Out of curiousity, give us some info on how you are drawing your objects. Are you using VertexBuffers? If so, are they dynamic? Static? Are you locking them every frame? What's your lock call look like? Oh, and of course, are you using C++? Or maybe a managed language like C#. My first guess would be it has something to do with garbage collection, perhaps in combination with locking VBs, just cuz I had the same problem before.

--Vic--

Share this post


Link to post
Share on other sites
First of all, thank you for your interest. To show the problem more clearly, I've compiled a demo that sets D3DPRESENT_INTERVAL_ONE, and thus limits the framerate the to system's VSYNC rate (e.g. 60Hz on my system). At least on my laptop, the sprites even seem to jump back and forth. I'd be interested to hear how it runs on other systems. You can download it here... Try moving around the character with the arrow keys, you'll see what I mean.

I'm using DirectX 9.0c SDK, C++, and I'm using textured quads to render the 2D content. I am using one dynamic vertex buffer, and I lock the buffer each frame. The code snippet below shows the relevant bits.




// init phase:



// setup fullscreen parameters
//
m_pd3dppf = new D3DPRESENT_PARAMETERS;
ZeroMemory(m_pd3dppf, sizeof(D3DPRESENT_PARAMETERS));
m_pd3dppf->Windowed = false;
m_pd3dppf->SwapEffect = D3DSWAPEFFECT_DISCARD;
m_pd3dppf->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
m_pd3dppf->BackBufferWidth = nWidth;
m_pd3dppf->BackBufferHeight = nHeight;
m_pd3dppf->BackBufferCount = 1;
m_pd3dppf->BackBufferFormat = d3ddm.Format;

// create Direct3D device
//
hr = m_pd3d->CreateDevice(

D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
m_pd3dppf,
&m_pd3dd
);

// create the vertex buffer
//
hr = m_pd3dd->CreateVertexBuffer(

nPanelCnt * CPanel::VERTEX_COUNT * CPanel::VERTEX_SIZE,
D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC,
D3DFVF_XYZ | D3DFVF_TEX1,
D3DPOOL_DEFAULT,
&m_pVB,
NULL
);



// each frame:



// check if dynamic VB is full
//
int nFlags;

if (m_nVBOffset + nPanelCnt > m_nVBSize)
{
// lock new VB, discard old
//
nFlags = D3DLOCK_DISCARD;
m_nVBOffset = 0;
}
else
{
// lock unused part of VB
//
nFlags = D3DLOCK_NOOVERWRITE;
}

// lock VB
//
hr = m_pVB->Lock(

m_nVBOffset * CPanel::VERTEX_COUNT * CPanel::VERTEX_SIZE,
nPanelCnt * CPanel::VERTEX_COUNT * CPanel::VERTEX_SIZE,
(VOID **)ppVer,
nFlags
);

// draw VB
//
hr = m_pd3dd->DrawPrimitive(

D3DPT_TRIANGLELIST,
m_nVBOffset * CPanel::VERTEX_COUNT,
nPanelCnt * CPanel::PRIMITIVE_COUNT
);

// unlock VB
//
hr = m_pVB->Unlock();

// advance VB offset
//
m_nVBOffset += nPanelCnt;









[Edited by - space_cadet on May 15, 2005 6:44:52 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!