GPU_matrix: use Blender's naming conventions

Thanks to @sergey for review
This commit is contained in:
2018-07-15 15:27:15 +02:00
parent b457cae397
commit 57ab7daa2a
64 changed files with 495 additions and 495 deletions

View File

@@ -119,7 +119,7 @@ void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4]
void GWN_batch_draw(Gwn_Batch*); void GWN_batch_draw(Gwn_Batch*);
// This does not bind/unbind shader and does not call gpuBindMatrices() // This does not bind/unbind shader and does not call GPU_matrix_bind()
void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance); void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance);
// Does not even need batch // Does not even need batch

View File

@@ -18,7 +18,7 @@
#include <string.h> #include <string.h>
// necessary functions from matrix API // necessary functions from matrix API
extern void gpuBindMatrices(const Gwn_ShaderInterface* shaderface); extern void GPU_matrix_bind(const Gwn_ShaderInterface* shaderface);
static void batch_update_program_bindings(Gwn_Batch* batch, unsigned int v_first); static void batch_update_program_bindings(Gwn_Batch* batch, unsigned int v_first);
@@ -537,7 +537,7 @@ void GWN_batch_draw(Gwn_Batch* batch)
assert(batch->verts[0]->vbo_id != 0); assert(batch->verts[0]->vbo_id != 0);
#endif #endif
GWN_batch_program_use_begin(batch); GWN_batch_program_use_begin(batch);
gpuBindMatrices(batch->interface); // external call. GPU_matrix_bind(batch->interface); // external call.
GWN_batch_draw_range_ex(batch, 0, 0, false); GWN_batch_draw_range_ex(batch, 0, 0, false);

View File

@@ -19,8 +19,8 @@
#include <string.h> #include <string.h>
// necessary functions from matrix API // necessary functions from matrix API
extern void gpuBindMatrices(const Gwn_ShaderInterface*); extern void GPU_matrix_bind(const Gwn_ShaderInterface*);
extern bool gpuMatricesDirty(void); extern bool GPU_matrix_dirty_get(void);
typedef struct { typedef struct {
// TODO: organize this struct by frequency of change (run-time) // TODO: organize this struct by frequency of change (run-time)
@@ -129,7 +129,7 @@ void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface)
glUseProgram(program); glUseProgram(program);
get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface); get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface);
gpuBindMatrices(shaderface); GPU_matrix_bind(shaderface);
} }
void immUnbindProgram(void) void immUnbindProgram(void)
@@ -341,8 +341,8 @@ static void immDrawSetup(void)
} }
} }
if (gpuMatricesDirty()) if (GPU_matrix_dirty_get())
gpuBindMatrices(imm.shader_interface); GPU_matrix_bind(imm.shader_interface);
} }
void immEnd(void) void immEnd(void)

View File

@@ -594,24 +594,24 @@ static void blf_draw_gl__start(FontBLF *font)
if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0) if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0)
return; /* glyphs will be translated individually and batched. */ return; /* glyphs will be translated individually and batched. */
gpuPushMatrix(); GPU_matrix_push();
if (font->flags & BLF_MATRIX) if (font->flags & BLF_MATRIX)
gpuMultMatrix(font->m); GPU_matrix_mul(font->m);
gpuTranslate3fv(font->pos); GPU_matrix_translate_3fv(font->pos);
if (font->flags & BLF_ASPECT) if (font->flags & BLF_ASPECT)
gpuScale3fv(font->aspect); GPU_matrix_scale_3fv(font->aspect);
if (font->flags & BLF_ROTATION) if (font->flags & BLF_ROTATION)
gpuRotate2D(RAD2DEG(font->angle)); GPU_matrix_rotate_2d(RAD2DEG(font->angle));
} }
static void blf_draw_gl__end(FontBLF *font) static void blf_draw_gl__end(FontBLF *font)
{ {
if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0) if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0)
gpuPopMatrix(); GPU_matrix_pop();
} }
void BLF_draw_ex( void BLF_draw_ex(

View File

@@ -142,15 +142,15 @@ void blf_batch_draw_begin(FontBLF *font)
if (g_batch.active) { if (g_batch.active) {
float gpumat[4][4]; float gpumat[4][4];
gpuGetModelViewMatrix(gpumat); GPU_matrix_model_view_get(gpumat);
bool mat_changed = (memcmp(gpumat, g_batch.mat, sizeof(g_batch.mat)) != 0); bool mat_changed = (memcmp(gpumat, g_batch.mat, sizeof(g_batch.mat)) != 0);
if (mat_changed) { if (mat_changed) {
/* Modelviewmat is no longer the same. /* Modelviewmat is no longer the same.
* Flush cache but with the previous mat. */ * Flush cache but with the previous mat. */
gpuPushMatrix(); GPU_matrix_push();
gpuLoadMatrix(g_batch.mat); GPU_matrix_set(g_batch.mat);
} }
/* flush cache if config is not the same. */ /* flush cache if config is not the same. */
@@ -165,7 +165,7 @@ void blf_batch_draw_begin(FontBLF *font)
} }
if (mat_changed) { if (mat_changed) {
gpuPopMatrix(); GPU_matrix_pop();
/* Save for next memcmp. */ /* Save for next memcmp. */
memcpy(g_batch.mat, gpumat, sizeof(g_batch.mat)); memcpy(g_batch.mat, gpumat, sizeof(g_batch.mat));
} }

View File

@@ -165,14 +165,14 @@ static void external_draw_scene_do(void *vedata)
} }
/* Rendered draw. */ /* Rendered draw. */
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
ED_region_pixelspace(ar); ED_region_pixelspace(ar);
/* Render result draw. */ /* Render result draw. */
type = rv3d->render_engine->type; type = rv3d->render_engine->type;
type->view_draw(rv3d->render_engine, draw_ctx->evil_C); type->view_draw(rv3d->render_engine, draw_ctx->evil_C);
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
/* Set render info. */ /* Set render info. */
EXTERNAL_Data *data = vedata; EXTERNAL_Data *data = vedata;

View File

@@ -120,16 +120,16 @@ void DRW_draw_callbacks_pre_scene(void)
{ {
RegionView3D *rv3d = DST.draw_ctx.rv3d; RegionView3D *rv3d = DST.draw_ctx.rv3d;
gpuLoadProjectionMatrix(rv3d->winmat); GPU_matrix_projection_set(rv3d->winmat);
gpuLoadMatrix(rv3d->viewmat); GPU_matrix_set(rv3d->viewmat);
} }
void DRW_draw_callbacks_post_scene(void) void DRW_draw_callbacks_post_scene(void)
{ {
RegionView3D *rv3d = DST.draw_ctx.rv3d; RegionView3D *rv3d = DST.draw_ctx.rv3d;
gpuLoadProjectionMatrix(rv3d->winmat); GPU_matrix_projection_set(rv3d->winmat);
gpuLoadMatrix(rv3d->viewmat); GPU_matrix_set(rv3d->viewmat);
} }
struct DRWTextStore *DRW_text_cache_ensure(void) struct DRWTextStore *DRW_text_cache_ensure(void)
@@ -2074,18 +2074,18 @@ void DRW_draw_depth_loop(
DRW_opengl_context_disable(); DRW_opengl_context_disable();
/* XXX Drawing the resulting buffer to the BACK_BUFFER */ /* XXX Drawing the resulting buffer to the BACK_BUFFER */
gpuPushMatrix(); GPU_matrix_push();
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
wmOrtho2_region_pixelspace(ar); wmOrtho2_region_pixelspace(ar);
gpuLoadIdentity(); GPU_matrix_identity_set();
glEnable(GL_DEPTH_TEST); /* Cannot write to depth buffer without testing */ glEnable(GL_DEPTH_TEST); /* Cannot write to depth buffer without testing */
glDepthFunc(GL_ALWAYS); glDepthFunc(GL_ALWAYS);
draw_depth_texture_to_screen(g_select_buffer.texture_depth); draw_depth_texture_to_screen(g_select_buffer.texture_depth);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
gpuPopMatrix(); GPU_matrix_pop();
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
} }
/** \} */ /** \} */

View File

@@ -141,11 +141,11 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar)
} }
float original_proj[4][4]; float original_proj[4][4];
gpuGetProjectionMatrix(original_proj); GPU_matrix_projection_get(original_proj);
wmOrtho2_region_pixelspace(ar); wmOrtho2_region_pixelspace(ar);
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
const int font_id = BLF_default(); const int font_id = BLF_default();
@@ -173,8 +173,8 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar)
} }
} }
gpuPopMatrix(); GPU_matrix_pop();
gpuLoadProjectionMatrix(original_proj); GPU_matrix_projection_set(original_proj);
if (rv3d->rflag & RV3D_CLIPPING) { if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_enable(); ED_view3d_clipping_enable();

View File

@@ -548,8 +548,8 @@ void DRW_draw_grid(void)
*(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */ *(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */
drawgrid(&scene->unit, ar, v3d, &grid_unit); drawgrid(&scene->unit, ar, v3d, &grid_unit);
gpuLoadProjectionMatrix(rv3d->winmat); GPU_matrix_projection_set(rv3d->winmat);
gpuLoadMatrix(rv3d->viewmat); GPU_matrix_set(rv3d->viewmat);
} }
else { else {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
@@ -587,9 +587,9 @@ void DRW_draw_background(void)
uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
uchar col_hi[3], col_lo[3]; uchar col_hi[3], col_lo[3];
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
gpuLoadProjectionMatrix(m); GPU_matrix_projection_set(m);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR_DITHER); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR_DITHER);
@@ -608,7 +608,7 @@ void DRW_draw_background(void)
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -724,8 +724,8 @@ void DRW_draw_cursor(void)
} }
ED_region_pixelspace(ar); ED_region_pixelspace(ar);
gpuTranslate2f(co[0] + 0.5f, co[1] + 0.5f); GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f);
gpuScale2f(U.widget_unit, U.widget_unit); GPU_matrix_scale_2f(U.widget_unit, U.widget_unit);
Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned); Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned);
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR); GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR);

View File

@@ -87,8 +87,8 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
/* because the frame number text is subject to the same scaling as the contents of the view */ /* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_scale_get(v2d, &xscale, NULL); UI_view2d_scale_get(v2d, &xscale, NULL);
gpuPushMatrix(); GPU_matrix_push();
gpuScale2f(1.0f / xscale, 1.0f); GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
/* get timecode string /* get timecode string
* - padding on str-buf passed so that it doesn't sit on the frame indicator * - padding on str-buf passed so that it doesn't sit on the frame indicator
@@ -128,7 +128,7 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag)
numstr, col); numstr, col);
/* restore view transform */ /* restore view transform */
gpuPopMatrix(); GPU_matrix_pop();
} }
/* General call for drawing current frame indicator in animation editor */ /* General call for drawing current frame indicator in animation editor */

View File

@@ -505,8 +505,8 @@ void ED_markers_draw(const bContext *C, int flag)
/* no time correction for framelen! space is drawn with old values */ /* no time correction for framelen! space is drawn with old values */
ypixels = BLI_rcti_size_y(&v2d->mask); ypixels = BLI_rcti_size_y(&v2d->mask);
UI_view2d_scale_get(v2d, &xscale, &yscale); UI_view2d_scale_get(v2d, &xscale, &yscale);
gpuPushMatrix(); GPU_matrix_push();
gpuScale2f(1.0f / xscale, 1.0f); GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
/* x-bounds with offset for text (adjust for long string, avoid checking string width) */ /* x-bounds with offset for text (adjust for long string, avoid checking string width) */
font_width_max = (10 * UI_DPI_FAC) / xscale; font_width_max = (10 * UI_DPI_FAC) / xscale;
@@ -529,7 +529,7 @@ void ED_markers_draw(const bContext *C, int flag)
} }
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
/* ************************ Marker Wrappers API ********************* */ /* ************************ Marker Wrappers API ********************* */

View File

@@ -392,12 +392,12 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
GWN_batch_uniform_3fv(sphere, "color", color); GWN_batch_uniform_3fv(sphere, "color", color);
/* scale to edit-mode space */ /* scale to edit-mode space */
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(obedit->obmat); GPU_matrix_mul(obedit->obmat);
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) { for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
gpuTranslate3f( GPU_matrix_translate_3f(
selem->location_local[0] - location_prev[0], selem->location_local[0] - location_prev[0],
selem->location_local[1] - location_prev[1], selem->location_local[1] - location_prev[1],
selem->location_local[2] - location_prev[2]); selem->location_local[2] - location_prev[2]);
@@ -405,15 +405,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
const float radius = stroke_elem_radius(cdd, selem); const float radius = stroke_elem_radius(cdd, selem);
gpuPushMatrix(); GPU_matrix_push();
gpuScaleUniform(radius); GPU_matrix_scale_1f(radius);
GWN_batch_draw(sphere); GWN_batch_draw(sphere);
gpuPopMatrix(); GPU_matrix_pop();
location_prev = selem->location_local; location_prev = selem->location_local;
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
if (stroke_len > 1) { if (stroke_len > 1) {

View File

@@ -94,10 +94,10 @@ static void ed_gizmo_draw_preset_geometry(
GPU_select_load_id(select_id); GPU_select_load_id(select_id);
} }
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(mat); GPU_matrix_mul(mat);
wm_gizmo_geometryinfo_draw(info, is_select, color); wm_gizmo_geometryinfo_draw(info, is_select, color);
gpuPopMatrix(); GPU_matrix_pop();
if (is_select) { if (is_select) {
GPU_select_load_id(-1); GPU_select_load_id(-1);
@@ -139,10 +139,10 @@ void ED_gizmo_draw_preset_facemap(
GPU_select_load_id(select_id); GPU_select_load_id(select_id);
} }
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(ob->obmat); GPU_matrix_mul(ob->obmat);
ED_draw_object_facemap(CTX_data_depsgraph(C), scene, ob, color, facemap); ED_draw_object_facemap(CTX_data_depsgraph(C), scene, ob, color, facemap);
gpuPopMatrix(); GPU_matrix_pop();
if (is_select) { if (is_select) {
GPU_select_load_id(-1); GPU_select_load_id(-1);

View File

@@ -72,9 +72,9 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix); GPU_matrix_mul(matrix);
gpuRotate2D(RAD2DEGF(arrow_angle)); GPU_matrix_rotate_2d(RAD2DEGF(arrow_angle));
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -93,7 +93,7 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
} }
static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *gz) static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *gz)

View File

@@ -143,15 +143,15 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const
/* *** draw arrow head *** */ /* *** draw arrow head *** */
gpuPushMatrix(); GPU_matrix_push();
if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) { if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
const float size = 0.05f; const float size = 0.05f;
/* translate to line end with some extra offset so box starts exactly where line ends */ /* translate to line end with some extra offset so box starts exactly where line ends */
gpuTranslate3f(0.0f, 0.0f, arrow_length + size); GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size);
/* scale down to box size */ /* scale down to box size */
gpuScale3f(size, size, size); GPU_matrix_scale_3f(size, size, size);
/* draw cube */ /* draw cube */
immUnbindProgram(); immUnbindProgram();
@@ -165,13 +165,13 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const
const float width = 0.06f; const float width = 0.06f;
/* translate to line end */ /* translate to line end */
gpuTranslate3f(0.0f, 0.0f, arrow_length); GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8); imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1); imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
} }
gpuPopMatrix(); GPU_matrix_pop();
#endif /* USE_GIZMO_CUSTOM_ARROWS */ #endif /* USE_GIZMO_CUSTOM_ARROWS */
} }
@@ -190,26 +190,26 @@ static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool
WM_gizmo_calc_matrix_final(gz, matrix_final); WM_gizmo_calc_matrix_final(gz, matrix_final);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
GPU_blend(true); GPU_blend(true);
arrow_draw_geom(arrow, select, color); arrow_draw_geom(arrow, select, color);
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
if (gz->interaction_data) { if (gz->interaction_data) {
GizmoInteraction *inter = gz->interaction_data; GizmoInteraction *inter = gz->interaction_data;
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(inter->init_matrix_final); GPU_matrix_mul(inter->init_matrix_final);
GPU_blend(true); GPU_blend(true);
arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -150,8 +150,8 @@ static void button2d_draw_intern(
} }
bool need_to_pop = true; bool need_to_pop = true;
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
if (is_3d) { if (is_3d) {
RegionView3D *rv3d = CTX_wm_region_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -161,7 +161,7 @@ static void button2d_draw_intern(
mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
zero_v3(matrix_align[3]); zero_v3(matrix_align[3]);
transpose_m4(matrix_align); transpose_m4(matrix_align);
gpuMultMatrix(matrix_align); GPU_matrix_mul(matrix_align);
} }
if (select) { if (select) {
@@ -195,15 +195,15 @@ static void button2d_draw_intern(
float size[2]; float size[2];
if (is_3d) { if (is_3d) {
const float fac = 2.0f; const float fac = 2.0f;
gpuTranslate2f(-(fac / 2), -(fac / 2)); GPU_matrix_translate_2f(-(fac / 2), -(fac / 2));
gpuScale2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC)); GPU_matrix_scale_2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC));
size[0] = 1.0f; size[0] = 1.0f;
size[1] = 1.0f; size[1] = 1.0f;
} }
else { else {
size[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; size[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC;
size[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; size[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC;
gpuPopMatrix(); GPU_matrix_pop();
need_to_pop = false; need_to_pop = false;
} }
UI_icon_draw(size[0], size[1], button->icon); UI_icon_draw(size[0], size[1], button->icon);
@@ -212,7 +212,7 @@ static void button2d_draw_intern(
} }
if (need_to_pop) { if (need_to_pop) {
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -551,8 +551,8 @@ static void gizmo_cage2d_draw_intern(
WM_gizmo_calc_matrix_final(gz, matrix_final); WM_gizmo_calc_matrix_final(gz, matrix_final);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
float margin[2]; float margin[2];
gizmo_calc_rect_view_margin(gz, dims, margin); gizmo_calc_rect_view_margin(gz, dims, margin);
@@ -668,7 +668,7 @@ static void gizmo_cage2d_draw_intern(
} }
GPU_line_width(1.0); GPU_line_width(1.0);
gpuPopMatrix(); GPU_matrix_pop();
} }
/** /**

View File

@@ -296,8 +296,8 @@ static void gizmo_cage3d_draw_intern(
WM_gizmo_calc_matrix_final(gz, matrix_final); WM_gizmo_calc_matrix_final(gz, matrix_final);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
float margin[3]; float margin[3];
gizmo_calc_rect_view_margin(gz, dims, margin); gizmo_calc_rect_view_margin(gz, dims, margin);
@@ -412,7 +412,7 @@ static void gizmo_cage3d_draw_intern(
} }
GPU_line_width(1.0); GPU_line_width(1.0);
gpuPopMatrix(); GPU_matrix_pop();
} }
/** /**

View File

@@ -161,8 +161,8 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[
{ {
GPU_line_width(1.0f); GPU_line_width(1.0f);
gpuPushMatrix(); GPU_matrix_push();
gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); GPU_matrix_rotate_3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f);
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -177,7 +177,7 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
} }
static void dial_ghostarc_draw( static void dial_ghostarc_draw(
@@ -292,8 +292,8 @@ static void dial_draw_intern(
.matrix_basis = (void *)matrix_basis_adjust, .matrix_basis = (void *)matrix_basis_adjust,
}), matrix_final); }), matrix_final);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
/* draw rotation indicator arc first */ /* draw rotation indicator arc first */
if ((gz->flag & WM_GIZMO_DRAW_VALUE) && if ((gz->flag & WM_GIZMO_DRAW_VALUE) &&
@@ -335,7 +335,7 @@ static void dial_draw_intern(
/* draw actual dial gizmo */ /* draw actual dial gizmo */
dial_geom_draw(gz, color, select, matrix_basis_adjust, clip_plane); dial_geom_draw(gz, color, select, matrix_basis_adjust, clip_plane);
gpuPopMatrix(); GPU_matrix_pop();
} }
static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id) static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)

View File

@@ -176,8 +176,8 @@ static void grab3d_draw_intern(
gizmo_color_get(gz, highlight, color); gizmo_color_get(gz, highlight, color);
WM_gizmo_calc_matrix_final(gz, matrix_final); WM_gizmo_calc_matrix_final(gz, matrix_final);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
if (align_view) { if (align_view) {
float matrix_final_unit[4][4]; float matrix_final_unit[4][4];
@@ -186,26 +186,26 @@ static void grab3d_draw_intern(
mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
zero_v3(matrix_align[3]); zero_v3(matrix_align[3]);
transpose_m4(matrix_align); transpose_m4(matrix_align);
gpuMultMatrix(matrix_align); GPU_matrix_mul(matrix_align);
} }
GPU_blend(true); GPU_blend(true);
grab_geom_draw(gz, color, select, draw_options); grab_geom_draw(gz, color, select, draw_options);
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
if (gz->interaction_data) { if (gz->interaction_data) {
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(inter->init_matrix_final); GPU_matrix_mul(inter->init_matrix_final);
if (align_view) { if (align_view) {
gpuMultMatrix(matrix_align); GPU_matrix_mul(matrix_align);
} }
GPU_blend(true); GPU_blend(true);
grab_geom_draw(gz, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); grab_geom_draw(gz, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options);
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -99,14 +99,14 @@ static void gizmo_primitive_draw_intern(
WM_gizmo_calc_matrix_final(gz, matrix_final); WM_gizmo_calc_matrix_final(gz, matrix_final);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
GPU_blend(true); GPU_blend(true);
gizmo_primitive_draw_geom(color_inner, color_outer, draw_style); gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
if (gz->interaction_data) { if (gz->interaction_data) {
GizmoInteraction *inter = gz->interaction_data; GizmoInteraction *inter = gz->interaction_data;
@@ -115,14 +115,14 @@ static void gizmo_primitive_draw_intern(
copy_v3_fl(color_outer, 0.5f); copy_v3_fl(color_outer, 0.5f);
color_outer[3] = 0.8f; color_outer[3] = 0.8f;
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(inter->init_matrix_final); GPU_matrix_mul(inter->init_matrix_final);
GPU_blend(true); GPU_blend(true);
gizmo_primitive_draw_geom(color_inner, color_outer, draw_style); gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -280,7 +280,7 @@ static void ui_update_window_matrix(const wmWindow *window, const ARegion *regio
/* window matrix and aspect */ /* window matrix and aspect */
if (region && region->visible) { if (region && region->visible) {
/* Get projection matrix which includes View2D translation and zoom. */ /* Get projection matrix which includes View2D translation and zoom. */
gpuGetProjectionMatrix(block->winmat); GPU_matrix_projection_get(block->winmat);
block->aspect = 2.0f / fabsf(region->winx * block->winmat[0][0]); block->aspect = 2.0f / fabsf(region->winx * block->winmat[0][0]);
} }
else { else {
@@ -1448,9 +1448,9 @@ void UI_block_draw(const bContext *C, uiBlock *block)
ui_but_to_pixelrect(&rect, ar, block, NULL); ui_but_to_pixelrect(&rect, ar, block, NULL);
/* pixel space for AA widgets */ /* pixel space for AA widgets */
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
wmOrtho2_region_pixelspace(ar); wmOrtho2_region_pixelspace(ar);
@@ -1485,8 +1485,8 @@ void UI_block_draw(const bContext *C, uiBlock *block)
BLF_batch_draw_end(); BLF_batch_draw_end();
/* restore matrix */ /* restore matrix */
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
gpuPopMatrix(); GPU_matrix_pop();
} }
static void ui_block_message_subscribe(ARegion *ar, struct wmMsgBus *mbus, uiBlock *block) static void ui_block_message_subscribe(ARegion *ar, struct wmMsgBus *mbus, uiBlock *block)

View File

@@ -1027,13 +1027,13 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
float col[3] = {alpha, alpha, alpha}; float col[3] = {alpha, alpha, alpha};
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(rect.xmin, yofs); GPU_matrix_translate_2f(rect.xmin, yofs);
gpuScale2f(w, h); GPU_matrix_scale_2f(w, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col);
gpuPopMatrix(); GPU_matrix_pop();
/* min max */ /* min max */
immUniformColor3f(0.5f, 0.5f, 0.5f); immUniformColor3f(0.5f, 0.5f, 0.5f);
@@ -1049,15 +1049,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
} }
/* RGB (3 channel) */ /* RGB (3 channel) */
else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) { else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) {
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(rect.xmin, yofs); GPU_matrix_translate_2f(rect.xmin, yofs);
gpuScale2f(w, h); GPU_matrix_scale_2f(w, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]);
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]); waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]);
waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, colors_alpha[2]); waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, colors_alpha[2]);
gpuPopMatrix(); GPU_matrix_pop();
} }
/* PARADE / YCC (3 channels) */ /* PARADE / YCC (3 channels) */
else if (ELEM(scopes->wavefrm_mode, else if (ELEM(scopes->wavefrm_mode,
@@ -1069,19 +1069,19 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
{ {
int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE); int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(rect.xmin, yofs); GPU_matrix_translate_2f(rect.xmin, yofs);
gpuScale2f(w3, h); GPU_matrix_scale_2f(w3, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
gpuTranslate2f(1.0f, 0.0f); GPU_matrix_translate_2f(1.0f, 0.0f);
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]); waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
gpuTranslate2f(1.0f, 0.0f); GPU_matrix_translate_2f(1.0f, 0.0f);
waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]); waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
gpuPopMatrix(); GPU_matrix_pop();
} }
/* min max */ /* min max */
@@ -1263,13 +1263,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
GPU_point_size(1.0); GPU_point_size(1.0);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(centerx, centery); GPU_matrix_translate_2f(centerx, centery);
gpuScaleUniform(diam); GPU_matrix_scale_1f(diam);
waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col); waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col);
gpuPopMatrix(); GPU_matrix_pop();
} }
immUnbindProgram(); immUnbindProgram();
@@ -1548,15 +1548,15 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
ui_but_v3_get(but, light); ui_but_v3_get(but, light);
/* transform to button */ /* transform to button */
gpuPushMatrix(); GPU_matrix_push();
if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
size = 0.5f * BLI_rcti_size_x(rect); size = 0.5f * BLI_rcti_size_x(rect);
else else
size = 0.5f * BLI_rcti_size_y(rect); size = 0.5f * BLI_rcti_size_y(rect);
gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
gpuScaleUniform(size); GPU_matrix_scale_1f(size);
Gwn_Batch *sphere = GPU_batch_preset_sphere(2); Gwn_Batch *sphere = GPU_batch_preset_sphere(2);
GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
@@ -1580,7 +1580,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
GPU_line_smooth(false); GPU_line_smooth(false);
/* matrix after circle */ /* matrix after circle */
gpuPopMatrix(); GPU_matrix_pop();
immUnbindProgram(); immUnbindProgram();
} }
@@ -1900,7 +1900,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
} }
if (!ok && scopes->track_preview) { if (!ok && scopes->track_preview) {
gpuPushMatrix(); GPU_matrix_push();
/* draw content of pattern area */ /* draw content of pattern area */
GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]); GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]);
@@ -1919,7 +1919,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
immDrawPixelsTex(&state, rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL); immDrawPixelsTex(&state, rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL);
/* draw cross for pixel position */ /* draw cross for pixel position */
gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]); GPU_matrix_translate_2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
GPU_scissor( GPU_scissor(
rect.xmin, rect.xmin,
rect.ymin, rect.ymin,
@@ -1958,7 +1958,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
immUnbindProgram(); immUnbindProgram();
} }
gpuPopMatrix(); GPU_matrix_pop();
ok = true; ok = true;
} }

View File

@@ -1292,7 +1292,7 @@ static void icon_draw_texture_cached(
{ {
float mvp[4][4]; float mvp[4][4];
gpuGetModelViewProjectionMatrix(mvp); GPU_matrix_model_view_projection_get(mvp);
IconDrawCall *call = &g_icon_draw_cache.drawcall_cache[g_icon_draw_cache.calls]; IconDrawCall *call = &g_icon_draw_cache.drawcall_cache[g_icon_draw_cache.calls];
g_icon_draw_cache.calls++; g_icon_draw_cache.calls++;

View File

@@ -1110,7 +1110,7 @@ void UI_widgetbase_draw_cache_flush(void)
GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH,
(float *)g_widget_base_batch.params); (float *)g_widget_base_batch.params);
GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
gpuBindMatrices(batch->interface); GPU_matrix_bind(batch->interface);
GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true);
GWN_batch_program_use_end(batch); GWN_batch_program_use_end(batch);
} }
@@ -4532,8 +4532,8 @@ void ui_draw_pie_center(uiBlock *block)
float angle = atan2f(pie_dir[1], pie_dir[0]); float angle = atan2f(pie_dir[1], pie_dir[0]);
float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4; float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4;
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(cx, cy); GPU_matrix_translate_2f(cx, cy);
GPU_blend(true); GPU_blend(true);
if (btheme->tui.wcol_pie_menu.shaded) { if (btheme->tui.wcol_pie_menu.shaded) {
@@ -4579,7 +4579,7 @@ void ui_draw_pie_center(uiBlock *block)
} }
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
} }

View File

@@ -1151,7 +1151,7 @@ void UI_view2d_view_restore(const bContext *C)
int height = BLI_rcti_size_y(&ar->winrct) + 1; int height = BLI_rcti_size_y(&ar->winrct) + 1;
wmOrtho2(0.0f, (float)width, 0.0f, (float)height); wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
gpuLoadIdentity(); GPU_matrix_identity_set();
// ED_region_pixelspace(CTX_wm_region(C)); // ED_region_pixelspace(CTX_wm_region(C));
} }

View File

@@ -695,17 +695,17 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO); GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO);
} }
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
if (stabmat) { if (stabmat) {
gpuMultMatrix(stabmat); GPU_matrix_mul(stabmat);
} }
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red);
immDrawPixelsTex(&state, 0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL); immDrawPixelsTex(&state, 0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL);
gpuPopMatrix(); GPU_matrix_pop();
if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
GPU_blend(false); GPU_blend(false);
@@ -715,13 +715,13 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
} }
/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x + xofs, y + yofs); GPU_matrix_translate_2f(x + xofs, y + yofs);
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
if (stabmat) { if (stabmat) {
gpuMultMatrix(stabmat); GPU_matrix_mul(stabmat);
} }
gpuScale2f(maxdim, maxdim); GPU_matrix_scale_2f(maxdim, maxdim);
if (do_draw_cb) { if (do_draw_cb) {
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -734,7 +734,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra, const int efra) void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra, const int efra)

View File

@@ -1045,8 +1045,8 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
glPolygonOffset(1.0f, 1.0f); glPolygonOffset(1.0f, 1.0f);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(kcd->ob->obmat); GPU_matrix_mul(kcd->ob->obmat);
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -1193,7 +1193,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
/* Reset default */ /* Reset default */
GPU_depth_test(true); GPU_depth_test(true);

View File

@@ -113,8 +113,8 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a
if ((lcd->totedge > 0) || (lcd->totpoint > 0)) { if ((lcd->totedge > 0) || (lcd->totpoint > 0)) {
GPU_depth_test(false); GPU_depth_test(false);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(lcd->ob->obmat); GPU_matrix_mul(lcd->ob->obmat);
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -146,7 +146,7 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
/* Reset default */ /* Reset default */
GPU_depth_test(true); GPU_depth_test(true);

View File

@@ -326,7 +326,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
wmOrtho2(0, sizex, 0, sizey); wmOrtho2(0, sizex, 0, sizey);
gpuTranslate2f(sizex / 2, sizey / 2); GPU_matrix_translate_2f(sizex / 2, sizey / 2);
G.f |= G_RENDER_OGL; G.f |= G_RENDER_OGL;
ED_gpencil_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ); ED_gpencil_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);

View File

@@ -146,7 +146,7 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
void ED_region_pixelspace(ARegion *ar) void ED_region_pixelspace(ARegion *ar)
{ {
wmOrtho2_region_pixelspace(ar); wmOrtho2_region_pixelspace(ar);
gpuLoadIdentity(); GPU_matrix_identity_set();
} }
/* only exported for WM */ /* only exported for WM */
@@ -352,8 +352,8 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
GPU_blend(true); GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin); GPU_matrix_translate_2f(-ar->winrct.xmin, -ar->winrct.ymin);
for (az = sa->actionzones.first; az; az = az->next) { for (az = sa->actionzones.first; az; az = az->next) {
/* test if action zone is over this region */ /* test if action zone is over this region */
@@ -388,7 +388,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
} }
} }
gpuPopMatrix(); GPU_matrix_pop();
GPU_blend(false); GPU_blend(false);
} }
@@ -2674,11 +2674,11 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
return; return;
/* find window pixel coordinates of origin */ /* find window pixel coordinates of origin */
gpuPushMatrix(); GPU_matrix_push();
/* offset and zoom using ogl */ /* offset and zoom using ogl */
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi); BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi);
@@ -2732,7 +2732,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
BLF_disable(blf_mono_font, BLF_CLIPPING); BLF_disable(blf_mono_font, BLF_CLIPPING);
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)

View File

@@ -364,7 +364,7 @@ void bglPolygonOffset(float viewdist, float dist)
// glPolygonOffset(-1.0, -1.0); // glPolygonOffset(-1.0, -1.0);
/* hack below is to mimic polygon offset */ /* hack below is to mimic polygon offset */
gpuGetProjectionMatrix(winmat); GPU_matrix_projection_get(winmat);
/* dist is from camera to center point */ /* dist is from camera to center point */
@@ -401,7 +401,7 @@ void bglPolygonOffset(float viewdist, float dist)
offset = 0.0; offset = 0.0;
} }
gpuLoadProjectionMatrix(winmat); GPU_matrix_projection_set(winmat);
} }
/* **** Color management helper functions for GLSL display/transform ***** */ /* **** Color management helper functions for GLSL display/transform ***** */

View File

@@ -627,14 +627,14 @@ static void screen_preview_draw(const bScreen *screen, int size_x, int size_y)
wmOrtho2(0.0f, size_x, 0.0f, size_y); wmOrtho2(0.0f, size_x, 0.0f, size_y);
/* center */ /* center */
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
gpuTranslate2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f); GPU_matrix_translate_2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f);
screen_preview_scale_get(screen, size_x, size_y, asp, scale); screen_preview_scale_get(screen, size_x, size_y, asp, scale);
screen_preview_draw_areas(screen, scale, col, 1.5f); screen_preview_draw_areas(screen, scale, col, 1.5f);
gpuPopMatrix(); GPU_matrix_pop();
} }
/** /**

View File

@@ -618,19 +618,19 @@ static void paint_draw_tex_overlay(
glDepthFunc(GL_ALWAYS); glDepthFunc(GL_ALWAYS);
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
gpuPushMatrix(); GPU_matrix_push();
/* brush rotation */ /* brush rotation */
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuRotate2D(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec)); GPU_matrix_rotate_2d(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec));
gpuTranslate2f(-x, -y); GPU_matrix_translate_2f(-x, -y);
/* scale based on tablet pressure */ /* scale based on tablet pressure */
if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) { if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
const float scale = ups->size_pressure_value; const float scale = ups->size_pressure_value;
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(scale, scale); GPU_matrix_scale_2f(scale, scale);
gpuTranslate2f(-x, -y); GPU_matrix_translate_2f(-x, -y);
} }
if (ups->draw_anchored) { if (ups->draw_anchored) {
@@ -671,12 +671,12 @@ static void paint_draw_tex_overlay(
quad.xmax = brush->mask_stencil_dimension[0]; quad.xmax = brush->mask_stencil_dimension[0];
quad.ymax = brush->mask_stencil_dimension[1]; quad.ymax = brush->mask_stencil_dimension[1];
} }
gpuPushMatrix(); GPU_matrix_push();
if (primary) if (primary)
gpuTranslate2fv(brush->stencil_pos); GPU_matrix_translate_2fv(brush->stencil_pos);
else else
gpuTranslate2fv(brush->mask_stencil_pos); GPU_matrix_translate_2fv(brush->mask_stencil_pos);
gpuRotate2D(RAD2DEGF(mtex->rot)); GPU_matrix_rotate_2d(RAD2DEGF(mtex->rot));
} }
/* set quad color. Colored overlay does not get blending */ /* set quad color. Colored overlay does not get blending */
@@ -710,7 +710,7 @@ static void paint_draw_tex_overlay(
immUnbindProgram(); immUnbindProgram();
if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_VIEW)) { if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_VIEW)) {
gpuPopMatrix(); GPU_matrix_pop();
} }
} }
} }
@@ -762,11 +762,11 @@ static void paint_draw_cursor_overlay(
/* scale based on tablet pressure */ /* scale based on tablet pressure */
if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) { if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
do_pop = true; do_pop = true;
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
gpuTranslate2fv(center); GPU_matrix_translate_2fv(center);
gpuScaleUniform(ups->size_pressure_value); GPU_matrix_scale_1f(ups->size_pressure_value);
gpuTranslate2f(-center[0], -center[1]); GPU_matrix_translate_2f(-center[0], -center[1]);
} }
Gwn_VertFormat *format = immVertexFormat(); Gwn_VertFormat *format = immVertexFormat();
@@ -796,7 +796,7 @@ static void paint_draw_cursor_overlay(
immUnbindProgram(); immUnbindProgram();
if (do_pop) if (do_pop)
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -299,8 +299,8 @@ static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsig
/* get the needed opengl matrices */ /* get the needed opengl matrices */
GPU_viewport_size_get_i(view); GPU_viewport_size_get_i(view);
gpuGetModelViewMatrix(matrix); GPU_matrix_model_view_get(matrix);
gpuGetProjectionMatrix(proj); GPU_matrix_projection_get(proj);
view[0] = view[1] = 0; view[0] = view[1] = 0;
mul_m4_m4m4(matrix, matrix, ob_eval->obmat); mul_m4_m4m4(matrix, matrix, ob_eval->obmat);
mul_m4_m4m4(matrix, proj, matrix); mul_m4_m4m4(matrix, proj, matrix);

View File

@@ -436,9 +436,9 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
if (pid->cache->cached_frames == NULL) if (pid->cache->cached_frames == NULL)
continue; continue;
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs); GPU_matrix_translate_2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs);
gpuScale2f(1.0, cache_draw_height); GPU_matrix_scale_2f(1.0, cache_draw_height);
switch (pid->type) { switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY: case PTCACHE_TYPE_SOFTBODY:
@@ -512,7 +512,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
yoffs += cache_draw_height; yoffs += cache_draw_height;
} }

View File

@@ -356,11 +356,11 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
glEnable(GL_COLOR_LOGIC_OP); glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR); glLogicOp(GL_XOR);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
gpuMultMatrix(sc->stabmat); GPU_matrix_mul(sc->stabmat);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -377,7 +377,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_LOGIC_OP);
} }
@@ -603,8 +603,8 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
} }
/* pattern and search outline */ /* pattern and search outline */
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2fv(marker_pos); GPU_matrix_translate_2fv(marker_pos);
if (sc->flag & SC_SHOW_MARKER_PATTERN) { if (sc->flag & SC_SHOW_MARKER_PATTERN) {
immBegin(GWN_PRIM_LINE_LOOP, 4); immBegin(GWN_PRIM_LINE_LOOP, 4);
@@ -625,7 +625,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
marker->search_max[1]); marker->search_max[1]);
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3]) static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3])
@@ -745,8 +745,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
} }
/* pattern */ /* pattern */
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2fv(marker_pos); GPU_matrix_translate_2fv(marker_pos);
if (track->flag & TRACK_LOCKED) { if (track->flag & TRACK_LOCKED) {
if (act) { if (act) {
@@ -800,7 +800,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
marker->search_max[0], marker->search_max[1]); marker->search_max[0], marker->search_max[1]);
} }
gpuPopMatrix(); GPU_matrix_pop();
/* Restore default shader */ /* Restore default shader */
immUnbindProgram(); immUnbindProgram();
@@ -884,8 +884,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
immUniformThemeColor(TH_MARKER_OUTLINE); immUniformThemeColor(TH_MARKER_OUTLINE);
} }
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2fv(marker_pos); GPU_matrix_translate_2fv(marker_pos);
dx = 6.0f / width / sc->zoom; dx = 6.0f / width / sc->zoom;
dy = 6.0f / height / sc->zoom; dy = 6.0f / height / sc->zoom;
@@ -944,7 +944,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos); draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos);
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
@@ -1141,8 +1141,8 @@ static void draw_plane_marker_image(Scene *scene,
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA,
GL_UNSIGNED_BYTE, display_buffer); GL_UNSIGNED_BYTE, display_buffer);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(gl_matrix); GPU_matrix_mul(gl_matrix);
Gwn_VertFormat *imm_format = immVertexFormat(); Gwn_VertFormat *imm_format = immVertexFormat();
uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1170,7 +1170,7 @@ static void draw_plane_marker_image(Scene *scene,
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
@@ -1342,13 +1342,13 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y); UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuPushMatrix(); GPU_matrix_push();
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
gpuMultMatrix(sc->stabmat); GPU_matrix_mul(sc->stabmat);
gpuScale2f(width, height); GPU_matrix_scale_2f(width, height);
act_track = BKE_tracking_track_get_active(tracking); act_track = BKE_tracking_track_get_active(tracking);
@@ -1539,7 +1539,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
if (sc->flag & SC_SHOW_NAMES) { if (sc->flag & SC_SHOW_NAMES) {
/* scaling should be cleared before drawing texts, otherwise font would also be scaled */ /* scaling should be cleared before drawing texts, otherwise font would also be scaled */
@@ -1565,7 +1565,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
} }
} }
gpuPopMatrix(); GPU_matrix_pop();
if (marker_pos) if (marker_pos)
MEM_freeN(marker_pos); MEM_freeN(marker_pos);
@@ -1592,11 +1592,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y); UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
gpuMultMatrix(sc->stabmat); GPU_matrix_mul(sc->stabmat);
gpuScale2f(width, height); GPU_matrix_scale_2f(width, height);
uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1774,7 +1774,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
} }
void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
@@ -1871,8 +1871,8 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
* associated with the clip is already drawn in draw_distortion * associated with the clip is already drawn in draw_distortion
*/ */
if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) { if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) {
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(sc->unistabmat); GPU_matrix_mul(sc->unistabmat);
if (is_track_source) { if (is_track_source) {
MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking);
@@ -1881,13 +1881,13 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
int framenr = ED_space_clip_get_clip_frame_number(sc); int framenr = ED_space_clip_get_clip_frame_number(sc);
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
gpuTranslate2fv(marker->pos); GPU_matrix_translate_2fv(marker->pos);
} }
} }
ED_gpencil_draw_2dimage(C); ED_gpencil_draw_2dimage(C);
gpuPopMatrix(); GPU_matrix_pop();
} }
} }
else { else {

View File

@@ -119,13 +119,13 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
if (sel == data->sel) { if (sel == data->sel) {
immUniformThemeColor(sel ? TH_HANDLE_VERTEX_SELECT : TH_HANDLE_VERTEX); immUniformThemeColor(sel ? TH_HANDLE_VERTEX_SELECT : TH_HANDLE_VERTEX);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(scene_framenr, val); GPU_matrix_translate_2f(scene_framenr, val);
gpuScale2f(1.0f / data->xscale * data->hsize, 1.0f / data->yscale * data->hsize); GPU_matrix_scale_2f(1.0f / data->xscale * data->hsize, 1.0f / data->yscale * data->hsize);
imm_draw_circle_wire_2d(data->pos, 0, 0, 0.7, 8); imm_draw_circle_wire_2d(data->pos, 0, 0, 0.7, 8);
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -1185,13 +1185,13 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
show_cursor |= sc->around == V3D_AROUND_CURSOR; show_cursor |= sc->around == V3D_AROUND_CURSOR;
if (show_cursor) { if (show_cursor) {
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
gpuMultMatrix(sc->stabmat); GPU_matrix_mul(sc->stabmat);
gpuScale2f(width, height); GPU_matrix_scale_2f(width, height);
ED_image_draw_cursor(ar, sc->cursor); ED_image_draw_cursor(ar, sc->cursor);
gpuPopMatrix(); GPU_matrix_pop();
} }
clip_draw_cache_and_notes(C, sc, ar); clip_draw_cache_and_notes(C, sc, ar);

View File

@@ -422,9 +422,9 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize, unsigned int pos) static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize, unsigned int pos)
{ {
/* adjust view transform before starting */ /* adjust view transform before starting */
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(1.0f / xscale * hsize, 1.0f / yscale * hsize); GPU_matrix_scale_2f(1.0f / xscale * hsize, 1.0f / yscale * hsize);
/* draw X shape */ /* draw X shape */
immBegin(GWN_PRIM_LINES, 4); immBegin(GWN_PRIM_LINES, 4);
@@ -436,7 +436,7 @@ static void draw_fcurve_sample_control(float x, float y, float xscale, float ysc
immEnd(); immEnd();
/* restore view transform */ /* restore view transform */
gpuPopMatrix(); GPU_matrix_pop();
} }
/* helper func - draw keyframe vertices only for an F-Curve */ /* helper func - draw keyframe vertices only for an F-Curve */
@@ -585,10 +585,10 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
} }
/* apply unit mapping */ /* apply unit mapping */
gpuPushMatrix(); GPU_matrix_push();
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
gpuScale2f(1.0f, unit_scale); GPU_matrix_scale_2f(1.0f, unit_scale);
gpuTranslate2f(0.0f, offset); GPU_matrix_translate_2f(0.0f, offset);
immBegin(GWN_PRIM_LINE_STRIP, count); immBegin(GWN_PRIM_LINE_STRIP, count);
@@ -645,7 +645,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
immEnd(); immEnd();
gpuPopMatrix(); GPU_matrix_pop();
} }
/* helper func - check if the F-Curve only contains easily drawable segments /* helper func - check if the F-Curve only contains easily drawable segments
@@ -679,10 +679,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
short mapping_flag = ANIM_get_normalization_flags(ac); short mapping_flag = ANIM_get_normalization_flags(ac);
/* apply unit mapping */ /* apply unit mapping */
gpuPushMatrix(); GPU_matrix_push();
unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
gpuScale2f(1.0f, unit_scale); GPU_matrix_scale_2f(1.0f, unit_scale);
gpuTranslate2f(0.0f, offset); GPU_matrix_translate_2f(0.0f, offset);
/* For now, this assumes the worst case scenario, where all the keyframes have /* For now, this assumes the worst case scenario, where all the keyframes have
* bezier interpolation, and are drawn at full res. * bezier interpolation, and are drawn at full res.
@@ -827,7 +827,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
immEnd(); immEnd();
gpuPopMatrix(); GPU_matrix_pop();
} }
/* Debugging -------------------------------- */ /* Debugging -------------------------------- */
@@ -1136,9 +1136,9 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
/* apply unit-scaling to all values via OpenGL */ /* apply unit-scaling to all values via OpenGL */
gpuPushMatrix(); GPU_matrix_push();
gpuScale2f(1.0f, unit_scale); GPU_matrix_scale_2f(1.0f, unit_scale);
gpuTranslate2f(0.0f, offset); GPU_matrix_translate_2f(0.0f, offset);
/* set this once and for all - all handles and handle-verts should use the same thickness */ /* set this once and for all - all handles and handle-verts should use the same thickness */
GPU_line_width(1.0); GPU_line_width(1.0);
@@ -1160,7 +1160,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
draw_fcurve_samples(sipo, ar, fcu); draw_fcurve_samples(sipo, ar, fcu);
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -117,13 +117,13 @@ static void draw_render_info(const bContext *C,
int x, y; int x, y;
UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate2f(x, y); GPU_matrix_translate_2f(x, y);
gpuScale2f(zoomx, zoomy); GPU_matrix_scale_2f(zoomx, zoomy);
if (rd->mode & R_BORDER) { if (rd->mode & R_BORDER) {
/* TODO: round or floor instead of casting to int */ /* TODO: round or floor instead of casting to int */
gpuTranslate2f((int)(-rd->border.xmin * rd->xsch * rd->size * 0.01f), GPU_matrix_translate_2f((int)(-rd->border.xmin * rd->xsch * rd->size * 0.01f),
(int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f)); (int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f));
} }
@@ -144,7 +144,7 @@ static void draw_render_info(const bContext *C,
MEM_freeN(tiles); MEM_freeN(tiles);
} }
gpuPopMatrix(); GPU_matrix_pop();
} }
} }
} }

View File

@@ -3193,8 +3193,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
if (ibuf) { if (ibuf) {
float x, y; float x, y;
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
gpuPushMatrix(); GPU_matrix_push();
/* somehow the offset has to be calculated inverse */ /* somehow the offset has to be calculated inverse */
wmOrtho2_region_pixelspace(ar); wmOrtho2_region_pixelspace(ar);
@@ -3277,8 +3277,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
} }
} }
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
gpuPopMatrix(); GPU_matrix_pop();
} }
BKE_image_release_ibuf(ima, ibuf, lock); BKE_image_release_ibuf(ima, ibuf, lock);

View File

@@ -1405,17 +1405,17 @@ void drawnodespace(const bContext *C, ARegion *ar)
{ {
float original_proj[4][4]; float original_proj[4][4];
gpuGetProjectionMatrix(original_proj); GPU_matrix_projection_get(original_proj);
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
wmOrtho2_pixelspace(ar->winx, ar->winy); wmOrtho2_pixelspace(ar->winx, ar->winy);
WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
gpuPopMatrix(); GPU_matrix_pop();
gpuLoadProjectionMatrix(original_proj); GPU_matrix_projection_set(original_proj);
} }
draw_nodetree(C, ar, ntree, path->parent_key); draw_nodetree(C, ar, ntree, path->parent_key);

View File

@@ -1308,8 +1308,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (draw_backdrop) { if (draw_backdrop) {
/* XXX: need to load identity projection too? */ /* XXX: need to load identity projection too? */
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
} }
glGenTextures(1, (GLuint *)&texid); glGenTextures(1, (GLuint *)&texid);
@@ -1439,7 +1439,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
} }
if (draw_backdrop) { if (draw_backdrop) {
gpuPopMatrix(); GPU_matrix_pop();
return; return;
} }

View File

@@ -621,7 +621,7 @@ void draw_object_backbufsel(
select_mode = ts->selectmode; select_mode = ts->selectmode;
} }
gpuMultMatrix(ob->obmat); GPU_matrix_mul(ob->obmat);
glClearDepth(1.0); GPU_clear(GPU_DEPTH_BIT); glClearDepth(1.0); GPU_clear(GPU_DEPTH_BIT);
GPU_depth_test(true); GPU_depth_test(true);
@@ -688,7 +688,7 @@ void draw_object_backbufsel(
break; break;
} }
gpuLoadMatrix(rv3d->viewmat); GPU_matrix_set(rv3d->viewmat);
} }

View File

@@ -251,7 +251,7 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d)
/* we have to multiply instead of loading viewmatob to make /* we have to multiply instead of loading viewmatob to make
* it work with duplis using displists, otherwise it will * it work with duplis using displists, otherwise it will
* override the dupli-matrix */ * override the dupli-matrix */
gpuMultMatrix(ob->obmat); GPU_matrix_mul(ob->obmat);
} }
#ifdef DEBUG #ifdef DEBUG

View File

@@ -184,8 +184,8 @@ static void view3d_main_region_setup_view(
ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, rect); ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, rect);
/* set for opengl */ /* set for opengl */
gpuLoadProjectionMatrix(rv3d->winmat); GPU_matrix_projection_set(rv3d->winmat);
gpuLoadMatrix(rv3d->viewmat); GPU_matrix_set(rv3d->viewmat);
} }
static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d) static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d)
@@ -1355,10 +1355,10 @@ void ED_view3d_draw_offscreen(
GPU_free_images_anim(G.main); /* XXX :((( */ GPU_free_images_anim(G.main); /* XXX :((( */
} }
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
gpuLoadIdentity(); GPU_matrix_identity_set();
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera) if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera)
view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname); view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname);
@@ -1375,8 +1375,8 @@ void ED_view3d_draw_offscreen(
ar->winy = bwiny; ar->winy = bwiny;
ar->winrct = brect; ar->winrct = brect;
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
gpuPopMatrix(); GPU_matrix_pop();
UI_Theme_Restore(&theme_state); UI_Theme_Restore(&theme_state);

View File

@@ -685,13 +685,13 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
GPU_blend(true); GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
gpuPushMatrix(); GPU_matrix_push();
ED_region_pixelspace(ar); ED_region_pixelspace(ar);
gpuTranslate2f(centx, centy); GPU_matrix_translate_2f(centx, centy);
gpuScaleUniform(bgpic->scale); GPU_matrix_scale_1f(bgpic->scale);
gpuRotate2D(RAD2DEGF(-bgpic->rotation)); GPU_matrix_rotate_2d(RAD2DEGF(-bgpic->rotation));
if (bgpic->flag & CAM_BGIMG_FLAG_FLIP_X) { if (bgpic->flag & CAM_BGIMG_FLAG_FLIP_X) {
zoomx *= -1.0f; zoomx *= -1.0f;
@@ -707,8 +707,8 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
immDrawPixelsTex(&state, x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect, immDrawPixelsTex(&state, x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect,
zoomx, zoomy, col); zoomx, zoomy, col);
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
gpuPopMatrix(); GPU_matrix_pop();
GPU_blend(false); GPU_blend(false);

View File

@@ -195,8 +195,8 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U
static const float axis_highlight[4] = {1, 1, 1, 1}; static const float axis_highlight[4] = {1, 1, 1, 1};
static const float axis_black[4] = {0, 0, 0, 1}; static const float axis_black[4] = {0, 0, 0, 1};
static float axis_color[3][4]; static float axis_color[3][4];
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(gz->matrix_offset); GPU_matrix_mul(gz->matrix_offset);
bool draw_center_done = false; bool draw_center_done = false;
@@ -219,11 +219,11 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U
/* Circle defining active area (revert back to 2D space). */ /* Circle defining active area (revert back to 2D space). */
{ {
gpuPopMatrix(); GPU_matrix_pop();
immUniformColor4fv(color); immUniformColor4fv(color);
imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION); imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(gz->matrix_offset); GPU_matrix_mul(gz->matrix_offset);
} }
draw_center_done = true; draw_center_done = true;
} }
@@ -276,15 +276,15 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U
/* Axis Ball. */ /* Axis Ball. */
{ {
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate3fv(v_final); GPU_matrix_translate_3fv(v_final);
gpuScaleUniform(is_pos ? 0.22f : 0.18f); GPU_matrix_scale_1f(is_pos ? 0.22f : 0.18f);
Gwn_Batch *sphere = GPU_batch_preset_sphere(0); Gwn_Batch *sphere = GPU_batch_preset_sphere(0);
GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
GWN_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); GWN_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade);
GWN_batch_draw(sphere); GWN_batch_draw(sphere);
gpuPopMatrix(); GPU_matrix_pop();
} }
/* Axis XYZ Character. */ /* Axis XYZ Character. */
@@ -298,7 +298,7 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U
} }
} }
gpuPopMatrix(); GPU_matrix_pop();
immUnbindProgram(); immUnbindProgram();
} }
@@ -318,13 +318,13 @@ static void axis3d_draw_intern(
.matrix_offset = matrix_unit, .matrix_offset = matrix_unit,
}), matrix_final); }), matrix_final);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(matrix_final); GPU_matrix_mul(matrix_final);
GPU_blend(true); GPU_blend(true);
axis_geom_draw(gz, color, select); axis_geom_draw(gz, color, select);
GPU_blend(false); GPU_blend(false);
gpuPopMatrix(); GPU_matrix_pop();
} }
static void gizmo_axis_draw(const bContext *C, wmGizmo *gz) static void gizmo_axis_draw(const bContext *C, wmGizmo *gz)

View File

@@ -677,7 +677,7 @@ void ED_view3d_project(const struct ARegion *ar, const float world[3], float reg
RegionView3D *rv3d = ar->regiondata; RegionView3D *rv3d = ar->regiondata;
int viewport[4] = {0, 0, ar->winx, ar->winy}; int viewport[4] = {0, 0, ar->winx, ar->winy};
gpuProject(world, rv3d->viewmat, rv3d->winmat, viewport, region); GPU_matrix_project(world, rv3d->viewmat, rv3d->winmat, viewport, region);
} }
bool ED_view3d_unproject(const struct ARegion *ar, float regionx, float regiony, float regionz, float world[3]) bool ED_view3d_unproject(const struct ARegion *ar, float regionx, float regiony, float regionz, float world[3])
@@ -686,5 +686,5 @@ bool ED_view3d_unproject(const struct ARegion *ar, float regionx, float regiony,
int viewport[4] = {0, 0, ar->winx, ar->winy}; int viewport[4] = {0, 0, ar->winx, ar->winy};
float region[3] = {regionx, regiony, regionz}; float region[3] = {regionx, regiony, regionz};
return gpuUnProject(region, rv3d->viewmat, rv3d->winmat, viewport, world); return GPU_matrix_unproject(region, rv3d->viewmat, rv3d->winmat, viewport, world);
} }

View File

@@ -510,7 +510,7 @@ static void do_lasso_select_mesh(
/* for non zbuf projections, don't change the GL state */ /* for non zbuf projections, don't change the GL state */
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
gpuLoadMatrix(vc->rv3d->viewmat); GPU_matrix_set(vc->rv3d->viewmat);
bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) { if (ts->selectmode & SCE_SELECT_VERTEX) {
@@ -1936,7 +1936,7 @@ static int do_mesh_box_select(
/* for non zbuf projections, don't change the GL state */ /* for non zbuf projections, don't change the GL state */
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
gpuLoadMatrix(vc->rv3d->viewmat); GPU_matrix_set(vc->rv3d->viewmat);
bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax); bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) { if (ts->selectmode & SCE_SELECT_VERTEX) {

View File

@@ -189,8 +189,8 @@ void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *ar)
RegionView3D *rv3d = ar->regiondata; RegionView3D *rv3d = ar->regiondata;
wmViewport(&ar->winrct); // TODO: bad wmViewport(&ar->winrct); // TODO: bad
gpuLoadProjectionMatrix(rv3d->winmat); GPU_matrix_projection_set(rv3d->winmat);
gpuLoadMatrix(rv3d->viewmat); GPU_matrix_set(rv3d->viewmat);
} }
} }

View File

@@ -721,14 +721,14 @@ void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d,
} }
if (is_ortho) { if (is_ortho) {
gpuOrtho(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); GPU_matrix_ortho_set(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
} }
else { else {
gpuFrustum(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); GPU_matrix_frustum_set(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
} }
/* update matrix in 3d view region */ /* update matrix in 3d view region */
gpuGetProjectionMatrix(rv3d->winmat); GPU_matrix_projection_get(rv3d->winmat);
} }
static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob) static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)

View File

@@ -1813,7 +1813,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
tmval[i] += offset[i]; tmval[i] += offset[i];
} }
gpuPushMatrix(); GPU_matrix_push();
/* Dashed lines first. */ /* Dashed lines first. */
if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) { if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) {
@@ -1853,8 +1853,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
case HLP_SPRING: case HLP_SPRING:
immUniformThemeColor(TH_VIEW_OVERLAY); immUniformThemeColor(TH_VIEW_OVERLAY);
gpuTranslate3fv(mval); GPU_matrix_translate_3fv(mval);
gpuRotateAxis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z'); GPU_matrix_rotate_axis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z');
GPU_line_width(3.0f); GPU_line_width(3.0f);
drawArrow(UP, 5, 10, 5); drawArrow(UP, 5, 10, 5);
@@ -1862,7 +1862,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
break; break;
case HLP_HARROW: case HLP_HARROW:
immUniformThemeColor(TH_VIEW_OVERLAY); immUniformThemeColor(TH_VIEW_OVERLAY);
gpuTranslate3fv(mval); GPU_matrix_translate_3fv(mval);
GPU_line_width(3.0f); GPU_line_width(3.0f);
drawArrow(RIGHT, 5, 10, 5); drawArrow(RIGHT, 5, 10, 5);
@@ -1871,7 +1871,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
case HLP_VARROW: case HLP_VARROW:
immUniformThemeColor(TH_VIEW_OVERLAY); immUniformThemeColor(TH_VIEW_OVERLAY);
gpuTranslate3fv(mval); GPU_matrix_translate_3fv(mval);
GPU_line_width(3.0f); GPU_line_width(3.0f);
drawArrow(UP, 5, 10, 5); drawArrow(UP, 5, 10, 5);
@@ -1887,23 +1887,23 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
immUniformThemeColor(TH_VIEW_OVERLAY); immUniformThemeColor(TH_VIEW_OVERLAY);
gpuTranslate3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0); GPU_matrix_translate_3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0);
GPU_line_width(3.0f); GPU_line_width(3.0f);
drawArc(dist, angle - delta_angle, angle - spacing_angle, 10); drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
drawArc(dist, angle + spacing_angle, angle + delta_angle, 10); drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
gpuPushMatrix(); GPU_matrix_push();
gpuTranslate3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0); GPU_matrix_translate_3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
gpuRotateAxis(RAD2DEGF(angle - delta_angle), 'Z'); GPU_matrix_rotate_axis(RAD2DEGF(angle - delta_angle), 'Z');
drawArrowHead(DOWN, 5); drawArrowHead(DOWN, 5);
gpuPopMatrix(); GPU_matrix_pop();
gpuTranslate3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0); GPU_matrix_translate_3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
gpuRotateAxis(RAD2DEGF(angle + delta_angle), 'Z'); GPU_matrix_rotate_axis(RAD2DEGF(angle + delta_angle), 'Z');
drawArrowHead(UP, 5); drawArrowHead(UP, 5);
break; break;
@@ -1913,7 +1913,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
unsigned char col[3], col2[3]; unsigned char col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col); UI_GetThemeColor3ubv(TH_GRID, col);
gpuTranslate3fv(mval); GPU_matrix_translate_3fv(mval);
GPU_line_width(3.0f); GPU_line_width(3.0f);
@@ -1933,7 +1933,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
} }
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
} }
} }
@@ -7049,8 +7049,8 @@ static void drawEdgeSlide(TransInfo *t)
GPU_blend(true); GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -7138,7 +7138,7 @@ static void drawEdgeSlide(TransInfo *t)
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
GPU_blend(false); GPU_blend(false);
@@ -7682,8 +7682,8 @@ static void drawVertSlide(TransInfo *t)
GPU_blend(true); GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
gpuPushMatrix(); GPU_matrix_push();
gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
GPU_line_width(line_size); GPU_line_width(line_size);
@@ -7769,7 +7769,7 @@ static void drawVertSlide(TransInfo *t)
immUnbindProgram(); immUnbindProgram();
} }
gpuPopMatrix(); GPU_matrix_pop();
GPU_depth_test(true); GPU_depth_test(true);
} }

View File

@@ -800,13 +800,13 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
unit_m4(imat); unit_m4(imat);
} }
gpuPushMatrix(); GPU_matrix_push();
if (t->spacetype == SPACE_VIEW3D) { if (t->spacetype == SPACE_VIEW3D) {
/* pass */ /* pass */
} }
else if (t->spacetype == SPACE_IMAGE) { else if (t->spacetype == SPACE_IMAGE) {
gpuScale2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]); GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]);
} }
else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) { else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) {
/* only scale y */ /* only scale y */
@@ -816,7 +816,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
float ysize = BLI_rctf_size_y(datamask); float ysize = BLI_rctf_size_y(datamask);
float xmask = BLI_rcti_size_x(mask); float xmask = BLI_rcti_size_x(mask);
float ymask = BLI_rcti_size_y(mask); float ymask = BLI_rcti_size_y(mask);
gpuScale2f(1.0f, (ysize / xsize) * (xmask / ymask)); GPU_matrix_scale_2f(1.0f, (ysize / xsize) * (xmask / ymask));
} }
depth_test_enabled = GPU_depth_test_enabled(); depth_test_enabled = GPU_depth_test_enabled();
@@ -837,7 +837,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
if (depth_test_enabled) if (depth_test_enabled)
GPU_depth_test(true); GPU_depth_test(true);
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -1116,7 +1116,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis
if (t->spacetype == SPACE_VIEW3D) { if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = t->view; View3D *v3d = t->view;
gpuPushMatrix(); GPU_matrix_push();
copy_v3_v3(v3, dir); copy_v3_v3(v3, dir);
mul_v3_fl(v3, v3d->far); mul_v3_fl(v3, v3d->far);
@@ -1144,7 +1144,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
} }
} }

View File

@@ -90,7 +90,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
GPU_line_width(1.0f); GPU_line_width(1.0f);
gpuTranslate2fv(cursor); GPU_matrix_translate_2fv(cursor);
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -141,7 +141,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
immUnbindProgram(); immUnbindProgram();
gpuTranslate2f(-cursor[0], -cursor[1]); GPU_matrix_translate_2f(-cursor[0], -cursor[1]);
} }
static int draw_uvs_face_check(Scene *scene) static int draw_uvs_face_check(Scene *scene)
@@ -814,7 +814,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* Now draw each face contour separately with another builtin program. */ /* Now draw each face contour separately with another builtin program. */
GWN_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR); GWN_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR);
gpuBindMatrices(loop_batch->interface); GPU_matrix_bind(loop_batch->interface);
GWN_batch_program_use_begin(loop_batch); GWN_batch_program_use_begin(loop_batch);
index = 0; index = 0;

View File

@@ -40,79 +40,79 @@ extern "C" {
struct Gwn_ShaderInterface; struct Gwn_ShaderInterface;
void gpuMatrixReset(void); /* to Identity transform & empty stack */ void GPU_matrix_reset(void); /* to Identity transform & empty stack */
/* ModelView Matrix (2D or 3D) */ /* ModelView Matrix (2D or 3D) */
void gpuPushMatrix(void); /* TODO: PushCopy vs PushIdentity? */ void GPU_matrix_push(void); /* TODO: PushCopy vs PushIdentity? */
void gpuPopMatrix(void); void GPU_matrix_pop(void);
void gpuLoadIdentity(void); void GPU_matrix_identity_set(void);
void gpuScaleUniform(float factor); void GPU_matrix_scale_1f(float factor);
/* 3D ModelView Matrix */ /* 3D ModelView Matrix */
void gpuLoadMatrix(const float m[4][4]); void GPU_matrix_set(const float m[4][4]);
void gpuMultMatrix(const float m[4][4]); void GPU_matrix_mul(const float m[4][4]);
void gpuTranslate3f(float x, float y, float z); void GPU_matrix_translate_3f(float x, float y, float z);
void gpuTranslate3fv(const float vec[3]); void GPU_matrix_translate_3fv(const float vec[3]);
void gpuScale3f(float x, float y, float z); void GPU_matrix_scale_3f(float x, float y, float z);
void gpuScale3fv(const float vec[3]); void GPU_matrix_scale_3fv(const float vec[3]);
void gpuRotate3f(float deg, float x, float y, float z); /* axis of rotation should be a unit vector */ void GPU_matrix_rotate_3f(float deg, float x, float y, float z); /* axis of rotation should be a unit vector */
void gpuRotate3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */ void GPU_matrix_rotate_3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */
void gpuRotateAxis(float deg, char axis); /* TODO: enum for axis? */ void GPU_matrix_rotate_axis(float deg, char axis); /* TODO: enum for axis? */
void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ); void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ);
/* TODO: variant that takes eye[3], center[3], up[3] */ /* TODO: variant that takes eye[3], center[3], up[3] */
/* 2D ModelView Matrix */ /* 2D ModelView Matrix */
void gpuTranslate2f(float x, float y); void GPU_matrix_translate_2f(float x, float y);
void gpuTranslate2fv(const float vec[2]); void GPU_matrix_translate_2fv(const float vec[2]);
void gpuScale2f(float x, float y); void GPU_matrix_scale_2f(float x, float y);
void gpuScale2fv(const float vec[2]); void GPU_matrix_scale_2fv(const float vec[2]);
void gpuRotate2D(float deg); void GPU_matrix_rotate_2d(float deg);
/* Projection Matrix (2D or 3D) */ /* Projection Matrix (2D or 3D) */
void gpuPushProjectionMatrix(void); void GPU_matrix_push_projection(void);
void gpuPopProjectionMatrix(void); void GPU_matrix_pop_projection(void);
/* 3D Projection Matrix */ /* 3D Projection Matrix */
void gpuLoadIdentityProjectionMatrix(void); void GPU_matrix_identity_projection_set(void);
void gpuLoadProjectionMatrix(const float m[4][4]); void GPU_matrix_projection_set(const float m[4][4]);
void gpuOrtho(float left, float right, float bottom, float top, float near, float far); void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far);
void gpuFrustum(float left, float right, float bottom, float top, float near, float far); void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far);
void gpuPerspective(float fovy, float aspect, float near, float far); void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far);
/* 3D Projection between Window and World Space */ /* 3D Projection between Window and World Space */
void gpuProject(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]); void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]);
bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]); bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]);
/* 2D Projection Matrix */ /* 2D Projection Matrix */
void gpuOrtho2D(float left, float right, float bottom, float top); void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top);
/* functions to get matrix values */ /* functions to get matrix values */
const float (*gpuGetModelViewMatrix(float m[4][4]))[4]; const float (*GPU_matrix_model_view_get(float m[4][4]))[4];
const float (*gpuGetProjectionMatrix(float m[4][4]))[4]; const float (*GPU_matrix_projection_get(float m[4][4]))[4];
const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4]; const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4];
const float (*gpuGetNormalMatrix(float m[3][3]))[3]; const float (*GPU_matrix_normal_get(float m[3][3]))[3];
const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3]; const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3];
/* set uniform values for currently bound shader */ /* set uniform values for currently bound shader */
void gpuBindMatrices(const struct Gwn_ShaderInterface *); void GPU_matrix_bind(const struct Gwn_ShaderInterface *);
bool gpuMatricesDirty(void); /* since last bind */ bool GPU_matrix_dirty_get(void); /* since last bind */
/* Python API needs to be able to inspect the stack so errors raise exceptions instead of crashing. */ /* Python API needs to be able to inspect the stack so errors raise exceptions instead of crashing. */
@@ -177,14 +177,14 @@ int GPU_matrix_stack_level_get_projection(void);
#endif /* C11 */ #endif /* C11 */
/* make matrix inputs generic, to avoid warnings */ /* make matrix inputs generic, to avoid warnings */
# define gpuMultMatrix(x) gpuMultMatrix(_GPU_MAT4_CONST_CAST(x)) # define GPU_matrix_mul(x) GPU_matrix_mul(_GPU_MAT4_CONST_CAST(x))
# define gpuLoadMatrix(x) gpuLoadMatrix(_GPU_MAT4_CONST_CAST(x)) # define GPU_matrix_set(x) GPU_matrix_set(_GPU_MAT4_CONST_CAST(x))
# define gpuLoadProjectionMatrix(x) gpuLoadProjectionMatrix(_GPU_MAT4_CONST_CAST(x)) # define GPU_matrix_projection_set(x) GPU_matrix_projection_set(_GPU_MAT4_CONST_CAST(x))
# define gpuGetModelViewMatrix(x) gpuGetModelViewMatrix(_GPU_MAT4_CAST(x)) # define GPU_matrix_model_view_get(x) GPU_matrix_model_view_get(_GPU_MAT4_CAST(x))
# define gpuGetProjectionMatrix(x) gpuGetProjectionMatrix(_GPU_MAT4_CAST(x)) # define GPU_matrix_projection_get(x) GPU_matrix_projection_get(_GPU_MAT4_CAST(x))
# define gpuGetModelViewProjectionMatrix(x) gpuGetModelViewProjectionMatrix(_GPU_MAT4_CAST(x)) # define GPU_matrix_model_view_projection_get(x) GPU_matrix_model_view_projection_get(_GPU_MAT4_CAST(x))
# define gpuGetNormalMatrix(x) gpuGetNormalMatrix(_GPU_MAT3_CAST(x)) # define GPU_matrix_normal_get(x) GPU_matrix_normal_get(_GPU_MAT3_CAST(x))
# define gpuGetNormalMatrixInverse(x) gpuGetNormalMatrixInverse(_GPU_MAT3_CAST(x)) # define GPU_matrix_normal_inverse_get(x) GPU_matrix_normal_inverse_get(_GPU_MAT3_CAST(x))
#endif /* SUPPRESS_GENERIC_MATRIX_API */ #endif /* SUPPRESS_GENERIC_MATRIX_API */
#endif /* __GPU_MATRIX_H__ */ #endif /* __GPU_MATRIX_H__ */

View File

@@ -86,7 +86,7 @@ static MatrixState state = {
#define ProjectionStack state.projection_stack #define ProjectionStack state.projection_stack
#define Projection ProjectionStack.stack[ProjectionStack.top] #define Projection ProjectionStack.stack[ProjectionStack.top]
void gpuMatrixReset(void) void GPU_matrix_reset(void)
{ {
state.model_view_stack.top = 0; state.model_view_stack.top = 0;
state.projection_stack.top = 0; state.projection_stack.top = 0;
@@ -119,76 +119,76 @@ static void checkmat(cosnt float *m)
#endif #endif
void gpuPushMatrix(void) void GPU_matrix_push(void)
{ {
BLI_assert(ModelViewStack.top + 1 < MATRIX_STACK_DEPTH); BLI_assert(ModelViewStack.top + 1 < MATRIX_STACK_DEPTH);
ModelViewStack.top++; ModelViewStack.top++;
copy_m4_m4(ModelView, ModelViewStack.stack[ModelViewStack.top - 1]); copy_m4_m4(ModelView, ModelViewStack.stack[ModelViewStack.top - 1]);
} }
void gpuPopMatrix(void) void GPU_matrix_pop(void)
{ {
BLI_assert(ModelViewStack.top > 0); BLI_assert(ModelViewStack.top > 0);
ModelViewStack.top--; ModelViewStack.top--;
state.dirty = true; state.dirty = true;
} }
void gpuPushProjectionMatrix(void) void GPU_matrix_push_projection(void)
{ {
BLI_assert(ProjectionStack.top + 1 < MATRIX_STACK_DEPTH); BLI_assert(ProjectionStack.top + 1 < MATRIX_STACK_DEPTH);
ProjectionStack.top++; ProjectionStack.top++;
copy_m4_m4(Projection, ProjectionStack.stack[ProjectionStack.top - 1]); copy_m4_m4(Projection, ProjectionStack.stack[ProjectionStack.top - 1]);
} }
void gpuPopProjectionMatrix(void) void GPU_matrix_pop_projection(void)
{ {
BLI_assert(ProjectionStack.top > 0); BLI_assert(ProjectionStack.top > 0);
ProjectionStack.top--; ProjectionStack.top--;
state.dirty = true; state.dirty = true;
} }
void gpuLoadMatrix(const float m[4][4]) void GPU_matrix_set(const float m[4][4])
{ {
copy_m4_m4(ModelView, m); copy_m4_m4(ModelView, m);
CHECKMAT(ModelView3D); CHECKMAT(ModelView3D);
state.dirty = true; state.dirty = true;
} }
void gpuLoadIdentityProjectionMatrix(void) void GPU_matrix_identity_projection_set(void)
{ {
unit_m4(Projection); unit_m4(Projection);
CHECKMAT(Projection3D); CHECKMAT(Projection3D);
state.dirty = true; state.dirty = true;
} }
void gpuLoadProjectionMatrix(const float m[4][4]) void GPU_matrix_projection_set(const float m[4][4])
{ {
copy_m4_m4(Projection, m); copy_m4_m4(Projection, m);
CHECKMAT(Projection3D); CHECKMAT(Projection3D);
state.dirty = true; state.dirty = true;
} }
void gpuLoadIdentity(void) void GPU_matrix_identity_set(void)
{ {
unit_m4(ModelView); unit_m4(ModelView);
state.dirty = true; state.dirty = true;
} }
void gpuTranslate2f(float x, float y) void GPU_matrix_translate_2f(float x, float y)
{ {
Mat4 m; Mat4 m;
unit_m4(m); unit_m4(m);
m[3][0] = x; m[3][0] = x;
m[3][1] = y; m[3][1] = y;
gpuMultMatrix(m); GPU_matrix_mul(m);
} }
void gpuTranslate2fv(const float vec[2]) void GPU_matrix_translate_2fv(const float vec[2])
{ {
gpuTranslate2f(vec[0], vec[1]); GPU_matrix_translate_2f(vec[0], vec[1]);
} }
void gpuTranslate3f(float x, float y, float z) void GPU_matrix_translate_3f(float x, float y, float z)
{ {
#if 1 #if 1
translate_m4(ModelView, x, y, z); translate_m4(ModelView, x, y, z);
@@ -199,61 +199,61 @@ void gpuTranslate3f(float x, float y, float z)
m[3][0] = x; m[3][0] = x;
m[3][1] = y; m[3][1] = y;
m[3][2] = z; m[3][2] = z;
gpuMultMatrix(m); GPU_matrix_mul(m);
#endif #endif
state.dirty = true; state.dirty = true;
} }
void gpuTranslate3fv(const float vec[3]) void GPU_matrix_translate_3fv(const float vec[3])
{ {
gpuTranslate3f(vec[0], vec[1], vec[2]); GPU_matrix_translate_3f(vec[0], vec[1], vec[2]);
} }
void gpuScaleUniform(float factor) void GPU_matrix_scale_1f(float factor)
{ {
Mat4 m; Mat4 m;
scale_m4_fl(m, factor); scale_m4_fl(m, factor);
gpuMultMatrix(m); GPU_matrix_mul(m);
} }
void gpuScale2f(float x, float y) void GPU_matrix_scale_2f(float x, float y)
{ {
Mat4 m = {{0.0f}}; Mat4 m = {{0.0f}};
m[0][0] = x; m[0][0] = x;
m[1][1] = y; m[1][1] = y;
m[2][2] = 1.0f; m[2][2] = 1.0f;
m[3][3] = 1.0f; m[3][3] = 1.0f;
gpuMultMatrix(m); GPU_matrix_mul(m);
} }
void gpuScale2fv(const float vec[2]) void GPU_matrix_scale_2fv(const float vec[2])
{ {
gpuScale2f(vec[0], vec[1]); GPU_matrix_scale_2f(vec[0], vec[1]);
} }
void gpuScale3f(float x, float y, float z) void GPU_matrix_scale_3f(float x, float y, float z)
{ {
Mat4 m = {{0.0f}}; Mat4 m = {{0.0f}};
m[0][0] = x; m[0][0] = x;
m[1][1] = y; m[1][1] = y;
m[2][2] = z; m[2][2] = z;
m[3][3] = 1.0f; m[3][3] = 1.0f;
gpuMultMatrix(m); GPU_matrix_mul(m);
} }
void gpuScale3fv(const float vec[3]) void GPU_matrix_scale_3fv(const float vec[3])
{ {
gpuScale3f(vec[0], vec[1], vec[2]); GPU_matrix_scale_3f(vec[0], vec[1], vec[2]);
} }
void gpuMultMatrix(const float m[4][4]) void GPU_matrix_mul(const float m[4][4])
{ {
mul_m4_m4_post(ModelView, m); mul_m4_m4_post(ModelView, m);
CHECKMAT(ModelView); CHECKMAT(ModelView);
state.dirty = true; state.dirty = true;
} }
void gpuRotate2D(float deg) void GPU_matrix_rotate_2d(float deg)
{ {
/* essentially RotateAxis('Z') /* essentially RotateAxis('Z')
* TODO: simpler math for 2D case * TODO: simpler math for 2D case
@@ -261,20 +261,20 @@ void gpuRotate2D(float deg)
rotate_m4(ModelView, 'Z', DEG2RADF(deg)); rotate_m4(ModelView, 'Z', DEG2RADF(deg));
} }
void gpuRotate3f(float deg, float x, float y, float z) void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
{ {
const float axis[3] = {x, y, z}; const float axis[3] = {x, y, z};
gpuRotate3fv(deg, axis); GPU_matrix_rotate_3fv(deg, axis);
} }
void gpuRotate3fv(float deg, const float axis[3]) void GPU_matrix_rotate_3fv(float deg, const float axis[3])
{ {
Mat4 m; Mat4 m;
axis_angle_to_mat4(m, axis, DEG2RADF(deg)); axis_angle_to_mat4(m, axis, DEG2RADF(deg));
gpuMultMatrix(m); GPU_matrix_mul(m);
} }
void gpuRotateAxis(float deg, char axis) void GPU_matrix_rotate_axis(float deg, char axis)
{ {
/* rotate_m4 works in place */ /* rotate_m4 works in place */
rotate_m4(ModelView, axis, DEG2RADF(deg)); rotate_m4(ModelView, axis, DEG2RADF(deg));
@@ -398,14 +398,14 @@ static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3
state.dirty = true; state.dirty = true;
} }
void gpuOrtho(float left, float right, float bottom, float top, float near, float far) void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
{ {
mat4_ortho_set(Projection, left, right, bottom, top, near, far); mat4_ortho_set(Projection, left, right, bottom, top, near, far);
CHECKMAT(Projection); CHECKMAT(Projection);
state.dirty = true; state.dirty = true;
} }
void gpuOrtho2D(float left, float right, float bottom, float top) void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top)
{ {
Mat4 m; Mat4 m;
mat4_ortho_set(m, left, right, bottom, top, -1.0f, 1.0f); mat4_ortho_set(m, left, right, bottom, top, -1.0f, 1.0f);
@@ -413,21 +413,21 @@ void gpuOrtho2D(float left, float right, float bottom, float top)
state.dirty = true; state.dirty = true;
} }
void gpuFrustum(float left, float right, float bottom, float top, float near, float far) void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far)
{ {
mat4_frustum_set(Projection, left, right, bottom, top, near, far); mat4_frustum_set(Projection, left, right, bottom, top, near, far);
CHECKMAT(Projection); CHECKMAT(Projection);
state.dirty = true; state.dirty = true;
} }
void gpuPerspective(float fovy, float aspect, float near, float far) void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far)
{ {
float half_height = tanf(fovy * (float)(M_PI / 360.0)) * near; float half_height = tanf(fovy * (float)(M_PI / 360.0)) * near;
float half_width = half_height * aspect; float half_width = half_height * aspect;
gpuFrustum(-half_width, +half_width, -half_height, +half_height, near, far); GPU_matrix_frustum_set(-half_width, +half_width, -half_height, +half_height, near, far);
} }
void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
{ {
Mat4 cm; Mat4 cm;
float lookdir[3]; float lookdir[3];
@@ -439,11 +439,11 @@ void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY,
mat4_look_from_origin(cm, lookdir, camup); mat4_look_from_origin(cm, lookdir, camup);
gpuMultMatrix(cm); GPU_matrix_mul(cm);
gpuTranslate3f(-eyeX, -eyeY, -eyeZ); GPU_matrix_translate_3f(-eyeX, -eyeY, -eyeZ);
} }
void gpuProject(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]) void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3])
{ {
float v[4]; float v[4];
@@ -459,7 +459,7 @@ void gpuProject(const float world[3], const float model[4][4], const float proj[
win[2] = (v[2] + 1) * 0.5f; win[2] = (v[2] + 1) * 0.5f;
} }
bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]) bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3])
{ {
float pm[4][4]; float pm[4][4];
float in[4]; float in[4];
@@ -497,7 +497,7 @@ bool gpuUnProject(const float win[3], const float model[4][4], const float proj[
return true; return true;
} }
const float (*gpuGetModelViewMatrix(float m[4][4]))[4] const float (*GPU_matrix_model_view_get(float m[4][4]))[4]
{ {
if (m) { if (m) {
copy_m4_m4(m, ModelView); copy_m4_m4(m, ModelView);
@@ -508,7 +508,7 @@ const float (*gpuGetModelViewMatrix(float m[4][4]))[4]
} }
} }
const float (*gpuGetProjectionMatrix(float m[4][4]))[4] const float (*GPU_matrix_projection_get(float m[4][4]))[4]
{ {
if (m) { if (m) {
copy_m4_m4(m, Projection); copy_m4_m4(m, Projection);
@@ -519,7 +519,7 @@ const float (*gpuGetProjectionMatrix(float m[4][4]))[4]
} }
} }
const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4] const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
{ {
if (m == NULL) { if (m == NULL) {
static Mat4 temp; static Mat4 temp;
@@ -530,14 +530,14 @@ const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4]
return m; return m;
} }
const float (*gpuGetNormalMatrix(float m[3][3]))[3] const float (*GPU_matrix_normal_get(float m[3][3]))[3]
{ {
if (m == NULL) { if (m == NULL) {
static Mat3 temp3; static Mat3 temp3;
m = temp3; m = temp3;
} }
copy_m3_m4(m, (const float (*)[4])gpuGetModelViewMatrix(NULL)); copy_m3_m4(m, (const float (*)[4])GPU_matrix_model_view_get(NULL));
invert_m3(m); invert_m3(m);
transpose_m3(m); transpose_m3(m);
@@ -545,20 +545,20 @@ const float (*gpuGetNormalMatrix(float m[3][3]))[3]
return m; return m;
} }
const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3] const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]
{ {
if (m == NULL) { if (m == NULL) {
static Mat3 temp3; static Mat3 temp3;
m = temp3; m = temp3;
} }
gpuGetNormalMatrix(m); GPU_matrix_normal_get(m);
invert_m3(m); invert_m3(m);
return m; return m;
} }
void gpuBindMatrices(const Gwn_ShaderInterface *shaderface) void GPU_matrix_bind(const Gwn_ShaderInterface *shaderface)
{ {
/* set uniform values to matrix stack values /* set uniform values to matrix stack values
* call this before a draw call if desired matrices are dirty * call this before a draw call if desired matrices are dirty
@@ -578,7 +578,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
puts("setting MV matrix"); puts("setting MV matrix");
#endif #endif
glUniformMatrix4fv(MV->location, 1, GL_FALSE, (const float *)gpuGetModelViewMatrix(NULL)); glUniformMatrix4fv(MV->location, 1, GL_FALSE, (const float *)GPU_matrix_model_view_get(NULL));
} }
if (P) { if (P) {
@@ -586,7 +586,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
puts("setting P matrix"); puts("setting P matrix");
#endif #endif
glUniformMatrix4fv(P->location, 1, GL_FALSE, (const float *)gpuGetProjectionMatrix(NULL)); glUniformMatrix4fv(P->location, 1, GL_FALSE, (const float *)GPU_matrix_projection_get(NULL));
} }
if (MVP) { if (MVP) {
@@ -594,7 +594,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
puts("setting MVP matrix"); puts("setting MVP matrix");
#endif #endif
glUniformMatrix4fv(MVP->location, 1, GL_FALSE, (const float *)gpuGetModelViewProjectionMatrix(NULL)); glUniformMatrix4fv(MVP->location, 1, GL_FALSE, (const float *)GPU_matrix_model_view_projection_get(NULL));
} }
if (N) { if (N) {
@@ -602,19 +602,19 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
puts("setting normal matrix"); puts("setting normal matrix");
#endif #endif
glUniformMatrix3fv(N->location, 1, GL_FALSE, (const float *)gpuGetNormalMatrix(NULL)); glUniformMatrix3fv(N->location, 1, GL_FALSE, (const float *)GPU_matrix_normal_get(NULL));
} }
if (MV_inv) { if (MV_inv) {
Mat4 m; Mat4 m;
gpuGetModelViewMatrix(m); GPU_matrix_model_view_get(m);
invert_m4(m); invert_m4(m);
glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float *)m); glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float *)m);
} }
if (P_inv) { if (P_inv) {
Mat4 m; Mat4 m;
gpuGetProjectionMatrix(m); GPU_matrix_projection_get(m);
invert_m4(m); invert_m4(m);
glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float *)m); glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float *)m);
} }
@@ -622,7 +622,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface)
state.dirty = false; state.dirty = false;
} }
bool gpuMatricesDirty(void) bool GPU_matrix_dirty_get(void)
{ {
return state.dirty; return state.dirty;
} }

View File

@@ -532,7 +532,7 @@ void GPU_shader_bind(GPUShader *shader)
BLI_assert(shader && shader->program); BLI_assert(shader && shader->program);
glUseProgram(shader->program); glUseProgram(shader->program);
gpuBindMatrices(shader->interface); GPU_matrix_bind(shader->interface);
} }
void GPU_shader_unbind(void) void GPU_shader_unbind(void)

View File

@@ -102,7 +102,7 @@ static PyObject *pygpu_matrix_push(PyObject *UNUSED(self))
if (!pygpu_stack_is_push_model_view_ok_or_error()) { if (!pygpu_stack_is_push_model_view_ok_or_error()) {
return NULL; return NULL;
} }
gpuPushMatrix(); GPU_matrix_push();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -116,7 +116,7 @@ static PyObject *pygpu_matrix_pop(PyObject *UNUSED(self))
if (!pygpu_stack_is_pop_model_view_ok_or_error()) { if (!pygpu_stack_is_pop_model_view_ok_or_error()) {
return NULL; return NULL;
} }
gpuPopMatrix(); GPU_matrix_pop();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -130,7 +130,7 @@ static PyObject *pygpu_matrix_push_projection(PyObject *UNUSED(self))
if (!pygpu_stack_is_push_projection_ok_or_error()) { if (!pygpu_stack_is_push_projection_ok_or_error()) {
return NULL; return NULL;
} }
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -144,7 +144,7 @@ static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self))
if (!pygpu_stack_is_pop_projection_ok_or_error()) { if (!pygpu_stack_is_pop_projection_ok_or_error()) {
return NULL; return NULL;
} }
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -197,14 +197,14 @@ static PyObject *pygpu_matrix_stack_context_enter(BPy_GPU_MatrixStackContext *se
if (!pygpu_stack_is_push_model_view_ok_or_error()) { if (!pygpu_stack_is_push_model_view_ok_or_error()) {
return NULL; return NULL;
} }
gpuPushMatrix(); GPU_matrix_push();
self->level = GPU_matrix_stack_level_get_model_view(); self->level = GPU_matrix_stack_level_get_model_view();
} }
else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) { else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
if (!pygpu_stack_is_push_projection_ok_or_error()) { if (!pygpu_stack_is_push_projection_ok_or_error()) {
return NULL; return NULL;
} }
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
self->level = GPU_matrix_stack_level_get_projection(); self->level = GPU_matrix_stack_level_get_projection();
} }
else { else {
@@ -227,7 +227,7 @@ static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *sel
fprintf(stderr, "Level push/pop mismatch, expected %d, got %d\n", self->level, level); fprintf(stderr, "Level push/pop mismatch, expected %d, got %d\n", self->level, level);
} }
if (level != 0) { if (level != 0) {
gpuPopMatrix(); GPU_matrix_pop();
} }
} }
else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) { else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
@@ -236,7 +236,7 @@ static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *sel
fprintf(stderr, "Level push/pop mismatch, expected %d, got %d", self->level, level); fprintf(stderr, "Level push/pop mismatch, expected %d, got %d", self->level, level);
} }
if (level != 0) { if (level != 0) {
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
} }
} }
else { else {
@@ -294,7 +294,7 @@ static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *
if (!Matrix_Parse4x4(value, &pymat)) { if (!Matrix_Parse4x4(value, &pymat)) {
return NULL; return NULL;
} }
gpuMultMatrix(pymat->matrix); GPU_matrix_mul(pymat->matrix);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -314,10 +314,10 @@ static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value)
return NULL; return NULL;
} }
if (len == 2) { if (len == 2) {
gpuScale2fv(scale); GPU_matrix_scale_2fv(scale);
} }
else { else {
gpuScale3fv(scale); GPU_matrix_scale_3fv(scale);
} }
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -337,7 +337,7 @@ static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *va
Py_TYPE(value)->tp_name); Py_TYPE(value)->tp_name);
return NULL; return NULL;
} }
gpuScaleUniform(scalar); GPU_matrix_scale_1f(scalar);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -357,10 +357,10 @@ static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value)
return NULL; return NULL;
} }
if (len == 2) { if (len == 2) {
gpuTranslate2fv(offset); GPU_matrix_translate_2fv(offset);
} }
else { else {
gpuTranslate3fv(offset); GPU_matrix_translate_3fv(offset);
} }
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -378,7 +378,7 @@ PyDoc_STRVAR(pygpu_matrix_reset_doc,
); );
static PyObject *pygpu_matrix_reset(PyObject *UNUSED(self)) static PyObject *pygpu_matrix_reset(PyObject *UNUSED(self))
{ {
gpuMatrixReset(); GPU_matrix_reset();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -389,7 +389,7 @@ PyDoc_STRVAR(pygpu_matrix_load_identity_doc,
); );
static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self)) static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self))
{ {
gpuLoadIdentity(); GPU_matrix_identity_set();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -407,7 +407,7 @@ static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *valu
if (!Matrix_Parse4x4(value, &pymat)) { if (!Matrix_Parse4x4(value, &pymat)) {
return NULL; return NULL;
} }
gpuLoadMatrix(pymat->matrix); GPU_matrix_set(pymat->matrix);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -428,7 +428,7 @@ PyDoc_STRVAR(pygpu_matrix_get_projection_matrix_doc,
static PyObject *pygpu_matrix_get_projection_matrix(PyObject *UNUSED(self)) static PyObject *pygpu_matrix_get_projection_matrix(PyObject *UNUSED(self))
{ {
float matrix[4][4]; float matrix[4][4];
gpuGetModelViewMatrix(matrix); GPU_matrix_model_view_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL); return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
} }
@@ -444,7 +444,7 @@ PyDoc_STRVAR(pygpu_matrix_get_modal_view_matrix_doc,
static PyObject *pygpu_matrix_get_modal_view_matrix(PyObject *UNUSED(self)) static PyObject *pygpu_matrix_get_modal_view_matrix(PyObject *UNUSED(self))
{ {
float matrix[4][4]; float matrix[4][4];
gpuGetProjectionMatrix(matrix); GPU_matrix_projection_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL); return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
} }
@@ -459,7 +459,7 @@ PyDoc_STRVAR(pygpu_matrix_get_normal_matrix_doc,
static PyObject *pygpu_matrix_get_normal_matrix(PyObject *UNUSED(self)) static PyObject *pygpu_matrix_get_normal_matrix(PyObject *UNUSED(self))
{ {
float matrix[3][3]; float matrix[3][3];
gpuGetNormalMatrix(matrix); GPU_matrix_normal_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 3, 3, NULL); return Matrix_CreatePyObject(&matrix[0][0], 3, 3, NULL);
} }

View File

@@ -2118,8 +2118,8 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
/* set up rotation if available */ /* set up rotation if available */
if (rc->rot_prop) { if (rc->rot_prop) {
rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop); rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
gpuPushMatrix(); GPU_matrix_push();
gpuRotate2D(RAD2DEGF(rot)); GPU_matrix_rotate_2d(RAD2DEGF(rot));
} }
/* draw textured quad */ /* draw textured quad */
@@ -2141,7 +2141,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
/* undo rotation */ /* undo rotation */
if (rc->rot_prop) if (rc->rot_prop)
gpuPopMatrix(); GPU_matrix_pop();
} }
else { else {
/* flat color if no texture available */ /* flat color if no texture available */
@@ -2208,7 +2208,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
/* Keep cursor in the original place */ /* Keep cursor in the original place */
x = rc->initial_mouse[0]; x = rc->initial_mouse[0];
y = rc->initial_mouse[1]; y = rc->initial_mouse[1];
gpuTranslate2f((float)x, (float)y); GPU_matrix_translate_2f((float)x, (float)y);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
@@ -2216,7 +2216,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
/* apply zoom if available */ /* apply zoom if available */
if (rc->zoom_prop) { if (rc->zoom_prop) {
RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
gpuScale2fv(zoom); GPU_matrix_scale_2fv(zoom);
} }
/* draw rotated texture */ /* draw rotated texture */
@@ -2233,23 +2233,23 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
immUniformColor3fvAlpha(col, 0.5f); immUniformColor3fvAlpha(col, 0.5f);
if (rc->subtype == PROP_ANGLE) { if (rc->subtype == PROP_ANGLE) {
gpuPushMatrix(); GPU_matrix_push();
/* draw original angle line */ /* draw original angle line */
gpuRotate2D(RAD2DEGF(rc->initial_value)); GPU_matrix_rotate_2d(RAD2DEGF(rc->initial_value));
immBegin(GWN_PRIM_LINES, 2); immBegin(GWN_PRIM_LINES, 2);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f);
immEnd(); immEnd();
/* draw new angle line */ /* draw new angle line */
gpuRotate2D(RAD2DEGF(rc->current_value - rc->initial_value)); GPU_matrix_rotate_2d(RAD2DEGF(rc->current_value - rc->initial_value));
immBegin(GWN_PRIM_LINES, 2); immBegin(GWN_PRIM_LINES, 2);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f);
immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f);
immEnd(); immEnd();
gpuPopMatrix(); GPU_matrix_pop();
} }
/* draw circles on top */ /* draw circles on top */

View File

@@ -201,8 +201,8 @@ static void playanim_window_get_size(int *r_width, int *r_height)
static void playanim_gl_matrix(void) static void playanim_gl_matrix(void)
{ {
/* unified matrix, note it affects offset for drawing */ /* unified matrix, note it affects offset for drawing */
/* note! cannot use gpuOrtho2D here because shader ignores. */ /* note! cannot use GPU_matrix_ortho_2d_set here because shader ignores. */
gpuOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0, 1.0f); GPU_matrix_ortho_set(0.0f, 1.0f, 0.0f, 1.0f, -1.0, 1.0f);
} }
/* implementation */ /* implementation */
@@ -366,10 +366,10 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
float fac = ps->picture->frame / (double)(((PlayAnimPict *)picsbase.last)->frame - ((PlayAnimPict *)picsbase.first)->frame); float fac = ps->picture->frame / (double)(((PlayAnimPict *)picsbase.last)->frame - ((PlayAnimPict *)picsbase.first)->frame);
fac = 2.0f * fac - 1.0f; fac = 2.0f * fac - 1.0f;
gpuPushProjectionMatrix(); GPU_matrix_push_projection();
gpuLoadIdentityProjectionMatrix(); GPU_matrix_identity_projection_set();
gpuPushMatrix(); GPU_matrix_push();
gpuLoadIdentity(); GPU_matrix_identity_set();
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -383,8 +383,8 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
immUnbindProgram(); immUnbindProgram();
gpuPopMatrix(); GPU_matrix_pop();
gpuPopProjectionMatrix(); GPU_matrix_pop_projection();
} }
GHOST_SwapWindowBuffers(g_WS.ghost_window); GHOST_SwapWindowBuffers(g_WS.ghost_window);

View File

@@ -50,7 +50,7 @@ void wmViewport(const rcti *winrct)
glScissor(winrct->xmin, winrct->ymin, width, height); glScissor(winrct->xmin, winrct->ymin, width, height);
wmOrtho2_pixelspace(width, height); wmOrtho2_pixelspace(width, height);
gpuLoadIdentity(); GPU_matrix_identity_set();
} }
void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct) void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct)
@@ -89,7 +89,7 @@ void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct
glScissor(x, y, scissor_width, scissor_height); glScissor(x, y, scissor_width, scissor_height);
wmOrtho2_pixelspace(width, height); wmOrtho2_pixelspace(width, height);
gpuLoadIdentity(); GPU_matrix_identity_set();
} }
void wmWindowViewport(wmWindow *win) void wmWindowViewport(wmWindow *win)
@@ -101,7 +101,7 @@ void wmWindowViewport(wmWindow *win)
glScissor(0, 0, width, height); glScissor(0, 0, width, height);
wmOrtho2_pixelspace(width, height); wmOrtho2_pixelspace(width, height);
gpuLoadIdentity(); GPU_matrix_identity_set();
} }
void wmOrtho2(float x1, float x2, float y1, float y2) void wmOrtho2(float x1, float x2, float y1, float y2)
@@ -110,7 +110,7 @@ void wmOrtho2(float x1, float x2, float y1, float y2)
if (x1 == x2) x2 += 1.0f; if (x1 == x2) x2 += 1.0f;
if (y1 == y2) y2 += 1.0f; if (y1 == y2) y2 += 1.0f;
gpuOrtho(x1, x2, y1, y2, -100, 100); GPU_matrix_ortho_set(x1, x2, y1, y2, -100, 100);
} }
static void wmOrtho2_offset(const float x, const float y, const float ofs) static void wmOrtho2_offset(const float x, const float y, const float ofs)