opengl: more error handling
Show message box on fail. Enable debug output only when logfile is defined; performance optimization. Fail if reported opengl version is less than 3.0 or errors are generated after context is created; fixes some crashes on unsupported hardware or faulty drivers.
This commit is contained in:
@@ -125,6 +125,8 @@
|
||||
#define IDS_2149 2149 // "Cassette images (*.PCM;*.RAW;*..."
|
||||
#define IDS_2150 2150 // "Cartridge %i: %ls"
|
||||
#define IDS_2151 2151 // "Cartridge images (*.JRC)\0*.JRC\0..."
|
||||
#define IDS_2152 2152 // "Error initializing OpenGL 3.0 renderer"
|
||||
#define IDS_2153 2153 // "OpenGL (3.0 Core) renderer could not be initialized."
|
||||
|
||||
#define IDS_4096 4096 // "Hard disk (%s)"
|
||||
#define IDS_4097 4097 // "%01i:%01i"
|
||||
@@ -233,7 +235,7 @@
|
||||
|
||||
#define IDS_LANG_ENUS IDS_7168
|
||||
|
||||
#define STR_NUM_2048 104
|
||||
#define STR_NUM_2048 106
|
||||
#define STR_NUM_3072 11
|
||||
#define STR_NUM_4096 40
|
||||
#define STR_NUM_4352 6
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Kazetové nahrávky (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Všechny soubory (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartridge %i: %ls"
|
||||
IDS_2151 "Obrazy cartridge (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Všechny soubory (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Kassettenimages (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Alle Dateien (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartridge %i: %ls"
|
||||
IDS_2151 "Cartridgeimages (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Alle Dateien (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Cassette images (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0All files (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartridge %i: %ls"
|
||||
IDS_2151 "Cartridge images (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0All files (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Cassette images (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0All files (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartridge %i: %ls"
|
||||
IDS_2151 "Cartridge images (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0All files (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Imágenes de Cassette (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0All files (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartucho %i: %ls"
|
||||
IDS_2151 "Imágenes de Cartucho (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0All files (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Kasetti-tiedostot (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Kaikki tiedostot (*.*)\0*.*\0"
|
||||
IDS_2150 "ROM-moduuli %i: %ls"
|
||||
IDS_2151 "ROM-moduulikuvat (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Kaikki tiedostot (*.*)\0*.*\0"
|
||||
IDS_2152 "Virhe renderöijän alustuksessa"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderöijän alustus epäonnistui. Käytä toista renderöijää."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Images cassette (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Tous les fichiers (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartouche %i: %ls"
|
||||
IDS_2151 "Images cartouche (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Tous les fichiers (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Slike audio kasete (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Sve datoteke (*.*)\0*.*\0"
|
||||
IDS_2150 "Kaseta %i: %ls"
|
||||
IDS_2151 "Slike kasete (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Sve datoteke (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -532,6 +532,8 @@ BEGIN
|
||||
IDS_2149 "Magnókazetta-képek (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Minden fájl (*.*)\0*.*\0"
|
||||
IDS_2150 "ROM-kazetta %i: %ls"
|
||||
IDS_2151 "ROM-kazetta képek (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Minden fájl (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Immagini cassetta (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Tutti i file (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartuccia %i: %ls"
|
||||
IDS_2151 "Immagini cartuccia (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Tutti i file (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "カセットイメージ (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0すべてのファイル (*.*)\0*.*\0"
|
||||
IDS_2150 "カートリッジ %i: %ls"
|
||||
IDS_2151 "カートリッジイメージ (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0すべてのファイル (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "카세트 이미지 (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0모든 파일 (*.*)\0*.*\0"
|
||||
IDS_2150 "카트리지 %i: %ls"
|
||||
IDS_2151 "카트리지 이미지 (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0모든 파일 (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -531,6 +531,8 @@ BEGIN
|
||||
IDS_2149 "Imagens de cassete (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Todos os arquivos (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartucho %i: %ls"
|
||||
IDS_2151 "Imagens de cartucho (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Todos os arquivos (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Imagens de cassete (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Todos os ficheiros (*.*)\0*.*\0"
|
||||
IDS_2150 "Cartucho %i: %ls"
|
||||
IDS_2151 "Imagens de cartucho (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Todos os ficheiros (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Образы кассет (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Все файлы (*.*)\0*.*\0"
|
||||
IDS_2150 "Картридж %i: %ls"
|
||||
IDS_2151 "Образы картриджей (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Все файлы (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Slike kaset (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Vse datoteke (*.*)\0*.*\0"
|
||||
IDS_2150 "Spominski vložek %i: %ls"
|
||||
IDS_2151 "Slike spominskega vložka (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Vse datoteke (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "Kaset imajları (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Tüm dosyalar (*.*)\0*.*\0"
|
||||
IDS_2150 "Kartuş %i: %ls"
|
||||
IDS_2151 "Kartuş imajları (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Tüm dosyalar (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -530,6 +530,8 @@ BEGIN
|
||||
IDS_2149 "磁带镜像 (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0所有文件 (*.*)\0*.*\0"
|
||||
IDS_2150 "卡带 %i: %ls"
|
||||
IDS_2151 "卡带镜像 (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0所有文件 (*.*)\0*.*\0"
|
||||
IDS_2152 "Error initializing renderer"
|
||||
IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@@ -56,6 +56,7 @@ typedef LONG atomic_flag;
|
||||
#include <86box/plat.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/win.h>
|
||||
#include <86box/language.h>
|
||||
#include <86box/win_opengl.h>
|
||||
#include <86box/win_opengl_glslp.h>
|
||||
|
||||
@@ -445,7 +446,9 @@ static void opengl_fail()
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
/* TODO: Notify user. */
|
||||
wchar_t* message = plat_get_string(IDS_2152);
|
||||
wchar_t* header = plat_get_string(IDS_2153);
|
||||
MessageBox(parent, header, message, MB_OK);
|
||||
|
||||
WaitForSingleObject(sync_objects.closing, INFINITE);
|
||||
|
||||
@@ -476,7 +479,7 @@ static void opengl_main(void* param)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
|
||||
if (GLAD_GL_ARB_debug_output)
|
||||
if (GLAD_GL_ARB_debug_output && log_path[0] != '\0')
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
|
||||
else
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
|
||||
@@ -527,7 +530,7 @@ static void opengl_main(void* param)
|
||||
opengl_fail();
|
||||
}
|
||||
|
||||
if (GLAD_GL_ARB_debug_output)
|
||||
if (GLAD_GL_ARB_debug_output && log_path[0] != '\0')
|
||||
{
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
glDebugMessageControlARB(GL_DONT_CARE, GL_DEBUG_TYPE_PERFORMANCE_ARB, GL_DONT_CARE, 0, 0, GL_FALSE);
|
||||
@@ -539,6 +542,33 @@ static void opengl_main(void* param)
|
||||
pclog("OpenGL version: %s\n", glGetString(GL_VERSION));
|
||||
pclog("OpenGL shader language version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
|
||||
/* Check that the driver actually reports version 3.0 or later */
|
||||
GLint major = -1;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
if (major < 3)
|
||||
{
|
||||
pclog("OpenGL: Minimum OpenGL version 3.0 is required.\n");
|
||||
SDL_GL_DeleteContext(context);
|
||||
opengl_fail();
|
||||
}
|
||||
|
||||
/* Check if errors have been generated at this point */
|
||||
GLenum gl_error = glGetError();
|
||||
if (gl_error != GL_NO_ERROR)
|
||||
{
|
||||
/* Log up to 10 errors */
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
pclog("OpenGL: Error %u\n", gl_error);
|
||||
i++;
|
||||
}
|
||||
while((gl_error = glGetError()) != GL_NO_ERROR && i < 10);
|
||||
|
||||
SDL_GL_DeleteContext(context);
|
||||
opengl_fail();
|
||||
}
|
||||
|
||||
gl_identifiers gl = { 0 };
|
||||
|
||||
if (!initialize_glcontext(&gl))
|
||||
|
Reference in New Issue
Block a user