Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/editors/image_uv_editor.c
- This file was added.
| /* | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License | |||||
| * as published by the Free Software Foundation; either version 2 | |||||
| * of the License, or (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software Foundation, | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| * | |||||
| * Copyright 2016, Blender Foundation. | |||||
| */ | |||||
| /** \file | |||||
| * \ingroup draw_editors | |||||
| * | |||||
| * Draw engine to draw the Image/UV editor | |||||
| */ | |||||
| #include "DRW_render.h" | |||||
| #include "GPU_batch.h" | |||||
| #include "GPU_shader.h" | |||||
| #include "image_uv_editor.h" | |||||
| /* Shaders */ | |||||
| /* *********** LISTS *********** */ | |||||
| /* GPUViewport.storage | |||||
| * Is freed everytime the viewport engine changes */ | |||||
| typedef struct IMAGE_UV_EDITOR_StorageList { | |||||
| struct IMAGE_UV_EDITOR_PrivateData *g_data; | |||||
| } IMAGE_UV_EDITOR_StorageList; | |||||
| typedef struct IMAGE_UV_EDITOR_PassList { | |||||
| DRWPass *image_pass; | |||||
| } IMAGE_UV_EDITOR_PassList; | |||||
| typedef struct IMAGE_UV_EDITOR_Data { | |||||
| void *engine_type; | |||||
| DRWViewportEmptyList *fbl; | |||||
| DRWViewportEmptyList *txl; | |||||
| IMAGE_UV_EDITOR_PassList *psl; | |||||
| IMAGE_UV_EDITOR_StorageList *stl; | |||||
| } IMAGE_UV_EDITOR_Data; | |||||
| typedef struct IMAGE_UV_EDITOR_Shaders { | |||||
| } IMAGE_UV_EDITOR_Shaders; | |||||
| /* *********** STATIC *********** */ | |||||
| static struct { | |||||
| int flag; | |||||
| float image_mat[4][4]; | |||||
| } e_data = {0}; /* Engine data */ | |||||
| /* Functions */ | |||||
| static void image_uv_editor_init(void *UNUSED(vedata)) | |||||
| { | |||||
| } | |||||
| static void image_uv_editor_cache_init(void *vedata) | |||||
| { | |||||
| IMAGE_UV_EDITOR_Data *ied = (IMAGE_UV_EDITOR_Data *)vedata; | |||||
| IMAGE_UV_EDITOR_PassList *psl = ied->psl; | |||||
| { | |||||
| psl->image_pass = DRW_pass_create("Image", DRW_STATE_DEFAULT); | |||||
| // GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE); | |||||
| GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR); | |||||
| DRWShadingGroup *shgrp = DRW_shgroup_create(shader, psl->image_pass); | |||||
| const float color[3] = {1.0, 0.0, 0.5}; | |||||
| DRW_shgroup_uniform_vec3_copy(shgrp, "color", color); | |||||
| GPUBatch *batch = DRW_cache_image_plane_get(); | |||||
| unit_m4(e_data.image_mat); | |||||
| scale_m4_fl(e_data.image_mat, 100); | |||||
| DRW_shgroup_call_obmat(shgrp, batch, e_data.image_mat); | |||||
| } | |||||
| } | |||||
| static void image_uv_editor_cache_populate(void *vedata, Object *ob) | |||||
| { | |||||
| } | |||||
| static void image_uv_editor_cache_finish(void *vedata) | |||||
| { | |||||
| } | |||||
| static void image_uv_editor_draw_background(void *vedata) | |||||
| { | |||||
| // static float clearcol[4] = {1.0f, 0.0f, 1.0f, 1.0f}; | |||||
| // DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | |||||
| // GPU_framebuffer_clear_color(dfbl->default_fb, clearcol); | |||||
| } | |||||
| static void image_uv_editor_draw_scene(void *vedata) | |||||
| { | |||||
| IMAGE_UV_EDITOR_Data *ied = (IMAGE_UV_EDITOR_Data *)vedata; | |||||
| IMAGE_UV_EDITOR_PassList *psl = ied->psl; | |||||
| DRW_draw_pass(psl->image_pass); | |||||
| } | |||||
| static void image_uv_editor_free(void) | |||||
| { | |||||
| } | |||||
| static const DrawEngineDataSize image_uv_editor_data_size = DRW_VIEWPORT_DATA_SIZE( | |||||
| IMAGE_UV_EDITOR_Data); | |||||
| DrawEngineType draw_engine_image_uv_editor_type = { | |||||
| NULL, | |||||
| NULL, | |||||
| N_("Image/UV Editor"), | |||||
| &image_uv_editor_data_size, | |||||
| &image_uv_editor_init, | |||||
| &image_uv_editor_free, | |||||
| &image_uv_editor_cache_init, | |||||
| &image_uv_editor_cache_populate, | |||||
| &image_uv_editor_cache_finish, | |||||
| &image_uv_editor_draw_background, | |||||
| &image_uv_editor_draw_scene, | |||||
| NULL, | |||||
| NULL, | |||||
| NULL, | |||||
| }; | |||||