Cleanup: WM: Use GPUTexture for radial control drawing
This commit is contained in:
parent
2d9eee15c5
commit
e2305690eb
|
@ -2120,7 +2120,7 @@ typedef struct {
|
|||
int slow_mouse[2];
|
||||
bool slow_mode;
|
||||
Dial *dial;
|
||||
unsigned int gltex;
|
||||
GPUTexture *texture;
|
||||
ListBase orig_paintcursors;
|
||||
bool use_secondary_tex;
|
||||
void *cursor;
|
||||
|
@ -2224,11 +2224,15 @@ static void radial_control_set_tex(RadialControl *rc)
|
|||
rc->image_id_ptr.data,
|
||||
rc->use_secondary_tex,
|
||||
!ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) {
|
||||
glGenTextures(1, &rc->gltex);
|
||||
glBindTexture(GL_TEXTURE_2D, rc->gltex);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0, GL_R8, ibuf->x, ibuf->y, 0, GL_RED, GL_FLOAT, ibuf->rect_float);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
rc->texture = GPU_texture_create_nD(
|
||||
ibuf->x, ibuf->y, 0, 2, ibuf->rect_float, GPU_R8, GPU_DATA_FLOAT, 0, false, NULL);
|
||||
GPU_texture_filter_mode(rc->texture, true);
|
||||
|
||||
GPU_texture_bind(rc->texture, 0);
|
||||
GPU_texture_swizzle_set(rc->texture, "111r");
|
||||
GPU_texture_unbind(rc->texture);
|
||||
|
||||
MEM_freeN(ibuf->rect_float);
|
||||
MEM_freeN(ibuf);
|
||||
}
|
||||
|
@ -2264,19 +2268,9 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
|
|||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
|
||||
if (rc->gltex) {
|
||||
|
||||
if (rc->texture) {
|
||||
uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, rc->gltex);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
GLint swizzleMask[] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED};
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||
|
||||
/* set up rotation if available */
|
||||
if (rc->rot_prop) {
|
||||
rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
|
||||
|
@ -2284,10 +2278,10 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
|
|||
GPU_matrix_rotate_2d(RAD2DEGF(rot));
|
||||
}
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
|
||||
immUniformColor3fvAlpha(col, alpha);
|
||||
immUniform1i("image", 0);
|
||||
immBindTexture("image", rc->texture);
|
||||
|
||||
/* draw textured quad */
|
||||
immBegin(GPU_PRIM_TRI_FAN, 4);
|
||||
|
@ -2306,6 +2300,8 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
|
|||
|
||||
immEnd();
|
||||
|
||||
GPU_texture_unbind(rc->texture);
|
||||
|
||||
/* undo rotation */
|
||||
if (rc->rot_prop) {
|
||||
GPU_matrix_pop();
|
||||
|
@ -2803,7 +2799,7 @@ static void radial_control_cancel(bContext *C, wmOperator *op)
|
|||
* new value is displayed in sliders/numfields */
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
|
||||
glDeleteTextures(1, &rc->gltex);
|
||||
GPU_texture_free(rc->texture);
|
||||
|
||||
MEM_freeN(rc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue