Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/glutil.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state) | static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state) | ||||
| { | { | ||||
| GPUVertFormat *vert_format = immVertexFormat(); | GPUVertFormat *vert_format = immVertexFormat(); | ||||
| state->pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | state->pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| state->texco = GPU_vertformat_attr_add( | state->texco = GPU_vertformat_attr_add( | ||||
| vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| } | } | ||||
| /* To be used before calling immDrawPixelsTex | /** | ||||
| * Default shader is GPU_SHADER_2D_IMAGE_COLOR | * To be used before calling #immDrawPixelsTex | ||||
| * Default shader is #GPU_SHADER_2D_IMAGE_COLOR | |||||
| * You can still set uniforms with : | * You can still set uniforms with: | ||||
| * GPU_shader_uniform_int(shader, GPU_shader_get_uniform(shader, "name"), 0); | * `GPU_shader_uniform_int(shader, GPU_shader_get_uniform(shader, "name"), 0);` | ||||
| * */ | */ | ||||
| IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin) | IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin) | ||||
| { | { | ||||
| IMMDrawPixelsTexState state; | IMMDrawPixelsTexState state; | ||||
| immDrawPixelsTexSetupAttributes(&state); | immDrawPixelsTexSetupAttributes(&state); | ||||
| state.shader = GPU_shader_get_builtin_shader(builtin); | state.shader = GPU_shader_get_builtin_shader(builtin); | ||||
| /* Shader will be unbind by immUnbindProgram in immDrawPixelsTexScaled_clipping */ | /* Shader will be unbind by immUnbindProgram in immDrawPixelsTexScaled_clipping */ | ||||
| immBindBuiltinProgram(builtin); | immBindBuiltinProgram(builtin); | ||||
| immUniform1i("image", 0); | immUniform1i("image", 0); | ||||
| state.do_shader_unbind = true; | state.do_shader_unbind = true; | ||||
| return state; | return state; | ||||
| } | } | ||||
| /* Use the currently bound shader. | /** | ||||
| * Use the currently bound shader. | |||||
| * | * | ||||
| * Use immDrawPixelsTexSetup to bind the shader you | * Use #immDrawPixelsTexSetup to bind the shader you | ||||
| * want before calling immDrawPixelsTex. | * want before calling #immDrawPixelsTex. | ||||
| * | * | ||||
| * If using a special shader double check it uses the same | * If using a special shader double check it uses the same | ||||
| * attributes "pos" "texCoord" and uniform "image". | * attributes "pos" "texCoord" and uniform "image". | ||||
| * | * | ||||
| * If color is NULL then use white by default | * If color is NULL then use white by default | ||||
| * | * | ||||
| * Be also aware that this function unbinds the shader when | * Be also aware that this function unbinds the shader when | ||||
| * it's finished. | * it's finished. | ||||
| * */ | */ | ||||
| void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, | void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, | ||||
| float x, | float x, | ||||
| float y, | float y, | ||||
| int img_w, | int img_w, | ||||
| int img_h, | int img_h, | ||||
| eGPUTextureFormat gpu_format, | eGPUTextureFormat gpu_format, | ||||
| bool use_filter, | bool use_filter, | ||||
| void *rect, | void *rect, | ||||
| ▲ Show 20 Lines • Show All 515 Lines • Show Last 20 Lines | |||||