mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Improve robustness of GL object handling
This commit is contained in:
parent
077828d0d9
commit
4b85062caf
4 changed files with 23 additions and 2 deletions
|
@ -100,7 +100,9 @@ class COpenGLCoreCacheHandler
|
|||
GL.Enable(curTextureType);
|
||||
#endif
|
||||
|
||||
GL.BindTexture(curTextureType, static_cast<const TOpenGLTexture *>(texture)->getOpenGLTextureName());
|
||||
auto name = static_cast<const TOpenGLTexture *>(texture)->getOpenGLTextureName();
|
||||
_IRR_DEBUG_BREAK_IF(name == 0)
|
||||
GL.BindTexture(curTextureType, name);
|
||||
} else {
|
||||
texture = 0;
|
||||
|
||||
|
|
|
@ -35,8 +35,14 @@ public:
|
|||
ColorAttachment = Driver->getFeature().ColorAttachment;
|
||||
MultipleRenderTarget = Driver->getFeature().MultipleRenderTarget;
|
||||
|
||||
if (ColorAttachment > 0)
|
||||
if (ColorAttachment > 0) {
|
||||
TEST_GL_ERROR(Driver);
|
||||
Driver->irrGlGenFramebuffers(1, &BufferID);
|
||||
if (!BufferID) {
|
||||
os::Printer::log("COpenGLCoreRenderTarget: framebuffer not created", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AssignedTextures.set_used(static_cast<u32>(ColorAttachment));
|
||||
|
||||
|
|
|
@ -99,6 +99,11 @@ public:
|
|||
}
|
||||
|
||||
GL.GenTextures(1, &TextureName);
|
||||
TEST_GL_ERROR(Driver);
|
||||
if (!TextureName) {
|
||||
os::Printer::log("COpenGLCoreTexture: texture not created", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
const COpenGLCoreTexture *prevTexture = Driver->getCacheHandler()->getTextureCache().get(0);
|
||||
Driver->getCacheHandler()->getTextureCache().set(0, this);
|
||||
|
@ -195,6 +200,11 @@ public:
|
|||
#endif
|
||||
|
||||
GL.GenTextures(1, &TextureName);
|
||||
TEST_GL_ERROR(Driver);
|
||||
if (!TextureName) {
|
||||
os::Printer::log("COpenGLCoreTexture: texture not created", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
const COpenGLCoreTexture *prevTexture = Driver->getCacheHandler()->getTextureCache().get(0);
|
||||
Driver->getCacheHandler()->getTextureCache().set(0, this);
|
||||
|
|
|
@ -212,6 +212,7 @@ void COpenGL3DriverBase::initQuadsIndices(u32 max_vertex_count)
|
|||
}
|
||||
QuadIndexVBO.upload(QuadsIndices.data(), QuadsIndices.size() * sizeof(u16),
|
||||
0, GL_STATIC_DRAW, true);
|
||||
assert(QuadIndexVBO.exists());
|
||||
}
|
||||
|
||||
void COpenGL3DriverBase::initVersion()
|
||||
|
@ -626,6 +627,7 @@ void COpenGL3DriverBase::drawBuffers(const scene::IVertexBuffer *vb,
|
|||
const void *vertices = vb->getData();
|
||||
if (hwvert) {
|
||||
assert(hwvert->IsVertex);
|
||||
assert(hwvert->Vbo.exists());
|
||||
GL.BindBuffer(GL_ARRAY_BUFFER, hwvert->Vbo.getName());
|
||||
vertices = nullptr;
|
||||
}
|
||||
|
@ -633,6 +635,7 @@ void COpenGL3DriverBase::drawBuffers(const scene::IVertexBuffer *vb,
|
|||
const void *indexList = ib->getData();
|
||||
if (hwidx) {
|
||||
assert(!hwidx->IsVertex);
|
||||
assert(hwidx->Vbo.exists());
|
||||
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, hwidx->Vbo.getName());
|
||||
indexList = nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue