X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcsynchronous.C;h=4c64b66f3cedfd18cac74997cb7f92d633c842fe;hb=ba9e9e32512994d5bccdd782bce844b2338992b7;hp=0bc4f104c3efb543381e7f79952895c6e0c3a55d;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/guicast/bcsynchronous.C b/cinelerra-5.1/guicast/bcsynchronous.C index 0bc4f104..4c64b66f 100644 --- a/cinelerra-5.1/guicast/bcsynchronous.C +++ b/cinelerra-5.1/guicast/bcsynchronous.C @@ -46,16 +46,21 @@ TextureID::TextureID(int window_id, int id, int w, int h, int components) in_use = 1; } -ShaderID::ShaderID(int window_id, unsigned int handle, char *source) +ShaderID::ShaderID(int window_id, unsigned int handle, + const char *vert, const char *frag) { this->window_id = window_id; this->handle = handle; - this->source = strdup(source); + if( !vert ) vert = ""; + if( !frag ) frag = ""; + this->vert = cstrdup(vert); + this->frag = cstrdup(frag); } ShaderID::~ShaderID() { - free(source); + delete [] vert; + delete [] frag; } #ifdef HAVE_GL @@ -240,37 +245,24 @@ void BC_Synchronous::handle_command(BC_SynchronousCommand *command) void BC_Synchronous::put_texture(int id, int w, int h, int components) { - if(id >= 0) - { + if( id >= 0 ) { table_lock->lock("BC_Resources::put_texture"); // Search for duplicate - for(int i = 0; i < texture_ids.total; i++) - { + for( int i = 0; i < texture_ids.total; i++ ) { TextureID *ptr = texture_ids.values[i]; - if(ptr->window_id == current_window->get_id() && - ptr->id == id) - { + if( ptr->window_id == current_window->get_id() && ptr->id == id ) { printf("BC_Synchronous::push_texture: texture exists\n" "exists: window=%d id=%d w=%d h=%d\n" "new: window=%d id=%d w=%d h=%d\n", - ptr->window_id, - ptr->id, - ptr->w, - ptr->h, - current_window->get_id(), - id, - w, - h); + ptr->window_id, ptr->id, ptr->w, ptr->h, + current_window->get_id(), id, w, h); table_lock->unlock(); return; } } TextureID *new_id = new TextureID(current_window->get_id(), - id, - w, - h, - components); + id, w, h, components); texture_ids.append(new_id); table_lock->unlock(); } @@ -317,30 +309,31 @@ void BC_Synchronous::release_texture(int window_id, int id) -unsigned int BC_Synchronous::get_shader(char *source, int *got_it) +int BC_Synchronous::get_shader(unsigned int *handle, + const char *vert, const char *frag) { + unsigned int shader = 0, ret = 0; + if( !vert ) vert = ""; + if( !frag ) frag = ""; table_lock->lock("BC_Resources::get_shader"); - for(int i = 0; i < shader_ids.total; i++) - { - if(shader_ids.values[i]->window_id == current_window->get_id() && - !strcmp(shader_ids.values[i]->source, source)) - { - unsigned int result = shader_ids.values[i]->handle; - table_lock->unlock(); - *got_it = 1; - return result; + for( int i=0; !ret && iget_id() && + !strcmp(sp.vert, vert) && !strcmp(sp.frag, frag) ) { + shader = shader_ids.values[i]->handle; + ret = 1; } } table_lock->unlock(); - *got_it = 0; - return 0; + *handle = shader; + return ret; } void BC_Synchronous::put_shader(unsigned int handle, - char *source) + const char *vert, const char *frag) { table_lock->lock("BC_Resources::put_shader"); - shader_ids.append(new ShaderID(current_window->get_id(), handle, source)); + shader_ids.append(new ShaderID(current_window->get_id(), handle, vert, frag)); table_lock->unlock(); } @@ -348,18 +341,18 @@ void BC_Synchronous::dump_shader(unsigned int handle) { int got_it = 0; table_lock->lock("BC_Resources::dump_shader"); - for(int i = 0; i < shader_ids.total; i++) - { - if(shader_ids.values[i]->handle == handle) - { + for( int i=0; ihandle == handle ) { printf("BC_Synchronous::dump_shader\n" - "%s", shader_ids.values[i]->source); + "vert: %s\nfrag: %s\n", + shader_ids[i]->vert, shader_ids[i]->frag); got_it = 1; break; } } table_lock->unlock(); - if(!got_it) printf("BC_Synchronous::dump_shader couldn't find %d\n", handle); + if( !got_it ) + printf("BC_Synchronous::dump_shader couldn't find %d\n", handle); } void BC_Synchronous::delete_window(BC_WindowBase *window) @@ -564,9 +557,3 @@ BC_WindowBase* BC_Synchronous::get_window() return current_window; } - - - - - -