add glad to load OpenGL extensions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
135
src/brush.cpp
135
src/brush.cpp
@@ -4,141 +4,6 @@
|
||||
#include "asset.h"
|
||||
#include "app.h"
|
||||
|
||||
void BrushMesh::draw(const std::vector<StrokeSample>& samples, const glm::mat4& proj)
|
||||
{
|
||||
assert(App::I.is_render_thread());
|
||||
std::vector<instance_t> 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;
|
||||
|
||||
13
src/brush.h
13
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<StrokeSample>& samples, const glm::mat4& proj);
|
||||
};
|
||||
|
||||
class Stroke
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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<std::vector<vertex_t>, 6> Canvas::stroke_draw_project(std::array<vert
|
||||
|
||||
glm::vec4 Canvas::stroke_draw_samples(int i, std::vector<vertex_t>& P)
|
||||
{
|
||||
assert(App::I.is_render_thread());
|
||||
|
||||
if (!ShaderManager::ext_framebuffer_fetch)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
@@ -458,8 +454,6 @@ std::vector<Canvas::StrokeFrame> 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<bool, 6> faces /*= SIXPLETTE(false)*/)
|
||||
{
|
||||
assert(App::I.is_render_thread());
|
||||
|
||||
glViewport(0, 0, m_width, m_height);
|
||||
auto ortho = glm::ortho<float>(-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, "");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
37
src/main.cpp
37
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();
|
||||
|
||||
|
||||
@@ -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<bool(Node*)> observer)
|
||||
|
||||
@@ -141,6 +141,8 @@ void NodeDialogCloud::load_thumbs_thread()
|
||||
auto image_tex = node->find<NodeImageTexture>("thumb-tex");
|
||||
image_tex->tex.destroy();
|
||||
image_tex->tex.create(thumb);
|
||||
|
||||
app_redraw();
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -64,9 +64,11 @@
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <tchar.h>
|
||||
#include <gl\glew.h>
|
||||
#include <gl\wglew.h>
|
||||
#include <gl\GL.h>
|
||||
#ifdef _DEBUG
|
||||
#define GLAD_DEBUG
|
||||
#endif
|
||||
#include <glad\glad.h>
|
||||
#include <glad\glad_wgl.h>
|
||||
#include <BugTrap.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -718,7 +718,6 @@ void parallel_for(size_t nb_elements, std::function<void(size_t i)> 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);
|
||||
|
||||
Reference in New Issue
Block a user