I'm curious which train you're taking from Bergen, because the direct trains from Bergen to Oslo arrive at Oslo S at about 06:25, 14:45, or later. If you're on the overnight train, I suggest leaving your bags in the bag lockers in Oslo S and spending most of the day in central Oslo. If you're on the train arriving Oslo S at 14:45, then by the time you have used Flytoget and arrived at Gardermoen, you'll be well within the normal checkin time for the 16:45 departure.
But anyway, if you really do have several hours at Gardermoen for this, you might make it to the checkin desks before the earlier flight closes and then you could check in while the desks are open. You could also still use the lockers in Oslo S and spend some more time around the center before going to the airport. The center of Oslo is generally more interesting than the airport (or anything nearby the airport).