1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Brecht Van Lommel.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file GPU_draw.h
* \ingroup gpu
*/
#ifndef __GPU_DRAW_H__
#define __GPU_DRAW_H__
#ifdef __cplusplus
extern "C" {
#endif
struct ImBuf;
struct Image;
struct ImageUser;
struct MTexPoly;
struct Object;
struct Scene;
struct SceneLayer;
struct View3D;
struct RegionView3D;
struct SmokeModifierData;
struct DupliObject;
/* OpenGL drawing functions related to shading. These are also
* shared with the game engine, where there were previously
* duplicates of some of these functions. */
/* Initialize
* - sets the default Blender opengl state, if in doubt, check
* the contents of this function
* - this is called when starting Blender, for opengl rendering,
* and for switching back from the game engine for example. */
void GPU_state_init(void);
/* Programmable point size
* - shaders set their own point size when enabled
* - use glPointSize when disabled */
void GPU_enable_program_point_size(void);
void GPU_disable_program_point_size(void);
/* Material drawing
* - first the state is initialized by a particular object and
* it's materials
* - after this, materials can be quickly enabled by their number,
* GPU_object_material_bind returns 0 if drawing should be skipped
* - after drawing, the material must be disabled again */
void GPU_begin_object_materials(struct View3D *v3d, struct RegionView3D *rv3d,
struct Scene *scene, struct SceneLayer *sl,
struct Object *ob, bool glsl, bool *do_alpha_after);
void GPU_end_object_materials(void);
bool GPU_object_materials_check(void);
int GPU_object_material_bind(int nr, void *attribs);
void GPU_object_material_unbind(void);
int GPU_object_material_visible(int nr, void *attribs);
void GPU_begin_dupli_object(struct DupliObject *dob);
void GPU_end_dupli_object(void);
void GPU_material_diffuse_get(int nr, float diff[4]);
bool GPU_material_use_matcaps_get(void);
void GPU_set_material_alpha_blend(int alphablend);
int GPU_get_material_alpha_blend(void);
/* TexFace drawing
* - this is mutually exclusive with material drawing, a mesh should
* be drawn using one or the other
* - passing NULL clears the state again */
int GPU_set_tpage(struct MTexPoly *mtexpoly, int mipmap, int transp);
void GPU_clear_tpage(bool force);
/* Lights
* - returns how many lights were enabled
* - this affects fixed functions materials and texface, not glsl */
int GPU_default_lights(void);
int GPU_scene_object_lights(
struct SceneLayer *sl, float viewmat[4][4], int ortho);
/* Text render
* - based on moving uv coordinates */
void GPU_render_text(
struct MTexPoly *mtexpoly, int mode,
const char *textstr, int textlen, unsigned int *col,
const float *v_quad[4], const float *uv_quad[4],
int glattrib);
/* Mipmap settings
* - these will free textures on changes */
void GPU_set_mipmap(bool mipmap);
bool GPU_get_mipmap(void);
void GPU_set_linear_mipmap(bool linear);
bool GPU_get_linear_mipmap(void);
void GPU_paint_set_mipmap(bool mipmap);
/* Anisotropic filtering settings
* - these will free textures on changes */
void GPU_set_anisotropic(float value);
float GPU_get_anisotropic(void);
/* enable gpu mipmapping */
void GPU_set_gpu_mipmapping(int gpu_mipmap);
/* Image updates and free
* - these deal with images bound as opengl textures */
void GPU_paint_update_image(struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
void GPU_update_images_framechange(void);
int GPU_update_image_time(struct Image *ima, double time);
int GPU_verify_image(
struct Image *ima, struct ImageUser *iuser,
int textarget, int tftile, bool compare, bool mipmap, bool is_data);
void GPU_create_gl_tex(
unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth,
int textarget, bool mipmap, bool use_hight_bit_depth, struct Image *ima);
void GPU_create_gl_tex_compressed(
unsigned int *bind, unsigned int *pix, int x, int y, int mipmap,
int textarget, struct Image *ima, struct ImBuf *ibuf);
bool GPU_upload_dxt_texture(struct ImBuf *ibuf);
void GPU_free_image(struct Image *ima);
void GPU_free_images(void);
void GPU_free_images_anim(void);
void GPU_free_images_old(void);
/* smoke drawing functions */
void GPU_free_smoke(struct SmokeModifierData *smd);
void GPU_create_smoke(struct SmokeModifierData *smd, int highres);
/* Delayed free of OpenGL buffers by main thread */
void GPU_free_unused_buffers(void);
#ifdef WITH_OPENSUBDIV
struct DerivedMesh;
void GPU_draw_update_fvar_offset(struct DerivedMesh *dm);
#endif
/* utilities */
void GPU_select_index_set(int index);
void GPU_select_index_get(int index, int *r_col);
int GPU_select_to_index(unsigned int col);
void GPU_select_to_index_array(unsigned int *col, const unsigned int size);
typedef enum eGPUStateMask {
GPU_DEPTH_BUFFER_BIT = (1 << 0),
GPU_ENABLE_BIT = (1 << 1),
GPU_SCISSOR_BIT = (1 << 2),
GPU_VIEWPORT_BIT = (1 << 3),
GPU_BLEND_BIT = (1 << 4),
} eGPUStateMask;
typedef struct GPUStateValues
{
eGPUStateMask mask;
/* GL_ENABLE_BIT */
unsigned int is_alpha_test : 1;
unsigned int is_blend : 1;
bool is_clip_plane[6];
unsigned int is_cull_face : 1;
unsigned int is_depth_test : 1;
unsigned int is_dither : 1;
bool is_light[8];
unsigned int is_lighting : 1;
unsigned int is_line_smooth : 1;
unsigned int is_color_logic_op : 1;
unsigned int is_map1_vertex3 : 1;
unsigned int is_multisample : 1;
unsigned int is_normalize : 1;
unsigned int is_polygon_offset_line : 1;
unsigned int is_polygon_offset_fill : 1;
unsigned int is_polygon_smooth : 1;
unsigned int is_sample_alpha_to_coverage : 1;
unsigned int is_scissor_test : 1;
unsigned int is_stencil_test : 1;
unsigned int is_texture_2d : 1;
/* GL_DEPTH_BUFFER_BIT */
/* unsigned int is_depth_test : 1; */
int depth_func;
double depth_clear_value;
bool depth_write_mask;
/* GL_SCISSOR_BIT */
int scissor_box[4];
/* unsigned int is_scissor_test : 1; */
/* GL_VIEWPORT_BIT */
int viewport[4];
double near_far[2];
} GPUStateValues;
void gpuSaveState(GPUStateValues *attribs, eGPUStateMask mask);
void gpuRestoreState(GPUStateValues *attribs);
#ifdef __cplusplus
}
#endif
#endif
|