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