igor ru.po
[goodguy/history.git] / cinelerra-5.1 / plugins / chromakey / chromakey.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "bcdisplayinfo.h"
23 #include "bcsignals.h"
24 #include "chromakey.h"
25 #include "clip.h"
26 #include "bchash.h"
27 #include "filexml.h"
28 #include "guicast.h"
29 #include "keyframe.h"
30 #include "language.h"
31 #include "loadbalance.h"
32 #include "playback3d.h"
33 #include "cicolors.h"
34 #include "pluginvclient.h"
35 #include "vframe.h"
36
37 #include <stdint.h>
38 #include <string.h>
39
40
41
42
43
44 ChromaKeyConfig::ChromaKeyConfig()
45 {
46         red = 0.0;
47         green = 0.0;
48         blue = 0.0;
49         threshold = 60.0;
50         use_value = 0;
51         slope = 100;
52 }
53
54
55 void ChromaKeyConfig::copy_from(ChromaKeyConfig &src)
56 {
57         red = src.red;
58         green = src.green;
59         blue = src.blue;
60         threshold = src.threshold;
61         use_value = src.use_value;
62         slope = src.slope;
63 }
64
65 int ChromaKeyConfig::equivalent(ChromaKeyConfig &src)
66 {
67         return (EQUIV(red, src.red) &&
68                 EQUIV(green, src.green) &&
69                 EQUIV(blue, src.blue) &&
70                 EQUIV(threshold, src.threshold) &&
71                 EQUIV(slope, src.slope) &&
72                 use_value == src.use_value);
73 }
74
75 void ChromaKeyConfig::interpolate(ChromaKeyConfig &prev,
76         ChromaKeyConfig &next,
77         int64_t prev_frame,
78         int64_t next_frame,
79         int64_t current_frame)
80 {
81         double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
82         double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame);
83
84         this->red = prev.red * prev_scale + next.red * next_scale;
85         this->green = prev.green * prev_scale + next.green * next_scale;
86         this->blue = prev.blue * prev_scale + next.blue * next_scale;
87         this->threshold = prev.threshold * prev_scale + next.threshold * next_scale;
88         this->slope = prev.slope * prev_scale + next.slope * next_scale;
89         this->use_value = prev.use_value;
90 }
91
92 int ChromaKeyConfig::get_color()
93 {
94         int red = (int)(CLIP(this->red, 0, 1) * 0xff);
95         int green = (int)(CLIP(this->green, 0, 1) * 0xff);
96         int blue = (int)(CLIP(this->blue, 0, 1) * 0xff);
97         return (red << 16) | (green << 8) | blue;
98 }
99
100
101
102
103
104
105
106 ChromaKeyWindow::ChromaKeyWindow(ChromaKey *plugin)
107  : PluginClientWindow(plugin,
108         320,
109         220,
110         320,
111         220,
112         0)
113 {
114         this->plugin = plugin;
115         color_thread = 0;
116 }
117
118 ChromaKeyWindow::~ChromaKeyWindow()
119 {
120         delete color_thread;
121 }
122
123 void ChromaKeyWindow::create_objects()
124 {
125         int x = 10, y = 10, x1 = 100;
126
127         BC_Title *title;
128         add_subwindow(title = new BC_Title(x, y, _("Color:")));
129         x += title->get_w() + 10;
130         add_subwindow(color = new ChromaKeyColor(plugin, this, x, y));
131         x += color->get_w() + 10;
132         add_subwindow(sample = new BC_SubWindow(x, y, 100, 50));
133         y += sample->get_h() + 10;
134         x = 10;
135
136         add_subwindow(new BC_Title(x, y, _("Slope:")));
137         add_subwindow(slope = new ChromaKeySlope(plugin, x1, y));
138
139         y += 30;
140         add_subwindow(new BC_Title(x, y, _("Threshold:")));
141         add_subwindow(threshold = new ChromaKeyThreshold(plugin, x1, y));
142
143
144         y += 30;
145         add_subwindow(use_value = new ChromaKeyUseValue(plugin, x1, y));
146
147         y += 30;
148         add_subwindow(use_colorpicker = new ChromaKeyUseColorPicker(plugin, this, x1, y));
149
150         color_thread = new ChromaKeyColorThread(plugin, this);
151
152         update_sample();
153         show_window();
154         flush();
155 }
156
157 void ChromaKeyWindow::update_sample()
158 {
159         sample->set_color(plugin->config.get_color());
160         sample->draw_box(0,
161                 0,
162                 sample->get_w(),
163                 sample->get_h());
164         sample->set_color(BLACK);
165         sample->draw_rectangle(0,
166                 0,
167                 sample->get_w(),
168                 sample->get_h());
169         sample->flash();
170 }
171
172
173
174
175
176
177
178
179
180 ChromaKeyColor::ChromaKeyColor(ChromaKey *plugin,
181         ChromaKeyWindow *gui,
182         int x,
183         int y)
184  : BC_GenericButton(x,
185         y,
186         _("Color..."))
187 {
188         this->plugin = plugin;
189         this->gui = gui;
190 }
191 int ChromaKeyColor::handle_event()
192 {
193         gui->color_thread->start_window(
194                 plugin->config.get_color(),
195                 0xff);
196         return 1;
197 }
198
199
200
201
202 ChromaKeyThreshold::ChromaKeyThreshold(ChromaKey *plugin, int x, int y)
203  : BC_FSlider(x,
204                         y,
205                         0,
206                         200,
207                         200,
208                         (float)0,
209                         (float)100,
210                         plugin->config.threshold)
211 {
212         this->plugin = plugin;
213         set_precision(0.01);
214 }
215 int ChromaKeyThreshold::handle_event()
216 {
217         plugin->config.threshold = get_value();
218         plugin->send_configure_change();
219         return 1;
220 }
221
222
223 ChromaKeySlope::ChromaKeySlope(ChromaKey *plugin, int x, int y)
224  : BC_FSlider(x,
225                         y,
226                         0,
227                         200,
228                         200,
229                         (float)0,
230                         (float)100,
231                         plugin->config.slope)
232 {
233         this->plugin = plugin;
234         set_precision(0.01);
235 }
236
237 int ChromaKeySlope::handle_event()
238 {
239         plugin->config.slope = get_value();
240         plugin->send_configure_change();
241         return 1;
242 }
243
244
245 ChromaKeyUseValue::ChromaKeyUseValue(ChromaKey *plugin, int x, int y)
246  : BC_CheckBox(x, y, plugin->config.use_value, _("Use value"))
247 {
248         this->plugin = plugin;
249 }
250 int ChromaKeyUseValue::handle_event()
251 {
252         plugin->config.use_value = get_value();
253         plugin->send_configure_change();
254         return 1;
255 }
256
257
258 ChromaKeyUseColorPicker::ChromaKeyUseColorPicker(ChromaKey *plugin,
259         ChromaKeyWindow *gui,
260         int x,
261         int y)
262  : BC_GenericButton(x, y, _("Use color picker"))
263 {
264         this->plugin = plugin;
265         this->gui = gui;
266 }
267
268 int ChromaKeyUseColorPicker::handle_event()
269 {
270         plugin->config.red = plugin->get_red();
271         plugin->config.green = plugin->get_green();
272         plugin->config.blue = plugin->get_blue();
273         gui->update_sample();
274         plugin->send_configure_change();
275         return 1;
276 }
277
278
279
280
281 ChromaKeyColorThread::ChromaKeyColorThread(ChromaKey *plugin, ChromaKeyWindow *gui)
282  : ColorThread(1, _("Inner color"))
283 {
284         this->plugin = plugin;
285         this->gui = gui;
286 }
287
288 int ChromaKeyColorThread::handle_new_color(int output, int alpha)
289 {
290         plugin->config.red = (float)(output & 0xff0000) / 0xff0000;
291         plugin->config.green = (float)(output & 0xff00) / 0xff00;
292         plugin->config.blue = (float)(output & 0xff) / 0xff;
293         gui->update_sample();
294         plugin->send_configure_change();
295         return 1;
296 }
297
298
299
300
301
302
303
304
305
306
307 ChromaKeyServer::ChromaKeyServer(ChromaKey *plugin)
308  : LoadServer(plugin->PluginClient::smp + 1, plugin->PluginClient::smp + 1)
309 {
310         this->plugin = plugin;
311 }
312 void ChromaKeyServer::init_packages()
313 {
314         for(int i = 0; i < get_total_packages(); i++)
315         {
316                 ChromaKeyPackage *pkg = (ChromaKeyPackage*)get_package(i);
317                 pkg->y1 = plugin->input->get_h() * i / get_total_packages();
318                 pkg->y2 = plugin->input->get_h() * (i + 1) / get_total_packages();
319         }
320
321 }
322 LoadClient* ChromaKeyServer::new_client()
323 {
324         return new ChromaKeyUnit(plugin, this);
325 }
326 LoadPackage* ChromaKeyServer::new_package()
327 {
328         return new ChromaKeyPackage;
329 }
330
331
332
333 ChromaKeyPackage::ChromaKeyPackage()
334  : LoadPackage()
335 {
336 }
337
338 ChromaKeyUnit::ChromaKeyUnit(ChromaKey *plugin, ChromaKeyServer *server)
339  : LoadClient(server)
340 {
341         this->plugin = plugin;
342 }
343
344
345 void ChromaKeyUnit::process_package(LoadPackage *package)
346 {
347         ChromaKeyPackage *pkg = (ChromaKeyPackage*)package;
348
349         int w = plugin->input->get_w();
350
351         float h, s, v;
352         HSV::rgb_to_hsv(plugin->config.red,
353                 plugin->config.green,
354                 plugin->config.blue,
355                 h,
356                 s,
357                 v);
358         //float min_hue = h - plugin->config.threshold * 360 / 100;
359         //float max_hue = h + plugin->config.threshold * 360 / 100;
360
361
362 #define RGB_TO_VALUE(r, g, b) \
363 ((r) * R_TO_Y + (g) * G_TO_Y + (b) * B_TO_Y)
364
365
366 #define OUTER_VARIABLES(plugin) \
367         YUV yuv; \
368         float value = RGB_TO_VALUE(plugin->config.red, \
369                 plugin->config.green, \
370                 plugin->config.blue); \
371         float threshold = plugin->config.threshold / 100; \
372         float min_v = value - threshold; \
373         float max_v = value + threshold; \
374         float r_key = plugin->config.red; \
375         float g_key = plugin->config.green; \
376         float b_key = plugin->config.blue; \
377         int y_key, u_key, v_key; \
378         yuv.rgb_to_yuv_8((int)(r_key * 0xff), (int)(g_key * 0xff), (int)(b_key * 0xff), y_key, u_key, v_key); \
379         float run = plugin->config.slope / 100; \
380         float threshold_run = threshold + run;
381
382         OUTER_VARIABLES(plugin)
383
384
385
386 #define CHROMAKEY(type, components, max, use_yuv) \
387 { \
388         for(int i = pkg->y1; i < pkg->y2; i++) \
389         { \
390                 type *row = (type*)plugin->input->get_rows()[i]; \
391  \
392                 for(int j = 0; j < w; j++) \
393                 { \
394                         float a = 1; \
395  \
396 /* Test for value in range */ \
397                         if(plugin->config.use_value) \
398                         { \
399                                 float current_value; \
400                                 if(use_yuv) \
401                                 { \
402                                         float r = (float)row[0] / max; \
403                                         current_value = r; \
404                                 } \
405                                 else \
406                                 { \
407                                         float r = (float)row[0] / max; \
408                                         float g = (float)row[1] / max; \
409                                         float b = (float)row[2] / max; \
410                                         current_value = RGB_TO_VALUE(r, g, b); \
411                                 } \
412  \
413 /* Full transparency if in range */ \
414                                 if(current_value >= min_v && current_value < max_v) \
415                                 { \
416                                         a = 0; \
417                                 } \
418                                 else \
419 /* Phased out if below or above range */ \
420                                 if(current_value < min_v) \
421                                 { \
422                                         if(min_v - current_value < run) \
423                                                 a = (min_v - current_value) / run; \
424                                 } \
425                                 else \
426                                 if(current_value - max_v < run) \
427                                         a = (current_value - max_v) / run; \
428                         } \
429                         else \
430 /* Use color cube */ \
431                         { \
432                                 float difference; \
433                                 if(use_yuv) \
434                                 { \
435                                         type y = row[0]; \
436                                         type u = row[1]; \
437                                         type v = row[2]; \
438                                         difference = sqrt(SQR(y - y_key) + \
439                                                 SQR(u - u_key) + \
440                                                 SQR(v - v_key)) / max; \
441                                 } \
442                                 else \
443                                 { \
444                                         float r = (float)row[0] / max; \
445                                         float g = (float)row[1] / max; \
446                                         float b = (float)row[2] / max; \
447                                         difference = sqrt(SQR(r - r_key) +  \
448                                                 SQR(g - g_key) + \
449                                                 SQR(b - b_key)); \
450                                 } \
451                                 if(difference < threshold) \
452                                 { \
453                                         a = 0; \
454                                 } \
455                                 else \
456                                 if(difference < threshold_run) \
457                                 { \
458                                         a = (difference - threshold) / run; \
459                                 } \
460  \
461                         } \
462  \
463 /* Multiply alpha and put back in frame */ \
464                         if(components == 4) \
465                         { \
466                                 row[3] = MIN((type)(a * max), row[3]); \
467                         } \
468                         else \
469                         if(use_yuv) \
470                         { \
471                                 row[0] = (type)(a * row[0]); \
472                                 row[1] = (type)(a * (row[1] - (max / 2 + 1)) + max / 2 + 1); \
473                                 row[2] = (type)(a * (row[2] - (max / 2 + 1)) + max / 2 + 1); \
474                         } \
475                         else \
476                         { \
477                                 row[0] = (type)(a * row[0]); \
478                                 row[1] = (type)(a * row[1]); \
479                                 row[2] = (type)(a * row[2]); \
480                         } \
481  \
482                         row += components; \
483                 } \
484         } \
485 }
486
487
488
489
490         switch(plugin->input->get_color_model())
491         {
492                 case BC_RGB_FLOAT:
493                         CHROMAKEY(float, 3, 1.0, 0);
494                         break;
495                 case BC_RGBA_FLOAT:
496                         CHROMAKEY(float, 4, 1.0, 0);
497                         break;
498                 case BC_RGB888:
499                         CHROMAKEY(unsigned char, 3, 0xff, 0);
500                         break;
501                 case BC_RGBA8888:
502                         CHROMAKEY(unsigned char, 4, 0xff, 0);
503                         break;
504                 case BC_YUV888:
505                         CHROMAKEY(unsigned char, 3, 0xff, 1);
506                         break;
507                 case BC_YUVA8888:
508                         CHROMAKEY(unsigned char, 4, 0xff, 1);
509                         break;
510                 case BC_YUV161616:
511                         CHROMAKEY(uint16_t, 3, 0xffff, 1);
512                         break;
513                 case BC_YUVA16161616:
514                         CHROMAKEY(uint16_t, 4, 0xffff, 1);
515                         break;
516         }
517
518 }
519
520
521
522
523
524 REGISTER_PLUGIN(ChromaKey)
525
526
527
528 ChromaKey::ChromaKey(PluginServer *server)
529  : PluginVClient(server)
530 {
531
532         engine = 0;
533 }
534
535 ChromaKey::~ChromaKey()
536 {
537
538         delete engine;
539 }
540
541
542 int ChromaKey::process_buffer(VFrame *frame,
543                 int64_t start_position,
544                 double frame_rate)
545 {
546 SET_TRACE
547
548         load_configuration();
549         this->input = frame;
550         this->output = frame;
551
552         read_frame(frame,
553                 0,
554                 start_position,
555                 frame_rate,
556                 get_use_opengl());
557
558         if(EQUIV(config.threshold, 0))
559         {
560                 return 1;
561         }
562         else
563         {
564                 if(get_use_opengl()) return run_opengl();
565
566                 if(!engine) engine = new ChromaKeyServer(this);
567                 engine->process_packages();
568         }
569 SET_TRACE
570
571         return 1;
572 }
573
574 const char* ChromaKey::plugin_title() { return _("Chroma key"); }
575 int ChromaKey::is_realtime() { return 1; }
576
577 NEW_WINDOW_MACRO(ChromaKey, ChromaKeyWindow)
578
579 LOAD_CONFIGURATION_MACRO(ChromaKey, ChromaKeyConfig)
580
581
582 void ChromaKey::save_data(KeyFrame *keyframe)
583 {
584         FileXML output;
585         output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
586         output.tag.set_title("CHROMAKEY");
587         output.tag.set_property("RED", config.red);
588         output.tag.set_property("GREEN", config.green);
589         output.tag.set_property("BLUE", config.blue);
590         output.tag.set_property("THRESHOLD", config.threshold);
591         output.tag.set_property("SLOPE", config.slope);
592         output.tag.set_property("USE_VALUE", config.use_value);
593         output.append_tag();
594         output.tag.set_title("/CHROMAKEY");
595         output.append_tag();
596         output.append_newline();
597         output.terminate_string();
598 }
599
600 void ChromaKey::read_data(KeyFrame *keyframe)
601 {
602         FileXML input;
603
604         input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
605
606         while(!input.read_tag())
607         {
608                 if(input.tag.title_is("CHROMAKEY"))
609                 {
610                         config.red = input.tag.get_property("RED", config.red);
611                         config.green = input.tag.get_property("GREEN", config.green);
612                         config.blue = input.tag.get_property("BLUE", config.blue);
613                         config.threshold = input.tag.get_property("THRESHOLD", config.threshold);
614                         config.slope = input.tag.get_property("SLOPE", config.slope);
615                         config.use_value = input.tag.get_property("USE_VALUE", config.use_value);
616                 }
617         }
618 }
619
620
621
622 void ChromaKey::update_gui()
623 {
624         if(thread)
625         {
626                 load_configuration();
627                 thread->window->lock_window();
628                 ((ChromaKeyWindow*)thread->window)->threshold->update(config.threshold);
629                 ((ChromaKeyWindow*)thread->window)->slope->update(config.slope);
630                 ((ChromaKeyWindow*)thread->window)->use_value->update(config.use_value);
631                 ((ChromaKeyWindow*)thread->window)->update_sample();
632
633                 thread->window->unlock_window();
634         }
635 }
636
637 int ChromaKey::handle_opengl()
638 {
639 #ifdef HAVE_GL
640         OUTER_VARIABLES(this)
641
642
643
644         static const char *uniform_frag =
645                 "uniform sampler2D tex;\n"
646                 "uniform float min_v;\n"
647                 "uniform float max_v;\n"
648                 "uniform float run;\n"
649                 "uniform float threshold;\n"
650                 "uniform float threshold_run;\n"
651                 "uniform vec3 key;\n";
652
653         static const char *get_yuvvalue_frag =
654                 "float get_value(vec4 color)\n"
655                 "{\n"
656                 "       return abs(color.r);\n"
657                 "}\n";
658
659         static const char *get_rgbvalue_frag =
660                 "float get_value(vec4 color)\n"
661                 "{\n"
662                 "       return dot(color.rgb, vec3(0.29900, 0.58700, 0.11400));\n"
663                 "}\n";
664
665         static const char *value_frag =
666                 "void main()\n"
667                 "{\n"
668                 "       vec4 color = texture2D(tex, gl_TexCoord[0].st);\n"
669                 "       float value = get_value(color);\n"
670                 "       float alpha = 1.0;\n"
671                 "\n"
672                 "       if(value >= min_v && value < max_v)\n"
673                 "               alpha = 0.0;\n"
674                 "       else\n"
675                 "       if(value < min_v)\n"
676                 "       {\n"
677                 "               if(min_v - value < run)\n"
678                 "                       alpha = (min_v - value) / run;\n"
679                 "       }\n"
680                 "       else\n"
681                 "       if(value - max_v < run)\n"
682                 "               alpha = (value - max_v) / run;\n"
683                 "\n"
684                 "       gl_FragColor = vec4(color.rgb, alpha);\n"
685                 "}\n";
686
687         static const char *cube_frag =
688                 "void main()\n"
689                 "{\n"
690                 "       vec4 color = texture2D(tex, gl_TexCoord[0].st);\n"
691                 "       float difference = length(color.rgb - key);\n"
692                 "       float alpha = 1.0;\n"
693                 "       if(difference < threshold)\n"
694                 "               alpha = 0.0;\n"
695                 "       else\n"
696                 "       if(difference < threshold_run)\n"
697                 "               alpha = (difference - threshold) / run;\n"
698                 "       gl_FragColor = vec4(color.rgb, min(color.a, alpha));\n"
699                 "}\n";
700
701
702
703         get_output()->to_texture();
704         get_output()->enable_opengl();
705         get_output()->init_screen();
706         const char *shader_stack[] = { 0, 0, 0, 0, 0 };
707         int current_shader = 0;
708
709         shader_stack[current_shader++] = uniform_frag;
710         switch(get_output()->get_color_model())
711         {
712                 case BC_YUV888:
713                 case BC_YUVA8888:
714                         if(config.use_value)
715                         {
716                                 shader_stack[current_shader++] = get_yuvvalue_frag;
717                                 shader_stack[current_shader++] = value_frag;
718                         }
719                         else
720                         {
721                                 shader_stack[current_shader++] = cube_frag;
722                         }
723                         break;
724
725                 default:
726                         if(config.use_value)
727                         {
728                                 shader_stack[current_shader++] = get_rgbvalue_frag;
729                                 shader_stack[current_shader++] = value_frag;
730                         }
731                         else
732                         {
733                                 shader_stack[current_shader++] = cube_frag;
734                         }
735                         break;
736         }
737 SET_TRACE
738
739         unsigned int frag = VFrame::make_shader(0,
740                 shader_stack[0],
741                 shader_stack[1],
742                 shader_stack[2],
743                 shader_stack[3],
744                 0);
745         get_output()->bind_texture(0);
746
747         if(frag)
748         {
749                 glUseProgram(frag);
750                 glUniform1i(glGetUniformLocation(frag, "tex"), 0);
751                 glUniform1f(glGetUniformLocation(frag, "min_v"), min_v);
752                 glUniform1f(glGetUniformLocation(frag, "max_v"), max_v);
753                 glUniform1f(glGetUniformLocation(frag, "run"), run);
754                 glUniform1f(glGetUniformLocation(frag, "threshold"), threshold);
755                 glUniform1f(glGetUniformLocation(frag, "threshold_run"), threshold_run);
756                 if(get_output()->get_color_model() != BC_YUV888 &&
757                         get_output()->get_color_model() != BC_YUVA8888)
758                         glUniform3f(glGetUniformLocation(frag, "key"),
759                                 r_key, g_key, b_key);
760                 else
761                         glUniform3f(glGetUniformLocation(frag, "key"),
762                                 (float)y_key / 0xff, (float)u_key / 0xff, (float)v_key / 0xff);
763
764         }
765 SET_TRACE
766
767         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
768         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
769
770         if(BC_CModels::components(get_output()->get_color_model()) == 3)
771         {
772                 glEnable(GL_BLEND);
773                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
774                 get_output()->clear_pbuffer();
775         }
776 SET_TRACE
777
778         get_output()->draw_texture();
779
780         glUseProgram(0);
781         get_output()->set_opengl_state(VFrame::SCREEN);
782         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
783         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
784         glDisable(GL_BLEND);
785 SET_TRACE
786         return 0;
787 #endif
788 }
789