Skip to content

Commit

Permalink
fixes for linux / intel gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Jul 29, 2024
1 parent 9bf3553 commit 8c25480
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sources/libengine/graphics/uniformBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace cage
else
{
if (usage == 0)
usage = GL_STATIC_DRAW;
usage = GL_DYNAMIC_DRAW;
glNamedBufferData(impl->id, buffer.size(), buffer.data(), usage);
CAGE_CHECK_GL_ERROR_DEBUG();
impl->size = numeric_cast<uint32>(buffer.size());
Expand Down
23 changes: 22 additions & 1 deletion sources/libengine/window/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ namespace cage
GLFWwindow *window = nullptr;
const int vsync = true;
bool focus = true;
#ifdef CAGE_DEBUG
uint64 currentThreadIdGlBound = 0;
#endif

#ifdef GCHL_WINDOWS_THREAD
Holder<Thread> windowThread;
Expand Down Expand Up @@ -733,14 +736,32 @@ namespace cage
glfwSetWindowPos(impl->window, tmp[0], tmp[1]);
}

#ifdef CAGE_DEBUG
namespace
{
Holder<Mutex> mutex = newMutex();
}
#endif

void Window::makeCurrent()
{
WindowImpl *impl = (WindowImpl *)this;
WindowImpl *impl = (WindowImpl *)this;
#ifdef CAGE_DEBUG
ScopeLock _(mutex);
CAGE_ASSERT(impl->currentThreadIdGlBound == 0);
impl->currentThreadIdGlBound = currentThreadId();
#endif
glfwMakeContextCurrent(impl->window);
}

void Window::makeNotCurrent()
{
#ifdef CAGE_DEBUG
WindowImpl *impl = (WindowImpl *)this;
ScopeLock _(mutex);
CAGE_ASSERT(impl->currentThreadIdGlBound == currentThreadId());
impl->currentThreadIdGlBound = 0;
#endif
glfwMakeContextCurrent(nullptr);
}

Expand Down
1 change: 1 addition & 0 deletions sources/libsimple/gameloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ namespace cage
{
graphicsFinalize();
assets->unloadCustomThread(1);
window->makeNotCurrent();
}

//////////////////////////////////////
Expand Down

0 comments on commit 8c25480

Please sign in to comment.