MSG::time is later than timeGetTime

Adam Naylor
  • MSG::time is later than timeGetTime Adam Naylor

    After noticing some timing descrepencies with events in my code, I boiled the problem all the way down to my Windows Message Loop.

    Basically, unless I'm doing something strange, I'm experiencing this behaviour:-

    MSG message;
    while (PeekMessage(&message, _applicationWindow.Handle, 0, 0, PM_REMOVE))
        int timestamp = timeGetTime();
        bool strange = message.time > timestamp; //strange == true!!!

    The only rational conclusion I can draw is that MSG::time uses a different timing mechanism then timeGetTime() and therefore is free to produce differing results. Is this the case or am i missing something fundamental?

  • I can see two reasons: Either they use different ways of measuring time (as you suggest), or, you have a AMD chip. These can in some cases have timing bugs that you need to either patch through a driver (I think) or handle in your application logic. Google for "AMD timing" and you will probably find something that might be of use.

  • Yes, it does use a different source. If you look at the Windows documentation you will see that you should use GetTickCount/GetTickCount64 to compare against the message time.

    If you need any kind of precision, I suggest not relying on the message time - GetTickCount has horrible resolution. (10-16ms)

c++ windows
Related questions and answers
  • but when I press the X button on the PSP I see no bullet being drawn or updated on the screen. I know the problem doesn't lie with the pad because I press start and it exits my game so I do not think it is the pad that is causing the problem. Maybe the bullet is being drawn out of the screen already. But I am not sure since I cannot debug maybe somebody can see the flaw in my code. main.cpp class... = set_gfx_mode(GFX_AUTODETECT,480,272,0,0); if (ret != 0) { allegro_message("Error setting grahpic mode! Because of it returned: %i", ret); return ret; } background

  • I'm rendering to a depth map in order to use it as a shader resource view, but when I sample the depth map in my shader, the red component has a value of 1 while all other channels have a value of 0... errors from D3D, and no compile time warning or anything. I'm not sure what I'm missing here at all. I have the impression the depth value is always being set to 1. I have not set any depth/stencil..., and the ShaderResourceView's format is D3D11_SRV_DIMENSION_TEXTURE2D. I'm setting the depth map render target, then i'm drawing my scene, and once that is done, I'm the back buffer render target and depth

  • ); glBindFramebuffer(GL_FRAMEBUFFER, 0); } Here is my drawing box code, which just takes a transformation matrix and calls the appropriate functions. The current values of P is a projection matrix... wrong in my frame buffer set up code, or elsewhere. But I can't see what. The FBO is set up through the following function: unsigned int fbo_id; unsigned int depth_buffer; int m_FBOWidth, m_FBOHeight...I'm having trouble implementing render to texture with OpenGL 3. My issue is that after rendering to the frame buffer, it appears the rendered object becomes deformed, which may imply a bad

  • "DirectXTemplate"; wcex.hIconSm = 0; RegisterClassEx(&wcex); wndHandle = CreateWindow(L"DirectXTemplate", L"DirectX Template", WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE, CW... WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; default..., Info.Format, D3DPOOL_SYSTEMMEM, &Surface, NULL); D3DXLoadSurfaceFromFile(Surface, NULL, NULL, wsPath.c_str(), NULL, D3DX_FILTER_NONE, 0, NULL); pd3dDevice -> GetBackBuffer(0, 0

  • ); m_pD3DDevice->RSSetState(m_pRSState); //...more code } WndProc: switch( message ) { case WM_SIZE: { m_pD3DDevice->RSSetState(m_pRSState); break; } } ...I am trying to create a ID3D10RasterizerState with direct3D10, and then call ID3D10Device::RSSetState() with the proper information. However, whenever the window get rescaled, or when the app goes fullscreen, the rasterizerstate seems to reset to the default state. I have tried to set the state with WM_SIZE messages, but awkwardly, nothing seems to happen... It works properly when I call

  • () { bgX = 0; bgY = 0; bg2X = 0; bg2Y = 0; width = 2048; height = 480; loaded = false; time = 0; } Level::~Level() { } //virtual functions are empty... I'm not sure exactly what I'm... code in them... Right now for testing purposes, I just have the main loop call Level1 level1; and use the functions, but when I run the game I get a segmentation fault. This is the first time I've tried writing inherited classes, so I know I'm doing something wrong, but I can't seem to figure out what exactly.

  • .... Maybe I'm doing something extra here? I managed to implement a std::vector collection like recommended: for(int i = 0; i < numTriangles; i++) { MD2Triangle* triangle = triangles + i... at the same time: glBegin(GL_TRIANGLES); for(int i = 0; i < numTriangles; i++) { MD2Triangle* triangle = triangles + i; for(int j = 0; j < 3; j++) { MD2Vertex* v1...; Vec3f normal = v1->normal * (1 - frac) + v2->normal * frac; if (normal[0] == 0 &amp;&amp; normal[1] == 0 &amp;&amp; normal[2] == 0) { normal = Vec3f(0, 0, 1

  • I'm writing a simple class to draw all the debugging lines I have in my scene at once. The code in the draw loop is this so far: (If I put for example, 2 instead of temporary2DVerts.size() where I have marked with //THIS LINE, the code works fine.) when I run the code below the line breaks //HERE. Access violation reading location 0x00000000. seems like the create buffer line is not working...; bd.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; bd.MiscFlags = 0; device->CreateBuffer(&amp;bd, NULL, &amp;pBuffer); void* pVoid; pBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &amp;pVoid); //HERE memcpy(pVoid

  • I'm currently working on my first space shooter, and I'm in the process of making my ship shoot some bullets/lasers. Unfortunately, I'm having a hard time getting the bullets to fly vertically. I'm a total noob when it comes to this so you might have a hard time understanding my code :/ // Position Bullet Function projectilex = x + 17; projectiley = y + -20; if(keystates[SDLK...,projectiley,ShootStuff,screen,&amp;lazers[frame]); frame++; projectiley + 1; } I'm trying to get the bullet to fly vertically... and I have no clue how to do that. I've tried messing

Data information