I have just finished implementing the graphical debug display of day 180 (it's really cool :D ) and I found a weird result.
This is the image:

Blue is game update and render
Pink is the wait to hit 33.3ms
Cyan is the draw command to the Window's window
In the stream, Casey hits the 33.3ms mark perfectly, and the draw part doesn't overshoot it like mine. My sleep works nicely, though.
Does anyone have any idea what might it be?
Or maybe I should just wait to worry about in when I implement the hardware render?
For reference this is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | win32_record_time_stamp(&frame_end_info, "Framerate Wait Completed", win32_get_seconds_elapse(last_counter, win32_get_wall_clock())); { auto device_context = GetDC(window); win32_draw_buffer_to_window(&win32_backbuffer, device_context, win32_get_window_dimention(window)); ReleaseDC(window, device_context); } flip_wall_clock = win32_get_wall_clock(); auto temp = old_game_input; old_game_input = game_input; game_input = temp; end_counter = win32_get_wall_clock(); win32_record_time_stamp(&frame_end_info, "End Of Frame", win32_get_seconds_elapse(last_counter, win32_get_wall_clock())); |
And this is win32_draw_buffer_to_window (at this point it is doing the 'false' if path):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | internal void win32_draw_buffer_to_window(Win32_Offscreen_Buffer *buffer, HDC device_context, Win32_Window_Dimention window_dimention) { if (window_dimention.width >= buffer->width*2 && window_dimention.height >= buffer->height*2) { StretchDIBits(device_context, 0, 0, 2*buffer->width, 2*buffer->height, 0, 0, buffer->width, buffer->height, buffer->memory, &buffer->info, DIB_RGB_COLORS, SRCCOPY); } else { #if 0 int offset_x = 10; int offset_y = 10; PatBlt(device_context, 0, 0, window_dimention.width, offset_y, BLACKNESS); PatBlt(device_context, 0, 0, offset_x, window_dimention.height, BLACKNESS); PatBlt(device_context, offset_x + buffer->width, 0, window_dimention.width, window_dimention.height, BLACKNESS); PatBlt(device_context, 0, offset_y + buffer->height, window_dimention.width, window_dimention.height, BLACKNESS); #else int offset_x = 0; int offset_y = 0; #endif StretchDIBits(device_context, offset_x, offset_y, buffer->width, buffer->height, 0, 0, buffer->width, buffer->height, buffer->memory, &buffer->info, DIB_RGB_COLORS, SRCCOPY); } } |
Thanks,
Dan Zaidan