check fb valid
This commit is contained in:
@@ -408,7 +408,7 @@ void NodeStrokePreview::draw_stroke_immediate()
|
||||
b->m_pattern_texture->bind() :
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
m_rtt_mixer.bindTexture();
|
||||
b->m_tip_mix > 0.f ? m_rtt_mixer.bindTexture() : glBindTexture(GL_TEXTURE_2D, 0);
|
||||
auto frames = stroke_draw_compute(m_stroke, zoom);
|
||||
m_rtt.clear();
|
||||
for (auto& f : frames)
|
||||
|
||||
25
src/rtt.cpp
25
src/rtt.cpp
@@ -6,7 +6,6 @@
|
||||
|
||||
RTT& RTT::operator=(RTT&& other)
|
||||
{
|
||||
LOG("RTT-move-assignment");
|
||||
int_fmt = other.int_fmt;
|
||||
texID = other.texID;
|
||||
fboID = other.fboID;
|
||||
@@ -38,8 +37,6 @@ RTT::RTT()
|
||||
|
||||
RTT::RTT(RTT&& other)
|
||||
{
|
||||
LOG("RTT-move-ctor");
|
||||
|
||||
int_fmt = other.int_fmt;
|
||||
texID = other.texID;
|
||||
fboID = other.fboID;
|
||||
@@ -59,10 +56,9 @@ RTT::RTT(RTT&& other)
|
||||
|
||||
RTT::~RTT()
|
||||
{
|
||||
LOG("RTT-dtor");
|
||||
//destroy();
|
||||
if (texID || rboID || fboID)
|
||||
if (valid())
|
||||
LOG("RTT not destroyed");
|
||||
destroy();
|
||||
}
|
||||
|
||||
bool RTT::resize(int width, int height)
|
||||
@@ -109,6 +105,8 @@ bool RTT::resize(int width, int height)
|
||||
|
||||
void RTT::destroy()
|
||||
{
|
||||
if (!valid())
|
||||
return;
|
||||
App::I->render_task_async([rboID=rboID, texID=texID, fboID=fboID]
|
||||
{
|
||||
if (rboID)
|
||||
@@ -137,6 +135,8 @@ void RTT::destroy()
|
||||
|
||||
void RTT::copy(const RTT & source)
|
||||
{
|
||||
if (!valid() || !source.valid())
|
||||
return;
|
||||
App::I->render_task([&]
|
||||
{
|
||||
GLint old_draw = 0;
|
||||
@@ -156,6 +156,8 @@ void RTT::copy(const RTT & source)
|
||||
|
||||
void RTT::copy(const RTT& source, const glm::vec4& rect)
|
||||
{
|
||||
if (!valid() || !source.valid())
|
||||
return;
|
||||
App::I->render_task([&]
|
||||
{
|
||||
auto r = rect_intersection(rect, { 0, 0, w, h });
|
||||
@@ -317,6 +319,9 @@ void RTT::clear_mask(glm::bool4 mask, glm::vec4 color)
|
||||
|
||||
glm::ivec4 RTT::calc_bounds() const noexcept
|
||||
{
|
||||
if (!valid())
|
||||
return glm::vec4(0);
|
||||
|
||||
auto data = std::unique_ptr<glm::u8vec4[]>(reinterpret_cast<glm::u8vec4*>(readTextureData()));
|
||||
glm::ivec2 bbmin(w, h);
|
||||
glm::ivec2 bbmax(0);
|
||||
@@ -336,6 +341,8 @@ glm::ivec4 RTT::calc_bounds() const noexcept
|
||||
|
||||
uint8_t* RTT::readTextureData(uint8_t* buffer) const noexcept
|
||||
{
|
||||
if (!valid())
|
||||
return nullptr;
|
||||
if (!buffer)
|
||||
buffer = createBuffer();
|
||||
App::I->render_task([&]
|
||||
@@ -351,6 +358,8 @@ uint8_t* RTT::readTextureData(uint8_t* buffer) const noexcept
|
||||
|
||||
float* RTT::readTextureDataFloat(float* buffer) const noexcept
|
||||
{
|
||||
if (!valid())
|
||||
return nullptr;
|
||||
if (!buffer)
|
||||
buffer = createBufferFloat();
|
||||
App::I->render_task([&]
|
||||
@@ -393,3 +402,7 @@ Image RTT::get_image() const noexcept
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool RTT::valid() const noexcept
|
||||
{
|
||||
return texID || rboID || fboID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user