@@ -239,8 +239,8 @@ sub togl_bind {
239239 if (defined $this -> {Impl }{indx_buf }) {
240240 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, $this -> {Impl }{indx_buf }); # unbind the VAO before you unbind the Index Buffer
241241 }
242- if (my ($program_key ) = grep /^program/, keys % { $this -> {Impl } }) {
243- glUseProgram($this -> { Impl }{ $program_key } );
242+ if (my ($program ) = grep defined , @ { $this -> {Impl } }{ qw( program program_nodestroy ) }) {
243+ glUseProgram($program );
244244 }
245245}
246246sub togl_unbind {
@@ -254,7 +254,7 @@ sub togl_unbind {
254254 glBindTexture(GL_TEXTURE_2D, 0);
255255 glDisable(GL_TEXTURE_2D);
256256 }
257- glUseProgram(0) if grep /^program/, keys % { $this -> {Impl } };
257+ glUseProgram(0) if grep defined , @ { $this -> {Impl } }{ qw( program program_nodestroy ) };
258258}
259259sub compile_shader {
260260 my ($this , $type , $src ) = @_ ;
@@ -416,11 +416,11 @@ sub togl_setup {
416416 @SPHERE {@KEYS } = gl_sphere(0.025, 15, 15);
417417 }
418418 @{ $this -> {Impl } }{@KEYS } = @SPHERE {@KEYS };
419+ $SHADER_PROGRAM //= $this -> compile_program($vertex_shader , $fragment_shader );
420+ $this -> {Impl }{program_nodestroy } = $SHADER_PROGRAM ;
419421 $this -> load_buffer(vert_buf => $this -> {Impl }{vertices });
420422 $this -> load_buffer(norm_buf => $this -> {Impl }{normals });
421423 $this -> load_idx_buffer(indx_buf => $this -> {Impl }{idx });
422- $SHADER_PROGRAM //= $this -> compile_program($vertex_shader , $fragment_shader );
423- $this -> {Impl }{program_nodestroy } = $SHADER_PROGRAM ;
424424 $this -> togl_unbind;
425425}
426426sub gdraw {
0 commit comments