additional Andrew provided Termux mods +
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bctexture.h
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 #ifndef BCTEXTURE_H
23 #define BCTEXTURE_H
24
25
26 #include "vframe.inc"
27
28
29 // Container for texture objects
30
31 class BC_Texture
32 {
33 public:
34         BC_Texture(int w, int h, int colormodel);
35         ~BC_Texture();
36
37         friend class VFrame;
38
39 // Create a new texture if *texture if 0
40 // or update the existing texture if *texture is
41 // nonzero.  The created texture object is stored in *texture.
42 // The texture parameters are stored in the texture manager.
43 // The user must delete *texture when finished with it.
44 // The texture is bound to the current texture unit and enabled.
45 // Must be called from a synchronous opengl thread after enable_opengl.
46         static void new_texture(BC_Texture **texture,
47                 int w,
48                 int h,
49                 int colormodel);
50
51 // Bind the frame's texture to GL_TEXTURE_2D and enable it.
52 // If a texture_unit is supplied, the texture unit is made active
53 // and the commands are run in the right sequence to
54 // initialize it to our preferred specifications.
55 // The texture unit initialization requires the texture to be bound.
56         void bind(int texture_unit, int nearest=0);
57
58 // Calculate the power of 2 size for allocating textures
59         static int calculate_texture_size(int w, int *max = 0);
60         int get_texture_id();
61         int get_texture_w();
62         int get_texture_h();
63         int get_texture_components();
64         int get_window_id();
65         void draw_texture(
66                 float in_x1, float in_y1, float in_x2, float in_y2,
67                 float out_x1, float out_y1, float out_x2, float out_y2);
68
69         void write_tex(const char *fn, int id);
70         void write_tex(const char *fn);
71 private:
72         void clear_objects();
73
74 // creates a new texture or updates an existing texture to work with the
75 // current window.
76         void create_texture(int w, int h, int colormodel);
77
78
79         int window_id;
80         int texture_id;
81         int texture_w;
82         int texture_h;
83         int texture_components;
84         int colormodel;
85         int w;
86         int h;
87 };
88
89
90 #endif