Skip to content

Commit dfbcd65

Browse files
authored
Merge pull request #6088 from fluffyfreak/minor-OS-and-OGL-tweaks
Detect Windows 11, update GL Renderer name
2 parents e463192 + d48f135 commit dfbcd65

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

src/graphics/opengl/RendererGL.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ namespace Graphics {
309309
SDL_GL_DeleteContext(m_glContext);
310310
}
311311

312+
const char *RendererOGL::GetName() const
313+
{
314+
// since 15/10/2020 we've been requiring OpenGL 3.2
315+
return "OpenGL 3.2, with extensions, renderer";
316+
}
317+
312318
static const char *gl_error_to_string(GLenum err)
313319
{
314320
switch (err) {
@@ -385,6 +391,12 @@ namespace Graphics {
385391
out << ", running on " << glGetString(GL_VENDOR);
386392
out << " " << glGetString(GL_RENDERER) << "\n";
387393

394+
// Log this information to output as well to aid error reporting
395+
Output("OpenGL version %s, running on %s %s",
396+
(const char *)glGetString(GL_VERSION),
397+
(const char *)glGetString(GL_VENDOR),
398+
(const char *)glGetString(GL_RENDERER));
399+
388400
out << "Available extensions:"
389401
<< "\n";
390402
if (glewIsSupported("GL_VERSION_3_1")) {

src/graphics/opengl/RendererGL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace Graphics {
4343
RendererOGL(SDL_Window *window, const Graphics::Settings &vs, SDL_GLContext &glContext);
4444
~RendererOGL() final;
4545

46-
const char *GetName() const final { return "OpenGL 3.1, with extensions, renderer"; }
46+
const char *GetName() const final;
4747
RendererType GetRendererType() const final { return RENDERER_OPENGL_3x; }
4848

4949
void WriteRendererInfo(std::ostream &out) const final;

src/win32/OSWin32.cpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@ namespace OS {
5151
struct OSVersion {
5252
DWORD major;
5353
DWORD minor;
54+
DWORD build;
5455
const char *name;
5556
};
5657
static const struct OSVersion osVersions[] = {
57-
{ 10, 0, "Windows 10" },
58-
{ 6, 3, "Windows 8.1" },
59-
{ 6, 2, "Windows 8" },
60-
{ 6, 1, "Windows 7" },
61-
{ 6, 0, "Windows Vista" },
62-
{ 5, 1, "Windows XP" },
63-
{ 5, 0, "Windows 2000" },
64-
{ 0, 0, nullptr }
58+
{ 10, 0, 22000, "Windows 11" }, // fuck microsoft, major minor are the same as Windows 10, but builds from 22000 are Win11
59+
{ 10, 0, 0, "Windows 10" },
60+
{ 6, 3, 0, "Windows 8.1" },
61+
{ 6, 2, 0, "Windows 8" },
62+
{ 6, 1, 0, "Windows 7" },
63+
{ 6, 0, 0, "Windows Vista" },
64+
{ 5, 1, 0, "Windows XP" },
65+
{ 5, 0, 0, "Windows 2000" },
66+
{ 0, 0, 0, nullptr }
6567
};
6668
} // namespace
6769

@@ -198,7 +200,9 @@ namespace OS {
198200
OSVERSIONINFOEX os;
199201
if (GetVersionHackNTDLL(&os) == TRUE) {
200202
for (const OSVersion *scan = osVersions; scan->name; scan++) {
201-
if (os.dwMajorVersion >= scan->major && os.dwMinorVersion >= scan->minor) {
203+
if (os.dwMajorVersion >= scan->major &&
204+
os.dwMinorVersion >= scan->minor &&
205+
os.dwBuildNumber >= scan->build) {
202206
name = scan->name;
203207
break;
204208
}
@@ -213,7 +217,9 @@ namespace OS {
213217
GetVersionExA(&osa);
214218

215219
for (const OSVersion *scan = osVersions; scan->name; scan++) {
216-
if (osa.dwMajorVersion >= scan->major && osa.dwMinorVersion >= scan->minor) {
220+
if (osa.dwMajorVersion >= scan->major &&
221+
osa.dwMinorVersion >= scan->minor &&
222+
osa.dwBuildNumber >= scan->build) {
217223
name = scan->name;
218224
break;
219225
}

0 commit comments

Comments
 (0)