CMake: add WITH_LINKER_LLD option for unix platforms
[blender-staging.git] / source / blender / editors / include / BIF_glutil.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19
20 /** \file
21  * \ingroup editorui
22  */
23
24 #ifndef __BIF_GLUTIL_H__
25 #define __BIF_GLUTIL_H__
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 struct rcti;
32
33 struct ColorManagedDisplaySettings;
34 struct ColorManagedViewSettings;
35 struct ImBuf;
36 struct bContext;
37
38 typedef struct IMMDrawPixelsTexState {
39   struct GPUShader *shader;
40   unsigned int pos;
41   unsigned int texco;
42   bool do_shader_unbind;
43 } IMMDrawPixelsTexState;
44
45 /* To be used before calling immDrawPixelsTex
46  * Default shader is GPU_SHADER_2D_IMAGE_COLOR
47  * Returns a shader to be able to set uniforms */
48 IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin);
49
50 /**
51  * immDrawPixelsTex - Functions like a limited glDrawPixels, but actually draws the
52  * image using textures, which can be tremendously faster on low-end
53  * cards, and also avoids problems with the raster position being
54  * clipped when offscreen. Pixel unpacking parameters and
55  * the glPixelZoom values are _not_ respected.
56  *
57  * \attention Use immDrawPixelsTexSetup before calling this function.
58  *
59  * \attention This routine makes many assumptions: the rect data
60  * is expected to be in RGBA byte or float format, and the
61  * modelview and projection matrices are assumed to define a
62  * 1-to-1 mapping to screen space.
63  */
64 void immDrawPixelsTex(IMMDrawPixelsTexState *state,
65                       float x,
66                       float y,
67                       int img_w,
68                       int img_h,
69                       int format,
70                       int type,
71                       int zoomfilter,
72                       void *rect,
73                       float xzoom,
74                       float yzoom,
75                       float color[4]);
76 void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state,
77                                float x,
78                                float y,
79                                int img_w,
80                                int img_h,
81                                int format,
82                                int type,
83                                int zoomfilter,
84                                void *rect,
85                                float clip_min_x,
86                                float clip_min_y,
87                                float clip_max_x,
88                                float clip_max_y,
89                                float xzoom,
90                                float yzoom,
91                                float color[4]);
92 void immDrawPixelsTexScaled(IMMDrawPixelsTexState *state,
93                             float x,
94                             float y,
95                             int img_w,
96                             int img_h,
97                             int format,
98                             int type,
99                             int zoomfilter,
100                             void *rect,
101                             float scaleX,
102                             float scaleY,
103                             float xzoom,
104                             float yzoom,
105                             float color[4]);
106 void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
107                                      float x,
108                                      float y,
109                                      int img_w,
110                                      int img_h,
111                                      int format,
112                                      int type,
113                                      int zoomfilter,
114                                      void *rect,
115                                      float scaleX,
116                                      float scaleY,
117                                      float clip_min_x,
118                                      float clip_min_y,
119                                      float clip_max_x,
120                                      float clip_max_y,
121                                      float xzoom,
122                                      float yzoom,
123                                      float color[4]);
124
125 /* Image buffer drawing functions, with display transform
126  *
127  * The view and display settings can either be specified manually,
128  * or retrieved from the context with the '_ctx' variations.
129  *
130  * For better performance clipping coordinates can be specified so parts of the
131  * image outside the view are skipped. */
132
133 void ED_draw_imbuf(struct ImBuf *ibuf,
134                    float x,
135                    float y,
136                    int zoomfilter,
137                    struct ColorManagedViewSettings *view_settings,
138                    struct ColorManagedDisplaySettings *display_settings,
139                    float zoom_x,
140                    float zoom_y);
141 void ED_draw_imbuf_clipping(struct ImBuf *ibuf,
142                             float x,
143                             float y,
144                             int zoomfilter,
145                             struct ColorManagedViewSettings *view_settings,
146                             struct ColorManagedDisplaySettings *display_settings,
147                             float clip_min_x,
148                             float clip_min_y,
149                             float clip_max_x,
150                             float clip_max_y,
151                             float zoom_x,
152                             float zoom_y);
153
154 void ED_draw_imbuf_ctx(const struct bContext *C,
155                        struct ImBuf *ibuf,
156                        float x,
157                        float y,
158                        int zoomfilter,
159                        float zoom_x,
160                        float zoom_y);
161 void ED_draw_imbuf_ctx_clipping(const struct bContext *C,
162                                 struct ImBuf *ibuf,
163                                 float x,
164                                 float y,
165                                 int zoomfilter,
166                                 float clip_min_x,
167                                 float clip_min_y,
168                                 float clip_max_x,
169                                 float clip_max_y,
170                                 float zoom_x,
171                                 float zoom_y);
172
173 int ED_draw_imbuf_method(struct ImBuf *ibuf);
174
175 /* OpenGL drawing utility functions. Do not use these in new code, these
176  * are intended to be moved or removed in the future. */
177
178 /* own working polygon offset */
179 float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist);
180 void bglPolygonOffset(float viewdist, float dist);
181
182 void immDrawBorderCorners(unsigned int pos, const struct rcti *border, float zoomx, float zoomy);
183
184 #ifdef __cplusplus
185 }
186 #endif
187
188 #endif /* __BIF_GLUTIL_H__ */