57e5a33623
Split canvas_texture_storage and texture_storage from render_storage class
96 lines
4.2 KiB
C++
96 lines
4.2 KiB
C++
/*************************************************************************/
|
|
/* canvas_texture_storage.cpp */
|
|
/*************************************************************************/
|
|
/* This file is part of: */
|
|
/* GODOT ENGINE */
|
|
/* https://godotengine.org */
|
|
/*************************************************************************/
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
|
/* */
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
/* a copy of this software and associated documentation files (the */
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
/* the following conditions: */
|
|
/* */
|
|
/* The above copyright notice and this permission notice shall be */
|
|
/* included in all copies or substantial portions of the Software. */
|
|
/* */
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
/*************************************************************************/
|
|
|
|
#ifdef GLES3_ENABLED
|
|
|
|
#include "canvas_texture_storage.h"
|
|
|
|
using namespace GLES3;
|
|
|
|
CanvasTextureStorage *CanvasTextureStorage::singleton = nullptr;
|
|
|
|
CanvasTextureStorage *CanvasTextureStorage::get_singleton() {
|
|
return singleton;
|
|
}
|
|
|
|
CanvasTextureStorage::CanvasTextureStorage() {
|
|
singleton = this;
|
|
}
|
|
|
|
CanvasTextureStorage::~CanvasTextureStorage() {
|
|
singleton = nullptr;
|
|
}
|
|
|
|
RID CanvasTextureStorage::canvas_texture_allocate() {
|
|
return canvas_texture_owner.allocate_rid();
|
|
}
|
|
|
|
void CanvasTextureStorage::canvas_texture_initialize(RID p_rid) {
|
|
canvas_texture_owner.initialize_rid(p_rid);
|
|
}
|
|
|
|
void CanvasTextureStorage::canvas_texture_free(RID p_rid) {
|
|
canvas_texture_owner.free(p_rid);
|
|
}
|
|
|
|
void CanvasTextureStorage::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) {
|
|
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
|
|
switch (p_channel) {
|
|
case RS::CANVAS_TEXTURE_CHANNEL_DIFFUSE: {
|
|
ct->diffuse = p_texture;
|
|
} break;
|
|
case RS::CANVAS_TEXTURE_CHANNEL_NORMAL: {
|
|
ct->normal_map = p_texture;
|
|
} break;
|
|
case RS::CANVAS_TEXTURE_CHANNEL_SPECULAR: {
|
|
ct->specular = p_texture;
|
|
} break;
|
|
}
|
|
}
|
|
|
|
void CanvasTextureStorage::canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_specular_color, float p_shininess) {
|
|
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
|
|
ct->specular_color.r = p_specular_color.r;
|
|
ct->specular_color.g = p_specular_color.g;
|
|
ct->specular_color.b = p_specular_color.b;
|
|
ct->specular_color.a = p_shininess;
|
|
}
|
|
|
|
void CanvasTextureStorage::canvas_texture_set_texture_filter(RID p_canvas_texture, RS::CanvasItemTextureFilter p_filter) {
|
|
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
|
|
ct->texture_filter = p_filter;
|
|
}
|
|
|
|
void CanvasTextureStorage::canvas_texture_set_texture_repeat(RID p_canvas_texture, RS::CanvasItemTextureRepeat p_repeat) {
|
|
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
|
|
ct->texture_repeat = p_repeat;
|
|
}
|
|
|
|
#endif // !GLES3_ENABLED
|