[Bf-blender-cvs] [efc499cb99] blender2.8: OpenGL immediate mode: paint_stroke.c
Clément Foucault
noreply at git.blender.org
Wed Feb 22 18:22:10 CET 2017
Commit: efc499cb991f1a432632d7c3a38070d36a3168b4
Author: Clément Foucault
Date: Wed Feb 22 18:19:42 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBefc499cb991f1a432632d7c3a38070d36a3168b4
OpenGL immediate mode: paint_stroke.c
===================================================================
M source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 05270dbfa0..38827b16e3 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -58,7 +58,7 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
-#include "GPU_basic_shader.h"
+#include "GPU_immediate.h"
#include "ED_screen.h"
#include "ED_view3d.h"
@@ -145,9 +145,17 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata
if (stroke && brush) {
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glColor4ubv(paint->paint_cursor_col);
- sdrawline(x, y, (int)stroke->last_mouse_position[0],
- (int)stroke->last_mouse_position[1]);
+
+ unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4ubv(paint->paint_cursor_col);
+
+ immBegin(GL_LINES, 2);
+ imm_draw_line(pos, x, y, stroke->last_mouse_position[0],
+ stroke->last_mouse_position[1]);
+ immEnd();
+ immUnbindProgram();
+
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
}
@@ -161,32 +169,35 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
- GPU_basic_shader_line_stipple(3, 0xAAAA);
- GPU_basic_shader_line_width(3.0);
+ setlinestyle(3);
+ glLineWidth(3.0f);
- glColor4ub(0, 0, 0, paint->paint_cursor_col[3]);
+ unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ immUniformColor4ub(0, 0, 0, paint->paint_cursor_col[3]);
if (stroke->constrain_line) {
- sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1],
+ imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1],
stroke->constrained_pos[0], stroke->constrained_pos[1]);
}
else {
- sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1],
+ imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1],
x, y);
}
- glColor4ub(255, 255, 255, paint->paint_cursor_col[3]);
- GPU_basic_shader_line_width(1.0);
+ glLineWidth(1.0f);
+ immUniformColor4ub(255, 255, 255, paint->paint_cursor_col[3]);
if (stroke->constrain_line) {
- sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1],
+ imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1],
stroke->constrained_pos[0], stroke->constrained_pos[1]);
}
else {
- sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1],
+ imm_draw_line(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1],
x, y);
}
+ immUnbindProgram();
- GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+ setlinestyle(0);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
More information about the Bf-blender-cvs
mailing list