Make image drawing code working with core profile
The issue was caused here by usage of deprecated GL_CURRENT_PROGRAM which was returning rubbish value. Now we use imm API and create vertex format prior to immBindProgram. This made us required to have some sort of state passed from setup function to actual drawing.
This commit is contained in:
parent
35ee9db1e2
commit
5a4fceff1b
|
@ -67,10 +67,16 @@ int glaGetOneInt(int param);
|
|||
*/
|
||||
void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y);
|
||||
|
||||
typedef struct IMMDrawPixelsTexState {
|
||||
struct GPUShader *shader;
|
||||
unsigned int pos;
|
||||
unsigned int texco;
|
||||
} IMMDrawPixelsTexState;
|
||||
|
||||
/* To be used before calling immDrawPixelsTex
|
||||
* Default shader is GPU_SHADER_2D_IMAGE_COLOR
|
||||
* Returns a shader to be able to set uniforms */
|
||||
struct GPUShader *immDrawPixelsTexSetup(int builtin);
|
||||
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin);
|
||||
|
||||
/**
|
||||
* immDrawPixelsTex - Functions like a limited glDrawPixels, but actually draws the
|
||||
|
@ -86,14 +92,18 @@ struct GPUShader *immDrawPixelsTexSetup(int builtin);
|
|||
* modelview and projection matrices are assumed to define a
|
||||
* 1-to-1 mapping to screen space.
|
||||
*/
|
||||
void immDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
|
||||
void immDrawPixelsTex(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
|
||||
float xzoom, float yzoom, float color[4]);
|
||||
void immDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
|
||||
void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
|
||||
float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y,
|
||||
float xzoom, float yzoom, float color[4]);
|
||||
void immDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY,
|
||||
float xzoom, float yzoom, float color[4]);
|
||||
void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY,
|
||||
void immDrawPixelsTexScaled(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY,
|
||||
float xzoom, float yzoom, float color[4]);
|
||||
void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY,
|
||||
float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y,
|
||||
float xzoom, float yzoom, float color[4]);
|
||||
/* 2D Drawing Assistance */
|
||||
|
|
|
@ -560,8 +560,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
|
|||
facy = (float)h / (float)ibuf->y;
|
||||
}
|
||||
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, (float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect,
|
||||
facx, facy, NULL);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
@ -1788,8 +1788,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
UI_draw_roundbox_4fv(true, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
|
||||
}
|
||||
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
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 */
|
||||
gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
|
||||
|
|
|
@ -1005,8 +1005,8 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
|
|||
}
|
||||
|
||||
/* draw */
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect,
|
||||
1.0f, 1.0f, col);
|
||||
|
||||
if (ima)
|
||||
|
|
|
@ -769,9 +769,9 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
|
|||
if (stabmat) {
|
||||
gpuMultMatrix3D(stabmat); /* XXX make this a 2D matrix */
|
||||
}
|
||||
GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red);
|
||||
immDrawPixelsTex(0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL);
|
||||
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);
|
||||
immDrawPixelsTex(&state, 0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL);
|
||||
|
||||
gpuPopMatrix();
|
||||
|
||||
|
|
|
@ -1538,8 +1538,8 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
|
|||
if (force_fallback == false) {
|
||||
if (IMB_colormanagement_setup_glsl_draw(&scene->view_settings, &scene->display_settings, dither, true)) {
|
||||
glEnable(GL_BLEND);
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(xof, yof, rres.rectx, rres.recty,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, xof, yof, rres.rectx, rres.recty,
|
||||
GL_RGBA, GL_FLOAT, GL_NEAREST, rres.rectf,
|
||||
scale_x, scale_y, NULL);;
|
||||
glDisable(GL_BLEND);
|
||||
|
@ -1558,8 +1558,8 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
|
|||
4, dither, &scene->view_settings, &scene->display_settings);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(xof, yof, rres.rectx, rres.recty,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, xof, yof, rres.rectx, rres.recty,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
GL_NEAREST, display_buffer,
|
||||
scale_x, scale_y, NULL);
|
||||
|
|
|
@ -600,8 +600,8 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
|
|||
if (re)
|
||||
RE_AcquiredResultGet32(re, &rres, (unsigned int *)rect_byte, 0);
|
||||
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(fx, fy, rres.rectx, rres.recty, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect_byte,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, fx, fy, rres.rectx, rres.recty, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect_byte,
|
||||
1.0f, 1.0f, NULL);
|
||||
|
||||
MEM_freeN(rect_byte);
|
||||
|
|
|
@ -137,19 +137,33 @@ static int get_cached_work_texture(int *r_w, int *r_h)
|
|||
return texid;
|
||||
}
|
||||
|
||||
static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state)
|
||||
{
|
||||
VertexFormat *vert_format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(vert_format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int texco = VertexFormat_add_attrib(vert_format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
state->pos = pos;
|
||||
state->texco = texco;
|
||||
}
|
||||
|
||||
/* To be used before calling immDrawPixelsTex
|
||||
* Default shader is GPU_SHADER_2D_IMAGE_COLOR
|
||||
* You can still set uniforms with :
|
||||
* GPU_shader_uniform_int(shader, GPU_shader_get_uniform(shader, "name"), 0);
|
||||
* */
|
||||
GPUShader *immDrawPixelsTexSetup(int builtin)
|
||||
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
|
||||
{
|
||||
IMMDrawPixelsTexState state;
|
||||
immDrawPixelsTexSetupAttributes(&state);
|
||||
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader(builtin);
|
||||
/* Shader will be unbind by immUnbindProgram in immDrawPixelsTexScaled_clipping */
|
||||
GPU_shader_bind(shader);
|
||||
immBindBuiltinProgram(builtin);
|
||||
GPU_shader_uniform_int(shader, GPU_shader_get_uniform(shader, "image"), 0);
|
||||
|
||||
return shader;
|
||||
state.shader = shader;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/* Use the currently bound shader.
|
||||
|
@ -165,7 +179,8 @@ GPUShader *immDrawPixelsTexSetup(int builtin)
|
|||
* Be also aware that this function unbinds the shader when
|
||||
* it's finished.
|
||||
* */
|
||||
void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h,
|
||||
void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h,
|
||||
int format, int type, int zoomfilter, void *rect,
|
||||
float scaleX, float scaleY,
|
||||
float clip_min_x, float clip_min_y,
|
||||
|
@ -229,25 +244,15 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h,
|
|||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, format, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
|
||||
VertexFormat *vert_format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(vert_format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int texco = VertexFormat_add_attrib(vert_format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = 0, texco = 1;
|
||||
|
||||
unsigned int program = glaGetOneInt(GL_CURRENT_PROGRAM);
|
||||
|
||||
/* This is needed for the OCIO case.
|
||||
* Shader program is set outside of blender and
|
||||
* we need it in imm module to do all attrib /
|
||||
* uniform bindings. */
|
||||
|
||||
/* A program is already bound.
|
||||
* set it in imm.bound_program to be able to use imm functions */
|
||||
BLI_assert(program);
|
||||
immBindProgram(program);
|
||||
|
||||
/* optionnal */
|
||||
if (glGetUniformLocation(program, "color") != -1)
|
||||
/* optional */
|
||||
/* NOTE: Shader could be null for GLSL OCIO drawing, it is fine, since
|
||||
* it does not need color.
|
||||
*/
|
||||
if (state->shader != NULL && GPU_shader_get_uniform(state->shader, "color") != -1) {
|
||||
immUniform4fv("color", (color) ? color : white);
|
||||
}
|
||||
|
||||
for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) {
|
||||
for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) {
|
||||
|
@ -322,27 +327,30 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h,
|
|||
glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length);
|
||||
}
|
||||
|
||||
void immDrawPixelsTexScaled(float x, float y, int img_w, int img_h,
|
||||
void immDrawPixelsTexScaled(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h,
|
||||
int format, int type, int zoomfilter, void *rect,
|
||||
float scaleX, float scaleY, float xzoom, float yzoom, float color[4])
|
||||
{
|
||||
immDrawPixelsTexScaled_clipping(x, y, img_w, img_h, format, type, zoomfilter, rect,
|
||||
immDrawPixelsTexScaled_clipping(state, x, y, img_w, img_h, format, type, zoomfilter, rect,
|
||||
scaleX, scaleY, 0.0f, 0.0f, 0.0f, 0.0f, xzoom, yzoom, color);
|
||||
}
|
||||
|
||||
void immDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
|
||||
void immDrawPixelsTex(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
|
||||
float xzoom, float yzoom, float color[4])
|
||||
{
|
||||
immDrawPixelsTexScaled_clipping(x, y, img_w, img_h, format, type, zoomfilter, rect, 1.0f, 1.0f,
|
||||
immDrawPixelsTexScaled_clipping(state, x, y, img_w, img_h, format, type, zoomfilter, rect, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, xzoom, yzoom, color);
|
||||
}
|
||||
|
||||
void immDrawPixelsTex_clipping(float x, float y, int img_w, int img_h,
|
||||
void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state,
|
||||
float x, float y, int img_w, int img_h,
|
||||
int format, int type, int zoomfilter, void *rect,
|
||||
float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y,
|
||||
float xzoom, float yzoom, float color[4])
|
||||
{
|
||||
immDrawPixelsTexScaled_clipping(x, y, img_w, img_h, format, type, zoomfilter, rect, 1.0f, 1.0f,
|
||||
immDrawPixelsTexScaled_clipping(state, x, y, img_w, img_h, format, type, zoomfilter, rect, 1.0f, 1.0f,
|
||||
clip_min_x, clip_min_y, clip_max_x, clip_max_y, xzoom, yzoom, color);
|
||||
}
|
||||
|
||||
|
@ -575,6 +583,9 @@ void glaDrawImBuf_glsl_clipping(ImBuf *ibuf, float x, float y, int zoomfilter,
|
|||
if (force_fallback == false) {
|
||||
int ok;
|
||||
|
||||
IMMDrawPixelsTexState state = {0};
|
||||
immDrawPixelsTexSetupAttributes(&state);
|
||||
|
||||
if (ibuf->rect_float) {
|
||||
if (ibuf->float_colorspace) {
|
||||
ok = IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings,
|
||||
|
@ -604,7 +615,8 @@ void glaDrawImBuf_glsl_clipping(ImBuf *ibuf, float x, float y, int zoomfilter,
|
|||
BLI_assert(!"Incompatible number of channels for GLSL display");
|
||||
|
||||
if (format != 0) {
|
||||
immDrawPixelsTex_clipping(x, y, ibuf->x, ibuf->y, format, GL_FLOAT,
|
||||
immDrawPixelsTex_clipping(&state,
|
||||
x, y, ibuf->x, ibuf->y, format, GL_FLOAT,
|
||||
zoomfilter, ibuf->rect_float,
|
||||
clip_min_x, clip_min_y, clip_max_x, clip_max_y,
|
||||
zoom_x, zoom_y, NULL);
|
||||
|
@ -612,7 +624,8 @@ void glaDrawImBuf_glsl_clipping(ImBuf *ibuf, float x, float y, int zoomfilter,
|
|||
}
|
||||
else if (ibuf->rect) {
|
||||
/* ibuf->rect is always RGBA */
|
||||
immDrawPixelsTex_clipping(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
immDrawPixelsTex_clipping(&state,
|
||||
x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
zoomfilter, ibuf->rect,
|
||||
clip_min_x, clip_min_y, clip_max_x, clip_max_y,
|
||||
zoom_x, zoom_y, NULL);
|
||||
|
@ -632,8 +645,9 @@ void glaDrawImBuf_glsl_clipping(ImBuf *ibuf, float x, float y, int zoomfilter,
|
|||
display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, display_settings, &cache_handle);
|
||||
|
||||
if (display_buffer) {
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex_clipping(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex_clipping(&state,
|
||||
x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
zoomfilter, display_buffer,
|
||||
clip_min_x, clip_min_y, clip_max_x, clip_max_y,
|
||||
zoom_x, zoom_y, NULL);
|
||||
|
|
|
@ -389,8 +389,8 @@ static void file_draw_preview(
|
|||
UI_GetThemeColor4fv(TH_TEXT, col);
|
||||
}
|
||||
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTexScaled(&state, (float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect,
|
||||
scale, scale, 1.0f, 1.0f, col);
|
||||
|
||||
if (icon) {
|
||||
|
|
|
@ -432,10 +432,10 @@ static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int
|
|||
recti[a] = rect[a] * 0.5f + 0.5f;
|
||||
}
|
||||
|
||||
GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red);
|
||||
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);
|
||||
|
||||
immDrawPixelsTex(x1, y1, rectx, recty, GL_RED, GL_INT, GL_NEAREST, recti, zoomx, zoomy, NULL);
|
||||
immDrawPixelsTex(&state, x1, y1, rectx, recty, GL_RED, GL_INT, GL_NEAREST, recti, zoomx, zoomy, NULL);
|
||||
|
||||
MEM_freeN(recti);
|
||||
}
|
||||
|
@ -470,10 +470,10 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec
|
|||
}
|
||||
}
|
||||
|
||||
GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red);
|
||||
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);
|
||||
|
||||
immDrawPixelsTex(x1, y1, rectx, recty, GL_RED, GL_FLOAT, GL_NEAREST, rectf, zoomx, zoomy, NULL);
|
||||
immDrawPixelsTex(&state, x1, y1, rectx, recty, GL_RED, GL_FLOAT, GL_NEAREST, rectf, zoomx, zoomy, NULL);
|
||||
|
||||
MEM_freeN(rectf);
|
||||
}
|
||||
|
@ -531,14 +531,14 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
|
|||
else if (sima->flag & SI_SHOW_ALPHA)
|
||||
shuffle[3] = 1.0f;
|
||||
|
||||
GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, shuffle);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle);
|
||||
|
||||
IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings);
|
||||
display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, display_settings, &cache_handle);
|
||||
|
||||
if (display_buffer) {
|
||||
immDrawPixelsTex_clipping(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer,
|
||||
immDrawPixelsTex_clipping(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer,
|
||||
0, 0, clip_max_x, clip_max_y, zoomx, zoomy, NULL);
|
||||
}
|
||||
|
||||
|
@ -619,14 +619,14 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
|
|||
UI_view2d_view_to_region(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y);
|
||||
|
||||
if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) == 0) {
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
|
||||
}
|
||||
else {
|
||||
GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, shuffle);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle);
|
||||
|
||||
immDrawPixelsTex(x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
|
||||
immDrawPixelsTex(&state, x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -734,8 +734,8 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer, zoomx, zoomy, col);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer, zoomx, zoomy, col);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
|
|
@ -3204,10 +3204,10 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
|||
else
|
||||
shuffle[3] = 1.0f;
|
||||
|
||||
GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, shuffle);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle);
|
||||
|
||||
immDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST,
|
||||
immDrawPixelsTex(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST,
|
||||
display_buffer, snode->zoom, snode->zoom, NULL);
|
||||
|
||||
GPU_shader_unbind();
|
||||
|
|
|
@ -706,8 +706,8 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */
|
||||
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect,
|
||||
scale, scale, NULL);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
|
|
@ -773,8 +773,8 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
|
|||
}
|
||||
|
||||
float col[4] = {1.0f, 1.0f, 1.0f, 1.0f - bgpic->blend};
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect,
|
||||
zoomx, zoomy, col);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
|
|
@ -335,8 +335,8 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
|
|||
drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy);
|
||||
else {
|
||||
float col[4] = {1.0f, 1.0f, 1.0f, 0.65f}; /* this blends texture */
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST,
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTexScaled(&state, x, y, drag->imb->x, drag->imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST,
|
||||
drag->imb->rect, drag->scale, drag->scale, 1.0f, 1.0f, col);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -367,11 +367,11 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
|
|||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
GPUShader *shader = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_bind(shader);
|
||||
GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "shuffle"), 4, 1, red);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_bind(state.shader);
|
||||
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red);
|
||||
|
||||
immDrawPixelsTex(rect.xmin, rect.ymin, w, h, GL_RED, GL_UNSIGNED_BYTE, GL_NEAREST, pixel_buf, 1.0f, 1.0f, NULL);
|
||||
immDrawPixelsTex(&state, rect.xmin, rect.ymin, w, h, GL_RED, GL_UNSIGNED_BYTE, GL_NEAREST, pixel_buf, 1.0f, 1.0f, NULL);
|
||||
|
||||
GPU_shader_unbind();
|
||||
|
||||
|
|
|
@ -322,9 +322,10 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
|
|||
imm_draw_checker_box(offs_x, offs_y, offs_x + span_x, offs_y + span_y);
|
||||
}
|
||||
|
||||
immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
|
||||
immDrawPixelsTex(
|
||||
&state,
|
||||
offs_x + (ps->draw_flip[0] ? span_x : 0.0f),
|
||||
offs_y + (ps->draw_flip[1] ? span_y : 0.0f),
|
||||
ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST,
|
||||
|
|
Loading…
Reference in New Issue