diff options
author | David Reveman <davidr@novell.com> | 2004-09-20 04:59:34 +0000 |
---|---|---|
committer | David Reveman <davidr@novell.com> | 2004-09-20 04:59:34 +0000 |
commit | 05bb9825487f03d50877fa60d96847c5605174ec (patch) | |
tree | e7e1043bd904cf4d3b5cbc7e027095f084311ab6 /src/glitz_agl_context.c | |
parent | 73540d4888c46c0b04dab9420741ecf03f050478 (diff) |
Improvements to AGL backend and better checking of successful fragment program loading
Diffstat (limited to 'src/glitz_agl_context.c')
-rw-r--r-- | src/glitz_agl_context.c | 140 |
1 files changed, 139 insertions, 1 deletions
diff --git a/src/glitz_agl_context.c b/src/glitz_agl_context.c index 3b57a4d..ae19b30 100644 --- a/src/glitz_agl_context.c +++ b/src/glitz_agl_context.c @@ -85,7 +85,7 @@ glitz_agl_context_get (glitz_agl_thread_info_t *thread_info, context->backend.program_map = &thread_info->program_map; context->backend.feature_mask = thread_info->feature_mask; - context->backend.gl.need_lookup = 0; + context->backend.gl.need_lookup = 1; return context; } @@ -98,6 +98,140 @@ glitz_agl_context_destroy (glitz_agl_thread_info_t *thread_info, free (context); } +/* These function addresses are never context specific but we retrive them + for each context anyway. */ +void +glitz_agl_context_proc_address_lookup (glitz_agl_thread_info_t *thread_info, + glitz_agl_context_t *context) +{ + CFBundleRef bundle; + + bundle = glitz_agl_get_bundle ("OpenGL.framework"); + + if (thread_info->gl_version >= 1.3) { + context->backend.gl.active_texture = + (glitz_gl_active_texture_t) + glitz_agl_get_proc_address (bundle, "glActiveTexture"); + } else { + context->backend.gl.active_texture = + (glitz_gl_active_texture_t) + glitz_agl_get_proc_address (bundle, "glActiveTextureARB"); + } + + context->backend.gl.gen_programs = + (glitz_gl_gen_programs_t) + glitz_agl_get_proc_address (bundle, "glGenProgramsARB"); + context->backend.gl.delete_programs = + (glitz_gl_delete_programs_t) + glitz_agl_get_proc_address (bundle, "glDeleteProgramsARB"); + context->backend.gl.program_string = + (glitz_gl_program_string_t) + glitz_agl_get_proc_address (bundle, "glProgramStringARB"); + context->backend.gl.bind_program = + (glitz_gl_bind_program_t) + glitz_agl_get_proc_address (bundle, "glBindProgramARB"); + context->backend.gl.program_local_param_4fv = + (glitz_gl_program_local_param_4fv_t) + glitz_agl_get_proc_address (bundle, "glProgramLocalParameter4fvARB"); + context->backend.gl.get_program_iv = + (glitz_gl_get_program_iv_t) + glitz_agl_get_proc_address (bundle, "glGetProgramivARB"); + + if (thread_info->gl_version >= 1.5) { + context->backend.gl.gen_buffers = + (glitz_gl_gen_buffers_t) + glitz_agl_get_proc_address (bundle, "glGenBuffers"); + context->backend.gl.delete_buffers = + (glitz_gl_delete_buffers_t) + glitz_agl_get_proc_address (bundle, "glDeleteBuffers"); + context->backend.gl.bind_buffer = + (glitz_gl_bind_buffer_t) + glitz_agl_get_proc_address (bundle, "glBindBuffer"); + context->backend.gl.buffer_data = + (glitz_gl_buffer_data_t) + glitz_agl_get_proc_address (bundle, "glBufferData"); + context->backend.gl.buffer_sub_data = + (glitz_gl_buffer_sub_data_t) + glitz_agl_get_proc_address (bundle, "glBufferSubData"); + context->backend.gl.get_buffer_sub_data = + (glitz_gl_get_buffer_sub_data_t) + glitz_agl_get_proc_address (bundle, "glGetBufferSubData"); + context->backend.gl.map_buffer = + (glitz_gl_map_buffer_t) + glitz_agl_get_proc_address (bundle, "glMapBuffer"); + context->backend.gl.unmap_buffer = + (glitz_gl_unmap_buffer_t) + glitz_agl_get_proc_address (bundle, "glUnmapBuffer"); + } else { + context->backend.gl.gen_buffers = + (glitz_gl_gen_buffers_t) + glitz_agl_get_proc_address (bundle, "glGenBuffersARB"); + context->backend.gl.delete_buffers = + (glitz_gl_delete_buffers_t) + glitz_agl_get_proc_address (bundle, "glDeleteBuffersARB"); + context->backend.gl.bind_buffer = + (glitz_gl_bind_buffer_t) + glitz_agl_get_proc_address (bundle, "glBindBufferARB"); + context->backend.gl.buffer_data = + (glitz_gl_buffer_data_t) + glitz_agl_get_proc_address (bundle, "glBufferDataARB"); + context->backend.gl.buffer_sub_data = + (glitz_gl_buffer_sub_data_t) + glitz_agl_get_proc_address (bundle, "glBufferSubDataARB"); + context->backend.gl.get_buffer_sub_data = + (glitz_gl_get_buffer_sub_data_t) + glitz_agl_get_proc_address (bundle, "glGetBufferSubDataARB"); + context->backend.gl.map_buffer = + (glitz_gl_map_buffer_t) + glitz_agl_get_proc_address (bundle, "glMapBufferARB"); + context->backend.gl.unmap_buffer = + (glitz_gl_unmap_buffer_t) + glitz_agl_get_proc_address (bundle, "glUnmapBufferARB"); + } + + glitz_agl_release_bundle (bundle); + + context->backend.feature_mask &= ~GLITZ_FEATURE_MULTITEXTURE_MASK; + context->backend.feature_mask &= ~GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK; + context->backend.feature_mask &= ~GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK; + context->backend.feature_mask &= ~GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK; + context->backend.feature_mask &= ~GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK; + + if (context->backend.gl.active_texture) { + context->backend.feature_mask |= GLITZ_FEATURE_MULTITEXTURE_MASK; + + if (thread_info->feature_mask & GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK) + context->backend.feature_mask |= + GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK; + + if (context->backend.gl.gen_programs && + context->backend.gl.delete_programs && + context->backend.gl.program_string && + context->backend.gl.bind_program && + context->backend.gl.program_local_param_4fv) { + if (thread_info->feature_mask & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK) + context->backend.feature_mask |= GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK; + } + } + + if (context->backend.gl.gen_buffers && + context->backend.gl.delete_buffers && + context->backend.gl.bind_buffer && + context->backend.gl.buffer_data && + context->backend.gl.buffer_sub_data && + context->backend.gl.get_buffer_sub_data && + context->backend.gl.map_buffer && + context->backend.gl.unmap_buffer) { + if (thread_info->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK) + context->backend.feature_mask |= GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK; + + if (thread_info->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK) + context->backend.feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK; + } + + context->backend.gl.need_lookup = 0; +} + void glitz_agl_context_make_current (glitz_agl_surface_t *surface, glitz_bool_t flush) @@ -124,6 +258,10 @@ glitz_agl_context_make_current (glitz_agl_surface_t *surface, aglSetDrawable (context, drawable); aglSetCurrentContext (context); + + if (surface->context->backend.gl.need_lookup) + glitz_agl_context_proc_address_lookup (surface->thread_info, + surface->context); } static void |