We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 906 - Better error reporting for WIN_GL_CreateContext()
Summary: Better error reporting for WIN_GL_CreateContext()
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: Other Windows (All)
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-14 19:15 UTC by Mason Wheeler
Modified: 2009-12-15 00:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mason Wheeler 2009-12-14 19:15:59 UTC
If context creation fails, it would be nice to know why.

--- C:\Users\Mason\AppData\Local\Temp\SDL_win32opengl.-revBASE.svn001.tmp.c	2009-12-14 19:11:16.000000000 -0800
+++ C:\Users\Mason\Documents\SDL-1.3\SDL-1.3.0-4423\src\video\win32\SDL_win32opengl.c	2009-09-05 10:31:30.000000000 -0800
@@ -533,13 +533,17 @@
             /* Delete the GL 2.x context */
             _this->gl_data->wglDeleteContext(temp_context);
         }
     }
 
     if (!context) {
-        SDL_SetError("Could not create GL context");
+		char* error = SDL_malloc(255);
+		FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, error, 255, NULL);
+		
+		SDL_SetError("Could not create GL context: %n", error);
+		SDL_free(error);
         return NULL;
     }
 
     if (WIN_GL_MakeCurrent(_this, window, context) < 0) {
         WIN_GL_DeleteContext(_this, context);
         return NULL;
Comment 1 Sam Lantinga 2009-12-15 00:12:17 UTC
There was already a function to do this, and I changed the code to use it.

Thanks!