Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
platform.h
1 #ifndef PLATFORM_H
2 #define PLATFORM_H
3 
4 #include <cstdint>
5 #include <string>
6 #include "types.h"
7 
8 namespace smlt {
9 
10 struct Resolution {
11  uint16_t width;
12  uint16_t height;
13  uint16_t refresh_rate;
14 };
15 
16 const uint64_t MEMORY_VALUE_UNAVAILABLE = (uint64_t) -1;
17 
18 class Platform {
19 public:
20  virtual ~Platform() {}
21 
22  // Information
23  virtual std::string name() const = 0;
24  virtual Resolution native_resolution() const = 0;
25 
26  /* Return the total amount of RAM in the system */
27  virtual uint64_t total_ram_in_bytes() const = 0;
28 
29  /*
30  * Return the number of bytes of ram available.
31  * This may be an approximation. If it's not possible
32  * to retreive the info this function returns MEMORY_VALUE_UNAVAILABLE
33  */
34  virtual uint64_t available_ram_in_bytes() const = 0;
35 
36  /*
37  * Return the number of used ram in bytes. Returns -1
38  * if either total_ram_in_bytes or available_ram_in_bytes is
39  * unavailable
40  */
41  virtual uint64_t used_ram_in_bytes() const {
42  auto t = total_ram_in_bytes();
43  auto a = available_ram_in_bytes();
44  return t - a;
45  }
46 
47  /* An approximation of the amount of ram used by the specified process
48  * in bytes. MEMORY_VALUE_UNAVAILABLE will be returned if unsupported on the platform. For
49  * Dreamcast this will be the same as used_ram_in_bytes. */
50  virtual uint64_t process_ram_usage_in_bytes(ProcessID process_id) const = 0;
51 
52  /*
53  * Return the number of bytes of video ram available.
54  * This may be an approximation. If it's not possible
55  * to retrieve the info this function returns MEMORY_VALUE_UNAVAILABLE
56  */
57  virtual uint64_t available_vram_in_bytes() const = 0;
58 };
59 
60 /* Returns the current platform */
61 Platform* get_platform();
62 
63 }
64 
65 
66 #endif // PLATFORM_H
smlt
Definition: animation.cpp:25
smlt::Platform
Definition: platform.h:18
smlt::Resolution
Definition: platform.h:10