Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/intern/draw_view.c')
-rw-r--r--source/blender/draw/intern/draw_view.c132
1 files changed, 64 insertions, 68 deletions
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index a666ec5395f..05aecea1d7a 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -79,7 +79,7 @@ void DRW_draw_region_info(void)
/* ************************* Grid ************************** */
-static void gridline_range(double x0, double dx, double max, int *r_first, int *r_count)
+static void gridline_range(double x0, double dx, double max, int *r_first, int *r_len)
{
/* determine range of gridlines that appear in this Area -- similar calc but separate ranges for x & y
* x0 is gridline 0, the axis in screen space
@@ -90,11 +90,11 @@ static void gridline_range(double x0, double dx, double max, int *r_first, int *
if (first <= last) {
*r_first = first;
- *r_count = last - first + 1;
+ *r_len = last - first + 1;
}
else {
*r_first = 0;
- *r_count = 0;
+ *r_len = 0;
}
}
@@ -104,19 +104,19 @@ static int gridline_count(ARegion *ar, double x0, double y0, double dx)
* dx is the frequency, shared by x & y directions
* pass in dx of smallest (highest precision) grid we want to draw */
- int first, x_ct, y_ct;
+ int first, x_len, y_len;
- gridline_range(x0, dx, ar->winx, &first, &x_ct);
- gridline_range(y0, dx, ar->winy, &first, &y_ct);
+ gridline_range(x0, dx, ar->winx, &first, &x_len);
+ gridline_range(y0, dx, ar->winy, &first, &y_len);
- int total_ct = x_ct + y_ct;
+ int total_len = x_len + y_len;
- return total_ct;
+ return total_len;
}
static bool drawgrid_draw(
ARegion *ar, double x0, double y0, double dx, int skip_mod,
- unsigned pos, unsigned col, GLubyte col_value[3])
+ uint pos, uint col, GLubyte col_value[3])
{
/* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw
* always skip exact x0 & y0 axes; they will be drawn later in color
@@ -129,7 +129,7 @@ static bool drawgrid_draw(
const float y_max = (float)ar->winy;
int first, ct;
- int x_ct = 0, y_ct = 0; /* count of lines actually drawn */
+ int x_len = 0, y_len = 0; /* count of lines actually drawn */
int lines_skipped_for_next_unit = 0;
/* draw vertical lines */
@@ -143,13 +143,13 @@ static bool drawgrid_draw(
continue;
}
- if (x_ct == 0)
+ if (x_len == 0)
immAttrib3ub(col, col_value[0], col_value[1], col_value[2]);
float x = (float)(x0 + i * dx);
immVertex2f(pos, x, 0.0f);
immVertex2f(pos, x, y_max);
- ++x_ct;
+ ++x_len;
}
/* draw horizontal lines */
@@ -163,13 +163,13 @@ static bool drawgrid_draw(
continue;
}
- if (x_ct + y_ct == 0)
+ if (x_len + y_len == 0)
immAttrib3ub(col, col_value[0], col_value[1], col_value[2]);
float y = (float)(y0 + i * dx);
immVertex2f(pos, 0.0f, y);
immVertex2f(pos, x_max, y);
- ++y_ct;
+ ++y_len;
}
return lines_skipped_for_next_unit > 0;
@@ -214,13 +214,13 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
glDepthMask(GL_FALSE); /* disable write in zbuffer */
#endif
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- unsigned char col[3], col2[3];
+ uchar col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col);
if (unit->system) {
@@ -249,11 +249,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
*grid_unit = bUnit_GetNameDisplay(usys, i);
rv3d->gridview = (float)((scalar * (double)v3d->grid) / (double)unit->scale_length);
- int gridline_ct = gridline_count(ar, x, y, dx_scalar);
- if (gridline_ct == 0)
+ int gridline_len = gridline_count(ar, x, y, dx_scalar);
+ if (gridline_len == 0)
goto drawgrid_cleanup; /* nothing to draw */
- immBegin(GWN_PRIM_LINES, gridline_ct * 2);
+ immBegin(GPU_PRIM_LINES, gridline_len * 2);
}
float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar);
@@ -302,11 +302,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
}
}
- int gridline_ct = gridline_count(ar, x, y, dx);
- if (gridline_ct == 0)
+ int gridline_len = gridline_count(ar, x, y, dx);
+ if (gridline_len == 0)
goto drawgrid_cleanup; /* nothing to draw */
- immBegin(GWN_PRIM_LINES, gridline_ct * 2);
+ immBegin(GPU_PRIM_LINES, gridline_len * 2);
if (grids_to_draw == 2) {
UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2);
@@ -369,25 +369,25 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0;
bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0;
- unsigned char col_grid[3], col_axis[3];
+ uchar col_grid[3], col_axis[3];
glLineWidth(1.0f);
UI_GetThemeColor3ubv(TH_GRID, col_grid);
if (show_floor) {
- const unsigned vertex_ct = 2 * (gridlines * 4 + 2);
+ const uint vertex_len = 2 * (gridlines * 4 + 2);
const int sublines = v3d->gridsubdiv;
- unsigned char col_bg[3], col_grid_emphasise[3], col_grid_light[3];
+ uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3];
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, vertex_ct);
+ immBegin(GPU_PRIM_LINES, vertex_len);
/* draw normal grid lines */
UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10);
@@ -469,12 +469,12 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
if (show_axis_x || show_axis_y || show_axis_z) {
/* draw axis lines -- sometimes grid floor is off, other times we still need to draw the Z axis */
- Gwn_VertFormat *format = immVertexFormat();
- uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2);
+ immBegin(GPU_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2);
if (show_axis_x) {
UI_make_axis_color(col_grid, col_axis, 'X');
@@ -548,8 +548,8 @@ void DRW_draw_grid(void)
*(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */
drawgrid(&scene->unit, ar, v3d, &grid_unit);
- gpuLoadProjectionMatrix(rv3d->winmat);
- gpuLoadMatrix(rv3d->viewmat);
+ GPU_matrix_projection_set(rv3d->winmat);
+ GPU_matrix_set(rv3d->viewmat);
}
else {
glDepthMask(GL_TRUE);
@@ -582,21 +582,21 @@ void DRW_draw_background(void)
/* Gradient background Color */
glDisable(GL_DEPTH_TEST);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- unsigned char col_hi[3], col_lo[3];
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uchar col_hi[3], col_lo[3];
- gpuPushMatrix();
- gpuLoadIdentity();
- gpuLoadProjectionMatrix(m);
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_projection_set(m);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR_DITHER);
UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib3ubv(color, col_lo);
immVertex2f(pos, -1.0f, -1.0f);
immVertex2f(pos, 1.0f, -1.0f);
@@ -608,7 +608,7 @@ void DRW_draw_background(void)
immUnbindProgram();
- gpuPopMatrix();
+ GPU_matrix_pop();
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -689,10 +689,10 @@ void DRW_draw_cursor(void)
/* Draw lines */
if (is_aligned == false) {
- uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColor3(TH_VIEW_OVERLAY);
- immBegin(GWN_PRIM_LINES, 12);
+ immBegin(GPU_PRIM_LINES, 12);
const float scale = ED_view3d_pixel_size_no_ui_scale(rv3d, cursor->location) * U.widget_unit;
@@ -724,14 +724,14 @@ void DRW_draw_cursor(void)
}
ED_region_pixelspace(ar);
- gpuTranslate2f(co[0] + 0.5f, co[1] + 0.5f);
- gpuScale2f(U.widget_unit, U.widget_unit);
+ GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f);
+ GPU_matrix_scale_2f(U.widget_unit, U.widget_unit);
- Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned);
+ GPUBatch *cursor_batch = DRW_cache_cursor_get(is_aligned);
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR);
- GWN_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
+ GPU_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
- GWN_batch_draw(cursor_batch);
+ GPU_batch_draw(cursor_batch);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
@@ -739,34 +739,30 @@ void DRW_draw_cursor(void)
}
}
-/* **************************** 3D Manipulator ******************************** */
+/* **************************** 3D Gizmo ******************************** */
-void DRW_draw_manipulator_3d(void)
+void DRW_draw_gizmo_3d(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
- View3D *v3d = draw_ctx->v3d;
- v3d->zbuf = false;
ARegion *ar = draw_ctx->ar;
- /* draw depth culled manipulators - manipulators need to be updated *after* view matrix was set up */
- /* TODO depth culling manipulators is not yet supported, just drawing _3D here, should
+ /* draw depth culled gizmos - gizmos need to be updated *after* view matrix was set up */
+ /* TODO depth culling gizmos is not yet supported, just drawing _3D here, should
* later become _IN_SCENE (and draw _3D separate) */
- WM_manipulatormap_draw(
- ar->manipulator_map, draw_ctx->evil_C,
- WM_MANIPULATORMAP_DRAWSTEP_3D);
+ WM_gizmomap_draw(
+ ar->gizmo_map, draw_ctx->evil_C,
+ WM_GIZMOMAP_DRAWSTEP_3D);
}
-void DRW_draw_manipulator_2d(void)
+void DRW_draw_gizmo_2d(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
- View3D *v3d = draw_ctx->v3d;
- v3d->zbuf = false;
ARegion *ar = draw_ctx->ar;
- WM_manipulatormap_draw(
- ar->manipulator_map, draw_ctx->evil_C,
- WM_MANIPULATORMAP_DRAWSTEP_2D);
+ WM_gizmomap_draw(
+ ar->gizmo_map, draw_ctx->evil_C,
+ WM_GIZMOMAP_DRAWSTEP_2D);
glDepthMask(GL_TRUE);
}