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

Summary: Better error reporting for WIN_GL_CreateContext()
Product: SDL Reporter: Mason Wheeler <masonwheeler>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2    
Version: HG 2.0   
Hardware: Other   
OS: Windows (All)   

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!