//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// #include "BsRenderTargetEx.h" #include "BsScriptShaderParameter.generated.h" namespace bs { UINT32 RenderTargetEx::getWidth(const SPtr& thisPtr) { return thisPtr->getProperties().width; } UINT32 RenderTargetEx::getHeight(const SPtr& thisPtr) { return thisPtr->getProperties().height; } bool RenderTargetEx::getGammaCorrection(const SPtr& thisPtr) { return thisPtr->getProperties().hwGamma; } INT32 RenderTargetEx::getPriority(const SPtr& thisPtr) { return thisPtr->getProperties().priority; } void RenderTargetEx::setPriority(const SPtr& thisPtr, INT32 priority) { thisPtr->setPriority(priority); } UINT32 RenderTargetEx::getSampleCount(const SPtr& thisPtr) { return thisPtr->getProperties().multisampleCount; } SPtr RenderTextureEx::create(PixelFormat format, int width, int height, int numSamples, bool gammaCorrection, bool createDepth, PixelFormat depthStencilFormat) { TEXTURE_DESC texDesc; texDesc.type = TEX_TYPE_2D; texDesc.width = width; texDesc.height = height; texDesc.format = format; texDesc.hwGamma = gammaCorrection; texDesc.numSamples = numSamples; return RenderTexture::create(texDesc, createDepth, depthStencilFormat); } SPtr RenderTextureEx::create(const HTexture& colorSurface) { return create(Vector{ colorSurface }, HTexture()); } SPtr RenderTextureEx::create(const HTexture& colorSurface, const HTexture& depthStencilSurface) { return create(Vector{ colorSurface }, depthStencilSurface); } SPtr RenderTextureEx::create(const Vector& colorSurface) { return create(Vector{ colorSurface }, HTexture()); } SPtr RenderTextureEx::create(const Vector& colorSurfaces, const HTexture& depthStencilSurface) { RENDER_SURFACE_DESC depthStencilSurfaceDesc; if (depthStencilSurface != nullptr) { depthStencilSurfaceDesc.face = 0; depthStencilSurfaceDesc.mipLevel = 0; depthStencilSurfaceDesc.numFaces = 1; if (!depthStencilSurface.isLoaded()) { LOGERR("Render texture must be created using a fully loaded texture."); } else depthStencilSurfaceDesc.texture = depthStencilSurface; } UINT32 numSurfaces = std::min((UINT32)colorSurfaces.size(), (UINT32)BS_MAX_MULTIPLE_RENDER_TARGETS); RENDER_TEXTURE_DESC desc; for (UINT32 i = 0; i < numSurfaces; i++) { RENDER_SURFACE_DESC surfaceDesc; surfaceDesc.face = 0; surfaceDesc.mipLevel = 0; surfaceDesc.numFaces = 1; if (!colorSurfaces[i].isLoaded()) { LOGERR("Render texture must be created using a fully loaded texture."); } else surfaceDesc.texture = colorSurfaces[i]; desc.colorSurfaces[i] = surfaceDesc; } desc.depthStencilSurface = depthStencilSurfaceDesc; return RenderTexture::create(desc); } Vector RenderTextureEx::getColorSurfaces(const SPtr& thisPtr) { UINT32 numColorSurfaces = BS_MAX_MULTIPLE_RENDER_TARGETS; Vector output; output.reserve(numColorSurfaces); for (UINT32 i = 0; i < numColorSurfaces; i++) { HTexture colorTex = thisPtr->getColorTexture(i); if (colorTex != nullptr) output.push_back(colorTex); } return output; } HTexture RenderTextureEx::getColorSurface(const SPtr& thisPtr) { return thisPtr->getColorTexture(0); } HTexture RenderTextureEx::getDepthStencilSurface(const SPtr& thisPtr) { return thisPtr->getDepthStencilTexture(); } }