Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
2.4 kB · 56 lines
C++
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include "LayerRenderingContext.h"#include "../ManagementContext/LayerManagmentContext.h"
Texture* LayerRenderingContext::CompositeAll(std::vector<LayerNode*> layers) // TODO: remove parameter{ if (!finalComposite) { SDL_GPUTextureCreateInfo creationInfo = {}; creationInfo.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; // TODO: make this configurable creationInfo.width = LayerManagementContext::FinalWidth; creationInfo.height = LayerManagementContext::FinalHeight; creationInfo.layer_count_or_depth = 1; creationInfo.num_levels = 1; creationInfo.sample_count = SDL_GPU_SAMPLECOUNT_1; creationInfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER; finalComposite = new Texture(creationInfo); } finalComposite->Clear({ 0.0f, 0.0f, 0.0f, 0.0f }); for (auto layer : layers) { layer->Composite(finalComposite); } return finalComposite;}
#include "../LayerNodes/PaintLayerNode.h"Texture* LayerRenderingContext::CompositeReplacedSelectedLayer(Texture* replacement){ if (!finalComposite) { SDL_GPUTextureCreateInfo creationInfo = {}; creationInfo.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; // TODO: make this configurable creationInfo.width = LayerManagementContext::FinalWidth; creationInfo.height = LayerManagementContext::FinalHeight; creationInfo.layer_count_or_depth = 1; creationInfo.num_levels = 1; creationInfo.sample_count = SDL_GPU_SAMPLECOUNT_1; creationInfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER; finalComposite = new Texture(creationInfo); } finalComposite->Clear({ 0.0f, 0.0f, 0.0f, 0.0f }); for (auto layer : LayerManagementContext::Layers) { if (layer == LayerManagementContext::SelectedLayer) { PaintLayerNode* paintLayer = new PaintLayerNode(); paintLayer->Target = replacement; paintLayer->BlendMode = LayerManagementContext::SelectedLayer->BlendMode; paintLayer->Opacity = LayerManagementContext::SelectedLayer->Opacity; paintLayer->Composite(finalComposite); paintLayer->Target = nullptr; delete paintLayer; } else { layer->Composite(finalComposite); } } return finalComposite;}