From 9176b546e3bbaa66e975d6df050b4db83a4400b0 Mon Sep 17 00:00:00 2001 From: X512 Date: Sun, 23 Feb 2020 08:45:12 +0900 Subject: [PATCH] Haiku3d: fix textures Textures creation like other OpenGL calls must be inside LockGL/UnlockGL. Fixes #15246. Change-Id: Id1f3ae7c04548dba301e5c5ba75a89163c08d69d Reviewed-on: https://review.haiku-os.org/c/haiku/+/2269 Reviewed-by: Adrien Destugues --- src/apps/haiku3d/RenderView.cpp | 8 ++++++++ src/apps/haiku3d/texture/BitmapTexture.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/apps/haiku3d/RenderView.cpp b/src/apps/haiku3d/RenderView.cpp index 4afe5e2685..b97f85aaeb 100644 --- a/src/apps/haiku3d/RenderView.cpp +++ b/src/apps/haiku3d/RenderView.cpp @@ -142,6 +142,8 @@ void RenderView::_InitGL(void) void RenderView::_CreateScene() { + LockGL(); + Texture* texture = new BitmapTexture( BTranslationUtils::GetBitmap(B_PNG_FORMAT, "texture")); @@ -187,17 +189,23 @@ RenderView::_CreateScene() texture->ReleaseReference(); fMainCamera = new Camera(Vector3(0, 0, 0), Quaternion(0, 0, 0, 1), 50); + + UnlockGL(); } void RenderView::_DeleteScene() { + LockGL(); + MeshInstanceList::iterator it = fMeshInstances.begin(); for (; it != fMeshInstances.end(); it++) { delete (*it); } fMeshInstances.clear(); + + UnlockGL(); } diff --git a/src/apps/haiku3d/texture/BitmapTexture.cpp b/src/apps/haiku3d/texture/BitmapTexture.cpp index 483daadfb5..5e3353af12 100644 --- a/src/apps/haiku3d/texture/BitmapTexture.cpp +++ b/src/apps/haiku3d/texture/BitmapTexture.cpp @@ -37,7 +37,7 @@ BitmapTexture::_Load(BBitmap* bitmap) { glBindTexture(GL_TEXTURE_2D, fId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, 4, + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (int) bitmap->Bounds().Width() + 1, (int) bitmap->Bounds().Height() + 1, 0, GL_BGRA, GL_UNSIGNED_BYTE,