35 static void asc_gl_debug_callback( |
35 static void asc_gl_debug_callback( |
36 GLenum source, GLenum type, GLuint id, GLenum severity, |
36 GLenum source, GLenum type, GLuint id, GLenum severity, |
37 GLsizei length, const GLchar* message, |
37 GLsizei length, const GLchar* message, |
38 const void* userParam |
38 const void* userParam |
39 ) { |
39 ) { |
40 cxmutstr buf = cx_asprintf( |
40 if (type == GL_DEBUG_TYPE_ERROR) { |
41 "source = %d, id = %u, type = %d, severity= %d, message = %.*s", |
41 asc_error("OpenGL source = %d, id = %u, type = %d, severity= %d, message = %.*s", |
42 source, id, type, severity, length, message); |
42 source, id, type, severity, length, message); |
43 if (type == GL_DEBUG_TYPE_ERROR) { |
|
44 asc_error(buf.ptr); |
|
45 } else { |
43 } else { |
46 asc_dprintf("GL debug: %.*s", (int)buf.length, buf.ptr); |
44 asc_dprintf("OpenGL source = %d, id = %u, type = %d, severity= %d, message = %.*s", |
|
45 source, id, type, severity, length, message); |
47 } |
46 } |
48 cx_strfree(&buf); |
|
49 } |
47 } |
50 |
48 |
51 static int asc_primitives_init(AscGLContext *context) { |
49 static int asc_primitives_init(AscGLContext *context) { |
52 asc_dprintf("Create primitives for the GL context of active window."); |
50 asc_dprintf("Create primitives for the GL context of active window."); |
53 asc_mesh_allocate_buffers(context->primitives, ASC_PRIMITIVE_COUNT); |
51 asc_mesh_allocate_buffers(context->primitives, ASC_PRIMITIVE_COUNT); |
81 // Create a 1x1 surface with 32-bit RGBA format |
79 // Create a 1x1 surface with 32-bit RGBA format |
82 SDL_Surface* white1x1 = SDL_CreateRGBSurface( |
80 SDL_Surface* white1x1 = SDL_CreateRGBSurface( |
83 0, 1, 1, 32, |
81 0, 1, 1, 32, |
84 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); |
82 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); |
85 if (white1x1 == NULL) { |
83 if (white1x1 == NULL) { |
86 // TODO: merge error messages once asc_error allows formatting |
84 asc_error("Failed to create surface: %s", SDL_GetError()); |
87 asc_error("Failed to create surface"); |
|
88 asc_error(SDL_GetError()); |
|
89 return 1; |
85 return 1; |
90 } |
86 } |
91 SDL_FillRect(white1x1, NULL, 0xFFFFFFFF); |
87 SDL_FillRect(white1x1, NULL, 0xFFFFFFFF); |
92 |
88 |
93 // Initialize the empty textures with the white surface |
89 // Initialize the empty textures with the white surface |