add gl::fence

This commit is contained in:
milek7
2018-10-21 00:38:39 +02:00
parent 7c9c19908a
commit cdd79e605c
3 changed files with 34 additions and 0 deletions

View File

@@ -108,6 +108,7 @@ set(SOURCES
"gl/cubemap.cpp"
"gl/glsl_common.cpp"
"gl/buffer.cpp"
"gl/fence.cpp"
"imgui/imgui.cpp"
"imgui/imgui_demo.cpp"

18
gl/fence.cpp Normal file
View File

@@ -0,0 +1,18 @@
#include "fence.h"
gl::fence::fence()
{
sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
gl::fence::~fence()
{
glDeleteSync(sync);
}
bool gl::fence::is_signalled()
{
GLint val;
glGetSynciv(sync, GL_SYNC_STATUS, 1, &val);
return val == GL_SIGNALED;
}

15
gl/fence.h Normal file
View File

@@ -0,0 +1,15 @@
#include "object.h"
namespace gl
{
class fence
{
GLsync sync;
public:
fence();
~fence();
bool is_signalled();
};
}