diff --git a/.gitmodules b/.gitmodules
index d6498e9..927159e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -51,4 +51,7 @@
url = https://bitbucket.org/omigamedev/ovr_mobile.git
[submodule "libs/ovr_platform"]
path = libs/ovr_platform
- url = https://bitbucket.org/omigamedev/ovr_platform.git
\ No newline at end of file
+ url = https://bitbucket.org/omigamedev/ovr_platform.git
+[submodule "libs/glad"]
+ path = libs/glad
+ url = https://bitbucket.org/omigamedev/glad.git
diff --git a/PanoPainter.vcxproj b/PanoPainter.vcxproj
index c31c869..d138649 100644
--- a/PanoPainter.vcxproj
+++ b/PanoPainter.vcxproj
@@ -77,7 +77,7 @@
true
- libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;libs\sqlite3;libs\openvr\headers;libs\nanort;libs\hash-library;libs\fmt\include;$(IncludePath)
+ libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;libs\sqlite3;libs\openvr\headers;libs\nanort;libs\hash-library;libs\fmt\include;libs\glad\include;$(IncludePath)
libs\curl-win\lib\dll-$(Configuration)-$(PlatformShortName);libs\glew-2.0.0\lib\Release\$(Platform);libs\bugtrap-client\lib;libs\openvr\lib\win64;$(LibraryPath)
@@ -87,7 +87,7 @@
false
- libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;libs\sqlite3;libs\openvr\headers;libs\nanort;libs\hash-library;libs\fmt\include;$(IncludePath)
+ libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;libs\sqlite3;libs\openvr\headers;libs\nanort;libs\hash-library;libs\fmt\include;libs\glad\include;$(IncludePath)
libs\curl-win\lib\dll-$(Configuration)-$(PlatformShortName);libs\glew-2.0.0\lib\Release\$(Platform);libs\bugtrap-client\lib;libs\openvr\lib\win64;$(LibraryPath)
@@ -177,6 +177,14 @@
NotUsing
NotUsing
+
+ NotUsing
+ NotUsing
+
+
+ NotUsing
+ NotUsing
+
NotUsing
NotUsing
diff --git a/PanoPainter.vcxproj.filters b/PanoPainter.vcxproj.filters
index 1f0304b..a2c7f91 100644
--- a/PanoPainter.vcxproj.filters
+++ b/PanoPainter.vcxproj.filters
@@ -58,6 +58,9 @@
{a2cacb13-2854-44ee-9511-6cb8ac587428}
+
+ {ca37521b-213f-4bcf-acfd-eda1483a30b2}
+
@@ -357,6 +360,12 @@
Source Files\ui
+
+ libs\glad
+
+
+ libs\glad
+
diff --git a/libs/glad b/libs/glad
new file mode 160000
index 0000000..a949664
--- /dev/null
+++ b/libs/glad
@@ -0,0 +1 @@
+Subproject commit a9496640eec1c823315acb8f21df59107224e176
diff --git a/src/app.cpp b/src/app.cpp
index fa5e55d..56d2364 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -104,7 +104,6 @@ bool App::request_close()
void App::clear()
{
- assert(is_render_thread());
glClearColor(.1f, .1f, .1f, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
}
diff --git a/src/brush.cpp b/src/brush.cpp
index 4ae3c60..848dde5 100644
--- a/src/brush.cpp
+++ b/src/brush.cpp
@@ -4,141 +4,6 @@
#include "asset.h"
#include "app.h"
-void BrushMesh::draw(const std::vector& samples, const glm::mat4& proj)
-{
- assert(App::I.is_render_thread());
- std::vector attributes;
- attributes.reserve(samples.size());
- for (const auto& s : samples)
- {
- auto mvp = proj *
- glm::translate(s.pos) *
- glm::scale(glm::vec3(s.size, s.size, 1)) *
- glm::eulerAngleZ(s.angle);
- attributes.emplace_back(instance_t{ mvp, s.flow });
- }
-#ifdef USE_VBO
- glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
- glBufferData(GL_ARRAY_BUFFER, (int)(sizeof(instance_t) * attributes.size()), attributes.data(), GL_STATIC_DRAW);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- glBindVertexArray(vao);
- glDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0, (int)samples.size());
- glBindVertexArray(0);
-#else
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
- glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, pos));
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
-
- // Likewise, we can do the same with the model matrix. Note that a
- // matrix input to the vertex shader consumes N consecutive input
- // locations, where N is the number of columns in the matrix. So...
- // we have four vertex attributes to set up.
- glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
- glBufferData(GL_ARRAY_BUFFER, (int)(sizeof(instance_t) * attributes.size()), attributes.data(), GL_STATIC_DRAW);
- // Loop over each column of the matrix...
- for (int i = 0; i < 4; i++)
- {
- // Set up the vertex attribute
- glVertexAttribPointer(loc_mvp + i, 4, GL_FLOAT, GL_FALSE, sizeof(instance_t),
- (GLvoid*)(offsetof(instance_t, mvp) + sizeof(glm::vec4) * i));
- // Enable it
- glEnableVertexAttribArray(loc_mvp + i);
- // Make it instanced
- glVertexAttribDivisor(loc_mvp + i, 1);
- }
- glEnableVertexAttribArray(loc_flow);
- glVertexAttribPointer(loc_flow, 1, GL_FLOAT, GL_FALSE, sizeof(instance_t),
- (GLvoid*)offsetof(instance_t, flow));
- glVertexAttribDivisor(loc_flow, 1);
-
- glDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0, (int)samples.size());
- //glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
-
- glDisableVertexAttribArray(0);
- glDisableVertexAttribArray(1);
- for (int i = 0; i < 4; i++)
- glDisableVertexAttribArray(loc_mvp + i);
- glDisableVertexAttribArray(loc_flow);
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-#endif // USE_VBO
-}
-bool BrushMesh::create()
-{
- bool ret = true;
- App::I.render_task([&]
- {
- static GLushort idx[6]{ 0, 1, 2, 0, 2, 3 };
- static vertex_t vertices[4]{
- { { -.5f, -.5f, 0, 1 }, { 0, 0 } }, // A B----C
- { { -.5f, .5f, 0, 1 }, { 0, 1 } }, // B --\ | |
- { { .5f, .5f, 0, 1 }, { 1, 1 } }, // C --/ | |
- { { .5f, -.5f, 0, 1 }, { 1, 0 } }, // D A----D
- };
- glGenBuffers(3, buffers);
- if (!(buffers[0] && buffers[1] && buffers[2]))
- {
- ret = false;
- return;
- }
-
- static instance_t inst{ glm::mat4(1), .1f };
- glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
- glBufferData(GL_ARRAY_BUFFER, sizeof(instance_t), &inst, GL_STATIC_DRAW);
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(idx), idx, GL_STATIC_DRAW);
- glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
- glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- auto shader = ShaderManager::get(kShader::BrushStroke);
-
- loc_flow = shader->GetAttribLocation("a_flow");
- loc_mvp = shader->GetAttribLocation("a_mvp");
-
-#if USE_VBO
- glGenVertexArrays(1, &vao);
- if (!vao)
- {
- ret = false;
- return;
- }
- glBindVertexArray(vao);
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
- glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, pos));
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
- glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
- // Loop over each column of the matrix...
- for (int i = 0; i < 4; i++)
- {
- // Set up the vertex attribute
- glVertexAttribPointer(loc_mvp + i, 4, GL_FLOAT, GL_FALSE, sizeof(instance_t),
- (GLvoid*)(offsetof(instance_t, mvp) + sizeof(glm::vec4) * i));
- // Enable it
- glEnableVertexAttribArray(loc_mvp + i);
- // Make it instanced
- glVertexAttribDivisor(loc_mvp + i, 1);
- }
- glEnableVertexAttribArray(loc_flow);
- glVertexAttribPointer(loc_flow, 1, GL_FLOAT, GL_FALSE, sizeof(instance_t),
- (GLvoid*)offsetof(instance_t, flow));
- glVertexAttribDivisor(loc_flow, 1);
- glBindVertexArray(0);
-#endif
- });
-
- return ret;
-}
StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, float dir_angle)
{
float size_dyn = m_brush->m_tip_size_pressure ? pressure : 1.f;
diff --git a/src/brush.h b/src/brush.h
index 092eaf4..36814ff 100644
--- a/src/brush.h
+++ b/src/brush.h
@@ -136,19 +136,6 @@ struct StrokeSample
}
};
-class BrushMesh
-{
-public:
- GLuint buffers[3]{ 0 };
- GLuint vao{ 0 };
- struct instance_t { glm::mat4 mvp; float flow; };
- int loc_flow = 0;
- int loc_mvp = 0;
-
- bool create();
- void draw(const std::vector& samples, const glm::mat4& proj);
-};
-
class Stroke
{
public:
diff --git a/src/canvas.cpp b/src/canvas.cpp
index 0b5a5ae..849f839 100644
--- a/src/canvas.cpp
+++ b/src/canvas.cpp
@@ -179,8 +179,6 @@ void Canvas::stroke_cancel()
}
void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz)
{
- assert(App::I.is_render_thread());
-
gl_state gl;
gl.save();
@@ -323,8 +321,6 @@ std::array, 6> Canvas::stroke_draw_project(std::array& P)
{
- assert(App::I.is_render_thread());
-
if (!ShaderManager::ext_framebuffer_fetch)
{
glActiveTexture(GL_TEXTURE1);
@@ -458,8 +454,6 @@ std::vector Canvas::stroke_draw_compute(Stroke& stroke) con
void Canvas::stroke_draw()
{
- assert(App::I.is_render_thread());
-
if (!(m_current_stroke && m_current_stroke->has_sample()))
{
//stroke_draw_mix({ 0,0 }, { m_mixer.getWidth(), m_mixer.getHeight() });
@@ -696,8 +690,6 @@ glm::vec3 Canvas::point_trace(glm::vec2 loc)
}
void Canvas::stroke_commit()
{
- assert(App::I.is_render_thread());
-
if (!m_dirty || m_layers.empty())
return;
@@ -874,8 +866,6 @@ void Canvas::stroke_commit()
void Canvas::draw_merge(std::array faces /*= SIXPLETTE(false)*/)
{
- assert(App::I.is_render_thread());
-
glViewport(0, 0, m_width, m_height);
auto ortho = glm::ortho(-0.5f, 0.5f, -0.5f, 0.5f, -1.f, 1.f);
const auto& b = m_current_stroke->m_brush;
@@ -1130,8 +1120,6 @@ void Canvas::stroke_update(glm::vec3 point, float pressure)
}
void Canvas::stroke_start(glm::vec3 point, float pressure)
{
- assert(App::I.is_render_thread());
-
// need to commit this now before starting a new stroke
if (m_current_stroke && m_commit_delayed)
{
@@ -1542,7 +1530,6 @@ bool Canvas::create(int width, int height)
m_plane.create<1>(1, 1);
m_plane_brush.create<1>(1, 1);
m_brush_shape.create();
- m_mesh.create();
m_brush_mix.create(8, 8);
for (auto& l : m_layers)
l->create(width, height, "");
diff --git a/src/canvas.h b/src/canvas.h
index d4c64db..d196872 100644
--- a/src/canvas.h
+++ b/src/canvas.h
@@ -79,7 +79,6 @@ public:
Plane m_plane;
Plane m_plane_brush;
DynamicShape m_brush_shape;
- BrushMesh m_mesh;
bool m_unsaved = false;
bool m_newdoc = true;
bool m_dirty = false;
diff --git a/src/canvas_modes.cpp b/src/canvas_modes.cpp
index 41228c5..d8756f5 100644
--- a/src/canvas_modes.cpp
+++ b/src/canvas_modes.cpp
@@ -227,8 +227,6 @@ void CanvasModePen::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
void CanvasModePen::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
if (m_draw_tip)
{
const auto& brush = Canvas::I->m_current_brush;
@@ -340,8 +338,6 @@ void CanvasModeLine::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
void CanvasModeLine::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
if (m_dragging)
{
ShaderManager::use(kShader::Color);
@@ -519,8 +515,6 @@ void CanvasModeGrid::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
void CanvasModeGrid::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
const glm::vec4 blue(0, 0, 1, 1);
const glm::vec4 red(1, 0, 0, 1);
for (int i = 0; i < m_lines.size(); i++)
@@ -749,8 +743,6 @@ void CanvasModeMaskFree::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
void CanvasModeMaskFree::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
bool depth = glIsEnabled(GL_DEPTH_TEST);
glDisable(GL_DEPTH_TEST);
if (m_points.size() > 3)
@@ -910,8 +902,6 @@ void CanvasModeMaskLine::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
void CanvasModeMaskLine::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
if (m_points.size() > 1)
{
if (m_active_tool)
@@ -1034,8 +1024,6 @@ void CanvasModeFill::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
void CanvasModeFill::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
if (!m_points.empty())
{
ShaderManager::use(kShader::Color);
@@ -1426,8 +1414,6 @@ void CanvasModeTransform::leave(kCanvasMode next)
void CanvasModeTransform::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
bool depth = glIsEnabled(GL_DEPTH_TEST);
glDisable(GL_DEPTH_TEST);
@@ -1669,8 +1655,6 @@ void CanvasModeFloodFill::init()
void CanvasModeFloodFill::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
{
- assert(App::I.is_render_thread());
-
if (m_draw_tip)
{
ShaderManager::use(kShader::Texture);
diff --git a/src/font.cpp b/src/font.cpp
index 170cb72..a765f02 100644
--- a/src/font.cpp
+++ b/src/font.cpp
@@ -139,7 +139,6 @@ void TextMesh::update(kFont id, const char* text)
void TextMesh::draw()
{
- assert(App::I.is_render_thread());
auto& f = FontManager::get(font_id);
if (f.font_tex.ready())
{
diff --git a/src/main.cpp b/src/main.cpp
index 4c0d711..3bee26a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -707,6 +707,22 @@ BOOL UnadjustWindowRectEx(LPRECT prc, DWORD dwStyle, BOOL fMenu, DWORD dwExStyle
return fRc;
}
+void _pre_call_callback(const char* name, void* funcptr, int len_args, ...)
+{
+ assert(App::I.is_render_thread());
+}
+
+void _post_call_callback(const char* name, void* funcptr, int len_args, ...)
+{
+ GLenum error_code;
+ error_code = glad_glGetError();
+
+ if (error_code != GL_NO_ERROR)
+ {
+ LOG("ERROR %d in %s\n", error_code, name);
+ }
+}
+
int main(int argc, char** argv)
{
WNDCLASS wc;
@@ -814,8 +830,16 @@ int main(int argc, char** argv)
wglMakeCurrent(hDC, hRC);
// Initialize extensions
- if (glewInit() != GLEW_OK)
+ if (!gladLoadGL())
+ {
+ LOG("gladLoadGL() failed");
return 0;
+ }
+ if (!gladLoadWGL(hDC))
+ {
+ LOG("gladLoadWGL() failed");
+ return 0;
+ }
LOG("GL version: %s", glGetString(GL_VERSION));
LOG("GL vendor: %s", glGetString(GL_VENDOR));
@@ -825,13 +849,13 @@ int main(int argc, char** argv)
swprintf_s(window_title, L"PanoPainter %s (%s)", g_version_number_w,
str2wstr((char*)glGetString(GL_RENDERER)).c_str());
- // If supported create a 3.1 context
- if (wglewIsSupported("WGL_ARB_create_context"))
+ // If supported create a 3.3 context
+ if (GLAD_WGL_ARB_create_context)
{
int contex_attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
- WGL_CONTEXT_MINOR_VERSION_ARB, 1,
+ WGL_CONTEXT_MINOR_VERSION_ARB, 3,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0
@@ -904,6 +928,11 @@ int main(int argc, char** argv)
App::I.render_thread_start();
App::I.ui_thread_start();
+#ifdef _DEBUG
+ glad_set_pre_callback(_pre_call_callback);
+ glad_set_post_callback(_post_call_callback);
+#endif
+
LOG("init app");
App::I.init();
diff --git a/src/node.cpp b/src/node.cpp
index 194c488..8b5024c 100644
--- a/src/node.cpp
+++ b/src/node.cpp
@@ -39,7 +39,7 @@
void Node::app_redraw()
{
- App::I.redraw = true;
+ App::I.ui_task([] { App::I.redraw = true; });
}
void Node::watch(std::function observer)
diff --git a/src/node_dialog_cloud.cpp b/src/node_dialog_cloud.cpp
index 9d55652..42c1d22 100644
--- a/src/node_dialog_cloud.cpp
+++ b/src/node_dialog_cloud.cpp
@@ -141,6 +141,8 @@ void NodeDialogCloud::load_thumbs_thread()
auto image_tex = node->find("thumb-tex");
image_tex->tex.destroy();
image_tex->tex.create(thumb);
+
+ app_redraw();
}
curl_easy_cleanup(curl);
}
diff --git a/src/pch.cpp b/src/pch.cpp
index 2ad93f5..ed69b62 100644
--- a/src/pch.cpp
+++ b/src/pch.cpp
@@ -17,7 +17,6 @@
#pragma comment(lib, "BugTrapU-x64.lib")
#pragma comment(lib, "shell32.lib")
#pragma comment(lib, "opengl32.lib")
- #pragma comment(lib, "glew32.lib")
#pragma comment(lib, "wbemuuid.lib")
#pragma comment(lib, "Shlwapi.lib")
//#pragma comment(lib, "Shcore.lib")
diff --git a/src/pch.h b/src/pch.h
index 0317f09..c58fdff 100644
--- a/src/pch.h
+++ b/src/pch.h
@@ -64,9 +64,11 @@
#include
#include
#include
- #include
- #include
- #include
+#ifdef _DEBUG
+ #define GLAD_DEBUG
+#endif
+ #include
+ #include
#include
#include
#include
diff --git a/src/rtt.cpp b/src/rtt.cpp
index d3519f3..54e0f22 100644
--- a/src/rtt.cpp
+++ b/src/rtt.cpp
@@ -198,7 +198,6 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format,
void RTT::bindFramebuffer()
{
- assert(App::I.is_render_thread());
#ifdef _DEBUG
if (bound)
{
@@ -217,7 +216,6 @@ void RTT::bindFramebuffer()
void RTT::unbindFramebuffer()
{
- assert(App::I.is_render_thread());
if (!bound)
return;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDFboID);
@@ -229,7 +227,6 @@ void RTT::unbindFramebuffer()
void RTT::clear(glm::vec4 color)
{
- assert(App::I.is_render_thread());
glClearColor(color.r, color.g, color.b, color.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
@@ -295,13 +292,11 @@ float * RTT::createBufferFloat()
void RTT::bindTexture()
{
- assert(App::I.is_render_thread());
glBindTexture(GL_TEXTURE_2D, texID);
}
void RTT::unbindTexture()
{
- assert(App::I.is_render_thread());
glBindTexture(GL_TEXTURE_2D, 0);
}
diff --git a/src/shader.cpp b/src/shader.cpp
index d4e4252..190e15c 100644
--- a/src/shader.cpp
+++ b/src/shader.cpp
@@ -290,19 +290,16 @@ void Shader::destroy()
void Shader::use()
{
- assert(App::I.is_render_thread());
glUseProgram(prog);
}
void Shader::u_vec4(kShaderUniform id, const glm::vec4& v)
{
- assert(App::I.is_render_thread());
if (m_umap.count(id) == 0)
LOG("UNIFORM vec4 %d NOT FOUND in shader %d", (int)id, (int)name)
else glUniform4fv(m_umap[id], 1, glm::value_ptr(v));
}
void Shader::u_vec3(kShaderUniform id, const glm::vec3& v)
{
- assert(App::I.is_render_thread());
if (m_umap.count(id) == 0)
LOG("UNIFORM vec3 %d NOT FOUND in shader %d", (int)id, (int)name)
else glUniform3fv(m_umap[id], 1, glm::value_ptr(v));
@@ -310,7 +307,6 @@ void Shader::u_vec3(kShaderUniform id, const glm::vec3& v)
void Shader::u_vec2(kShaderUniform id, const glm::vec2& v)
{
- assert(App::I.is_render_thread());
if (m_umap.count(id) == 0)
LOG("UNIFORM vec2 %d NOT FOUND in shader %d", (int)id, (int)name)
else glUniform2fv(m_umap[id], 1, glm::value_ptr(v));
@@ -318,14 +314,12 @@ void Shader::u_vec2(kShaderUniform id, const glm::vec2& v)
void Shader::u_mat4(kShaderUniform id, const glm::mat4& m)
{
- assert(App::I.is_render_thread());
if (m_umap.count(id) == 0)
LOG("UNIFORM mat4 %d NOT FOUND in shader %d", (int)id, (int)name)
else glUniformMatrix4fv(m_umap[id], 1, GL_FALSE, glm::value_ptr(m));
}
void Shader::u_int(kShaderUniform id, int i)
{
- assert(App::I.is_render_thread());
if (m_umap.count(id) == 0)
LOG("UNIFORM int %d NOT FOUND in shader %d", (int)id, (int)name)
else
@@ -333,14 +327,12 @@ void Shader::u_int(kShaderUniform id, int i)
}
void Shader::u_float(kShaderUniform id, float f)
{
- assert(App::I.is_render_thread());
if (m_umap.count(id) == 0)
LOG("UNIFORM float %d NOT FOUND in shader %d", (int)id, (int)name)
else glUniform1f(m_umap[id], f);
}
GLint Shader::GetAttribLocation(const char* name)
{
- assert(App::I.is_render_thread());
return glGetAttribLocation(prog, name);
}
diff --git a/src/texture.cpp b/src/texture.cpp
index 368503d..aaa4575 100644
--- a/src/texture.cpp
+++ b/src/texture.cpp
@@ -118,13 +118,11 @@ void Texture2D::destroy()
void Texture2D::bind() const
{
- assert(App::I.is_render_thread());
glBindTexture(GL_TEXTURE_2D, m_tex);
}
void Texture2D::unbind() const
{
- assert(App::I.is_render_thread());
glBindTexture(GL_TEXTURE_2D, 0);
}
diff --git a/src/util.cpp b/src/util.cpp
index e105e53..dec3afa 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -718,7 +718,6 @@ void parallel_for(size_t nb_elements, std::function functor, boo
void gl_state::save()
{
- assert(App::I.is_render_thread());
blend = glIsEnabled(GL_BLEND);
depth_test = glIsEnabled(GL_DEPTH_TEST);
scissor_test = glIsEnabled(GL_SCISSOR_TEST);
@@ -738,7 +737,6 @@ void gl_state::save()
void gl_state::restore()
{
- assert(App::I.is_render_thread());
blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
depth_test ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
scissor_test ? glEnable(GL_SCISSOR_TEST) : glDisable(GL_SCISSOR_TEST);