C++ Win32 FPS and DeltaTime Implementation

I'm trying to implement FPS and DeltaTime for my program (C++ Win32). Below is the current code that I have. FPS and DeltaTime should have implemented int the right manner. If not, please tell me how I may fix my problem.

The current problem I am facing is how I should use DeltaTime. That is to Update and Render. And yes I did use a wrapper class. Before I implemented this, I was using WindowProcedure to handle my messages and I no problem with that. But now, trying to implement this is tilting me. So before I was using a back buffer and WM_PAINT to draw and i had to take in hwnd in order to draw. And updated is via input from WindowProcedure which had to take in arguments like LPARAM and WPARAM But after reading articles and forums on this topic. Update and Render is needed but they didnt have to take in hwnd for the Render Method. As for update they didnt have to take that in.

So basically i just want to know how do i write the Update and Render Method ?


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
34
35
36
37

bool BaseWindow::HandleMessages() {

    // Counts Per Second
    INT64 counts_per_sec = 0;
    QueryPerformanceFrequency( ( LARGE_INTEGER* ) &counts_per_sec );
    // Seconds Per Count
    float sec_per_count = 1.0f / ( float ) counts_per_sec;
    // Pervious Time
    INT64 prev_time = 0;
    QueryPerformanceCounter( ( LARGE_INTEGER* ) &prev_time );

    MSG message = { 0 };

    if ( PeekMessage( &message, NULL, 0, 0, PM_REMOVE )) {
        TranslateMessage( &message );
        DispatchMessage( &message );

        if ( message.message == WM_QUIT ) {
            OnDestroy();
            return false;
        }
    }
    else {
        // Get current count
        INT64 current_time = 0;
        QueryPerformanceCounter( ( LARGE_INTEGER* ) &current_time );
        // DeltaTime
        float delta_time = ( current_time - prev_time ) * sec_per_count;

        // Update

        // Render
    }
    return true;
}


If you find the method from above. From the below BaseWindow.cpp
I would i have commented out what i have problems with

http://pastebin.com/CaGrZ1en
Last edited on
Look I don't know what the problem is as I am only starting off but when I ran it it said undeclared use of baseWindow? I dont know I f this helps but this is the best I could do for you
Topic archived. No new replies allowed.